Added the option to not have HolographicDisplays installed.

This commit is contained in:
GB6 2019-01-21 13:53:01 +01:00
parent a82eafe636
commit 5febb15458
5 changed files with 35 additions and 12 deletions

View File

@ -181,5 +181,11 @@
<version>4.1.0</version> <version>4.1.0</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>com.songoda</groupId>
<artifactId>craftbukkit-1-13</artifactId>
<version>4.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -5,7 +5,10 @@ import com.songoda.epicfurnaces.command.CommandManager;
import com.songoda.epicfurnaces.handlers.BlacklistHandler; import com.songoda.epicfurnaces.handlers.BlacklistHandler;
import com.songoda.epicfurnaces.hook.CraftBukkitHook; import com.songoda.epicfurnaces.hook.CraftBukkitHook;
import com.songoda.epicfurnaces.hooks.*; import com.songoda.epicfurnaces.hooks.*;
import com.songoda.epicfurnaces.listeners.*; import com.songoda.epicfurnaces.listeners.BlockListeners;
import com.songoda.epicfurnaces.listeners.FurnaceListeners;
import com.songoda.epicfurnaces.listeners.InteractListeners;
import com.songoda.epicfurnaces.listeners.InventoryListeners;
import com.songoda.epicfurnaces.managers.*; import com.songoda.epicfurnaces.managers.*;
import com.songoda.epicfurnaces.storage.Storage; import com.songoda.epicfurnaces.storage.Storage;
import com.songoda.epicfurnaces.storage.types.StorageMysql; import com.songoda.epicfurnaces.storage.types.StorageMysql;
@ -32,12 +35,16 @@ import org.json.simple.JSONArray;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser; import org.json.simple.parser.JSONParser;
import java.io.*; import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import static com.songoda.epicfurnaces.utils.StringUtils.formatText; import static com.songoda.epicfurnaces.utils.StringUtils.formatText;
import static java.util.Arrays.asList; import static java.util.Arrays.asList;
@ -69,6 +76,8 @@ public class EpicFurnaces extends JavaPlugin {
return; return;
} }
Bukkit.getConsoleSender().sendMessage(formatText("Holographic displays " + (Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays") ? "found, enabling support for holograms!" : "not found, holograms will not work.")));
for (String name : asList("config", "data", "hooks", "blacklist", "Furnace Recipes")) { for (String name : asList("config", "data", "hooks", "blacklist", "Furnace Recipes")) {
File file = new File(getDataFolder(), name + ".yml"); File file = new File(getDataFolder(), name + ".yml");
if (!file.exists()) { if (!file.exists()) {
@ -102,11 +111,14 @@ public class EpicFurnaces extends JavaPlugin {
this.boostManager = new BoostManager(this); this.boostManager = new BoostManager(this);
this.blacklistHandler = new BlacklistHandler(this); this.blacklistHandler = new BlacklistHandler(this);
this.bukkitEnums = new BukkitEnums(this); this.bukkitEnums = new BukkitEnums(this);
this.hologramManager = new HologramManager(this);
this.levelManager = new LevelManager(this); this.levelManager = new LevelManager(this);
this.hookManager = new HookManager(this); this.hookManager = new HookManager(this);
this.economy = getServer().getServicesManager().getRegistration(Economy.class).getProvider(); this.economy = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
if (Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) {
this.hologramManager = new HologramManager(this);
}
checkStorage(); checkStorage();
levelManager.loadLevelManager(); levelManager.loadLevelManager();
setupRecipes(); setupRecipes();
@ -154,7 +166,7 @@ public class EpicFurnaces extends JavaPlugin {
Bukkit.getConsoleSender().sendMessage(formatText("&7EpicFurnaces " + this.getDescription().getVersion() + " by &5Songoda <3&7!")); Bukkit.getConsoleSender().sendMessage(formatText("&7EpicFurnaces " + this.getDescription().getVersion() + " by &5Songoda <3&7!"));
Bukkit.getConsoleSender().sendMessage(formatText("&7Action: &cDisabling&7...")); Bukkit.getConsoleSender().sendMessage(formatText("&7Action: &cDisabling&7..."));
Bukkit.getConsoleSender().sendMessage(formatText("&a=============================")); Bukkit.getConsoleSender().sendMessage(formatText("&a============================="));
hologramManager.clearAll(); getHologramManager().ifPresent(HologramManager::clearAll);
saveToFile(); saveToFile();
} }
@ -301,8 +313,8 @@ public class EpicFurnaces extends JavaPlugin {
return bukkitEnums; return bukkitEnums;
} }
public HologramManager getHologramManager() { public Optional<HologramManager> getHologramManager() {
return hologramManager; return Optional.ofNullable(hologramManager);
} }
public HookManager getHookManager() { public HookManager getHookManager() {

View File

@ -26,7 +26,7 @@ public class FurnaceManager {
} }
public FurnaceObject addFurnace(Location location, FurnaceObject furnace) { public FurnaceObject addFurnace(Location location, FurnaceObject furnace) {
instance.getHologramManager().updateHologram(furnace); instance.getHologramManager().ifPresent(manager -> manager.updateHologram(furnace));
registeredFurnaces.put(roundLocation(location), furnace); registeredFurnaces.put(roundLocation(location), furnace);
return furnace; return furnace;
} }
@ -40,7 +40,7 @@ public class FurnaceManager {
} }
public void removeFurnace(Location location) { public void removeFurnace(Location location) {
instance.getHologramManager().remove(registeredFurnaces.remove(location)); instance.getHologramManager().ifPresent(manager -> manager.remove(registeredFurnaces.remove(location)));
} }
public Optional<FurnaceObject> getFurnace(Location location) { public Optional<FurnaceObject> getFurnace(Location location) {
@ -118,7 +118,12 @@ public class FurnaceManager {
instance.getBoostManager().addBoostToPlayer(boostData); instance.getBoostManager().addBoostToPlayer(boostData);
} }
} }
getFurnaces().values().forEach(furnace -> instance.getHologramManager().updateHologram(furnace));
if (!instance.getConfig().getBoolean("Main.Furnaces Have Holograms")) {
return;
}
getFurnaces().values().forEach(furnace -> instance.getHologramManager().ifPresent(manager -> manager.updateHologram(furnace)));
} }
public void saveToFile() { public void saveToFile() {

View File

@ -31,6 +31,6 @@ public class HologramTask extends BukkitRunnable {
instance.getFurnaceManager().getFurnaces().values().stream() instance.getFurnaceManager().getFurnaces().values().stream()
.filter(furnace -> furnace.getLocation() != null && furnace.getLocation().getWorld() != null && furnace.getLocation().getBlock() != null) .filter(furnace -> furnace.getLocation() != null && furnace.getLocation().getWorld() != null && furnace.getLocation().getBlock() != null)
.forEach(furnace -> instance.getHologramManager().updateHologram(furnace)); .forEach(furnace -> instance.getHologramManager().ifPresent(manager -> manager.updateHologram(furnace)));
} }
} }

View File

@ -3,8 +3,8 @@ version: ${project.version}
main: com.songoda.epicfurnaces.EpicFurnaces main: com.songoda.epicfurnaces.EpicFurnaces
authors: [Brianna, GB6] authors: [Brianna, GB6]
website: https://songoda.com/ website: https://songoda.com/
depend: [HolographicDisplays, Vault] depend: [Vault]
softdepend: [PlotSquared, GriefPrevention, USkyBlock, SkyBlock, WorldGuard, Factions] softdepend: [PlotSquared, GriefPrevention, USkyBlock, SkyBlock, WorldGuard, Factions, HolographicDisplays]
commands: commands:
epicfurnaces: epicfurnaces:
description: Default command for the EpicFurnaces plugin. description: Default command for the EpicFurnaces plugin.