diff --git a/pom.xml b/pom.xml
index 185ee3eb..b2761b2b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
4.0.0
de.erethon
dungeonsxl
- 0.17.5-SNAPSHOT
+ 0.17.5
jar
DungeonsXL
https://dre2n.github.io
diff --git a/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java b/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java
index 429cd061..45ed214c 100644
--- a/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java
+++ b/src/main/java/de/erethon/dungeonsxl/DungeonsXL.java
@@ -23,10 +23,7 @@ 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.Announcer;
import de.erethon.dungeonsxl.announcer.AnnouncerCache;
-import de.erethon.dungeonsxl.announcer.AnnouncerListener;
-import de.erethon.dungeonsxl.announcer.AnnouncerTask;
import de.erethon.dungeonsxl.command.DCommandCache;
import de.erethon.dungeonsxl.config.DMessage;
import de.erethon.dungeonsxl.config.MainConfig;
@@ -216,7 +213,7 @@ public class DungeonsXL extends DREPlugin {
protections = new GlobalProtectionCache(this);
dMobProviders = new ExternalMobProviderCache(this);
dPlayers = new DPlayerCache(this);
- announcers = new AnnouncerCache();
+ announcers = new AnnouncerCache(this);
dClasses = new DClassCache(this);
signScripts = new SignScriptCache();
dCommands = new DCommandCache(this);
@@ -235,7 +232,7 @@ public class DungeonsXL extends DREPlugin {
globalData.load();
dMobProviders.init();
dPlayers.init();
- initAnnouncerCache(ANNOUNCERS);
+ announcers.init(ANNOUNCERS);
dClasses.init(CLASSES);
Bukkit.getPluginManager().registerEvents(new DMobListener(), this);
signScripts.init(SIGNS);
@@ -367,18 +364,6 @@ public class DungeonsXL extends DREPlugin {
return announcers;
}
- private void initAnnouncerCache(File file) {
- if (file.isDirectory()) {
- for (File script : FileUtil.getFilesForFolder(file)) {
- announcers.addAnnouncer(new Announcer(this, script));
- }
- }
- if (!announcers.getAnnouncers().isEmpty()) {
- announcers.setAnnouncerTask(new AnnouncerTask(this).runTaskTimer(this, mainConfig.getAnnouncmentInterval(), mainConfig.getAnnouncmentInterval()));
- }
- Bukkit.getPluginManager().registerEvents(new AnnouncerListener(this), this);
- }
-
/**
* @return the loaded instance of DClassCache
*/
diff --git a/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java b/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java
index 4c2b520c..52dfa187 100644
--- a/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java
+++ b/src/main/java/de/erethon/dungeonsxl/announcer/Announcer.java
@@ -41,7 +41,6 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.material.Wool;
/**
* Represents a game announcement.
@@ -351,7 +350,7 @@ public class Announcer {
public void clickGroupButton(Player player, ItemStack button) {
DGroup dGroup = getDGroupByButton(button);
DGroup pGroup = DGroup.getByPlayer(player);
- DColor color = DColor.getByDyeColor(((Wool) button.getData()).getColor());
+ DColor color = DColor.getByWoolType(plugin.getCaliburn().getExItem(button));
for (DGroup group : dGroups) {
if (dGroups.contains(pGroup) && pGroup != null && pGroup.isCustom() && pGroup.getCaptain() == player) {
diff --git a/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerCache.java b/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerCache.java
index 41c69e4d..4f55f7e5 100644
--- a/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerCache.java
+++ b/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerCache.java
@@ -16,11 +16,13 @@
*/
package de.erethon.dungeonsxl.announcer;
+import de.erethon.dungeonsxl.DungeonsXL;
+import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.inventory.Inventory;
-import org.bukkit.scheduler.BukkitTask;
/**
* Announcer instance manager.
@@ -29,10 +31,27 @@ import org.bukkit.scheduler.BukkitTask;
*/
public class AnnouncerCache {
- private BukkitTask announcerTask;
+ private DungeonsXL plugin;
private List announcers = new ArrayList<>();
+ public AnnouncerCache(DungeonsXL plugin) {
+ this.plugin = plugin;
+ }
+
+ public void init(File folder) {
+ if (!folder.exists()) {
+ folder.mkdir();
+ }
+ for (File file : folder.listFiles()) {
+ addAnnouncer(new Announcer(plugin, file));
+ }
+ if (!announcers.isEmpty()) {
+ new AnnouncerTask(plugin).runTaskTimer(plugin, plugin.getMainConfig().getAnnouncmentInterval(), plugin.getMainConfig().getAnnouncmentInterval());
+ }
+ Bukkit.getPluginManager().registerEvents(new AnnouncerListener(plugin), plugin);
+ }
+
/**
* @param name the name
* @return the announcer that has the name
@@ -82,18 +101,4 @@ public class AnnouncerCache {
announcers.remove(announcer);
}
- /**
- * @return the AnnouncerTask
- */
- public BukkitTask getAnnouncerTask() {
- return announcerTask;
- }
-
- /**
- * @param announcerTask the AnnouncerTask to set
- */
- public void setAnnouncerTask(BukkitTask announcerTask) {
- this.announcerTask = announcerTask;
- }
-
}
diff --git a/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerListener.java b/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerListener.java
index a5ba22a0..e8c3b464 100644
--- a/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerListener.java
+++ b/src/main/java/de/erethon/dungeonsxl/announcer/AnnouncerListener.java
@@ -16,6 +16,7 @@
*/
package de.erethon.dungeonsxl.announcer;
+import de.erethon.caliburn.category.Category;
import de.erethon.dungeonsxl.DungeonsXL;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@@ -23,7 +24,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.material.Wool;
/**
* @author Daniel Saukel
@@ -46,7 +46,7 @@ public class AnnouncerListener implements Listener {
Inventory gui = event.getInventory();
ItemStack button = event.getCurrentItem();
Announcer announcer = announcers.getByGUI(gui);
- if (announcer != null && button != null && button.getData() instanceof Wool) {
+ if (announcer != null && button != null && Category.WOOL.containsMaterial(button.getType())) {
announcer.clickGroupButton(player, button);
}
}
diff --git a/src/main/java/de/erethon/dungeonsxl/util/DColor.java b/src/main/java/de/erethon/dungeonsxl/util/DColor.java
index 09ddfb45..6c236e15 100644
--- a/src/main/java/de/erethon/dungeonsxl/util/DColor.java
+++ b/src/main/java/de/erethon/dungeonsxl/util/DColor.java
@@ -16,6 +16,7 @@
*/
package de.erethon.dungeonsxl.util;
+import de.erethon.caliburn.item.ExItem;
import de.erethon.caliburn.item.VanillaItem;
import de.erethon.commons.compatibility.Version;
import org.bukkit.ChatColor;
@@ -92,6 +93,19 @@ public enum DColor {
return woolMaterial;
}
+ /**
+ * @param color the ChatColor to check
+ * @return the matching DColor or null
+ */
+ public static DColor getByChatColor(ChatColor color) {
+ for (DColor dColor : values()) {
+ if (dColor.chat == color) {
+ return dColor;
+ }
+ }
+ return null;
+ }
+
/**
* @param color the DyeColor to check
* @return the matching DColor or null
@@ -106,12 +120,12 @@ public enum DColor {
}
/**
- * @param color the ChatColor to check
+ * @param wool the wool item to check
* @return the matching DColor or null
*/
- public static DColor getByChatColor(ChatColor color) {
+ public static DColor getByWoolType(ExItem wool) {
for (DColor dColor : values()) {
- if (dColor.chat == color) {
+ if (dColor.woolMaterial == wool) {
return dColor;
}
}