mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2025-02-10 16:41:24 +01:00
Merge branch 'development'
This commit is contained in:
commit
60e865bb35
12
pom.xml
12
pom.xml
@ -2,7 +2,7 @@
|
||||
<groupId>com.songoda</groupId>
|
||||
<artifactId>EpicFurnaces</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>4.7.1</version>
|
||||
<version>4.7.2</version>
|
||||
<build>
|
||||
<defaultGoal>clean install</defaultGoal>
|
||||
<finalName>EpicFurnaces-${project.version}</finalName>
|
||||
@ -41,7 +41,7 @@
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.1.0</version>
|
||||
<version>3.3.0-SNAPSHOT</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>shaded</id>
|
||||
@ -79,6 +79,12 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>apache.snapshots</id>
|
||||
<url>https://repository.apache.org/snapshots/</url>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
@ -89,7 +95,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.16.1</version>
|
||||
<version>1.17</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.songoda</groupId>
|
||||
|
@ -56,6 +56,8 @@ import org.bukkit.plugin.PluginManager;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
@ -247,14 +249,6 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public void onDataLoad() {
|
||||
// Register Hologram Plugin
|
||||
|
||||
if (Settings.HOLOGRAMS.getBoolean()) {
|
||||
for (Furnace furnace : getFurnaceManager().getFurnaces().values()) {
|
||||
if (furnace.getLocation() == null || furnace.getLocation().getWorld() == null)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -267,33 +261,39 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
@Override
|
||||
public List<Config> getExtraConfig() {
|
||||
return Arrays.asList(levelsFile);
|
||||
return Collections.singletonList(levelsFile);
|
||||
}
|
||||
|
||||
public void clearHologram(Furnace furnace) {
|
||||
HologramManager.removeHologram(furnace.getLocation().add(0, .15, 0));
|
||||
}
|
||||
|
||||
public void updateHologram(Furnace furnace) {
|
||||
public void updateHolograms(Collection<Furnace> furnaces) {
|
||||
// are holograms enabled?
|
||||
if (!Settings.HOLOGRAMS.getBoolean() || !HologramManager.getManager().isEnabled()) return;
|
||||
|
||||
Map<Location, List<String>> holograms = new HashMap<>(furnaces.size());
|
||||
|
||||
for (Furnace furnace : furnaces) {
|
||||
// don't try to load furnaces in chunks that aren't loaded
|
||||
if (!furnace.isInLoadedChunk()) return;
|
||||
if (!furnace.isInLoadedChunk()) continue;
|
||||
|
||||
BlockState state = furnace.getLocation().getBlock().getState();
|
||||
|
||||
// verify that this is a furnace
|
||||
if (!(state instanceof org.bukkit.block.Furnace)) return;
|
||||
if (!(state instanceof org.bukkit.block.Furnace)) continue;
|
||||
|
||||
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) state);
|
||||
|
||||
int performance = (furnaceBlock.getCookTime() - furnace.getPerformanceTotal(furnaceBlock.getType())) <= 0 ? 0 : furnace.getPerformanceTotal(furnaceBlock.getType());
|
||||
|
||||
float percent = (float) (furnaceBlock.getCookTime() - performance) / (200 - performance);
|
||||
|
||||
int progressBars = (int) (6 * percent) + (percent == 0 ? 0 : 1);
|
||||
int leftOver = (6 - progressBars);
|
||||
|
||||
String progress;
|
||||
|
||||
if (furnaceBlock.getInventory().getFuel() != null) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < progressBars; i++) {
|
||||
sb.append("&a=");
|
||||
@ -302,11 +302,8 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
sb.append("&c=");
|
||||
}
|
||||
|
||||
ArrayList<String> lines = new ArrayList<>();
|
||||
|
||||
String progress = Methods.formatText(sb.toString());
|
||||
|
||||
if (furnaceBlock.getInventory().getFuel() == null) {
|
||||
progress = Methods.formatText(sb.toString());
|
||||
} else {
|
||||
progress = getLocale().getMessage("general.hologram.outoffuel").getMessage();
|
||||
}
|
||||
|
||||
@ -323,11 +320,11 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
.processPlaceholder("in", inAmt)
|
||||
.processPlaceholder("out", Math.min(outAmt, 64)).getMessage();
|
||||
|
||||
lines.add(progress);
|
||||
lines.add(stats);
|
||||
holograms.put(furnace.getLocation().add(0, .15, 0), Arrays.asList(progress, stats));
|
||||
}
|
||||
|
||||
// create the hologram
|
||||
HologramManager.updateHologram(furnace.getLocation().add(0, .15, 0), lines);
|
||||
// Update holograms
|
||||
HologramManager.bulkUpdateHolograms(holograms);
|
||||
}
|
||||
|
||||
private void loadLevelManager() {
|
||||
@ -424,7 +421,7 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
// Legacy trash.
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
String[] arr = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[0]);
|
||||
} else {
|
||||
return 1;
|
||||
@ -440,7 +437,7 @@ public class EpicFurnaces extends SongodaPlugin {
|
||||
|
||||
// Legacy trash.
|
||||
if (item.getItemMeta().getDisplayName().contains(":")) {
|
||||
String arr[] = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
String[] arr = (item.getItemMeta().getDisplayName().replace("§", "")).split(":");
|
||||
return Integer.parseInt(arr[1]);
|
||||
} else {
|
||||
return 0;
|
||||
|
@ -4,6 +4,7 @@ import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.compatibility.ServerVersion;
|
||||
import com.songoda.core.gui.GuiManager;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.math.MathUtils;
|
||||
import com.songoda.core.hooks.ProtectionManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.boost.BoostData;
|
||||
@ -25,9 +26,6 @@ import org.bukkit.event.inventory.FurnaceSmeltEvent;
|
||||
import org.bukkit.inventory.FurnaceInventory;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
|
||||
import javax.script.ScriptEngine;
|
||||
import javax.script.ScriptEngineManager;
|
||||
import javax.script.ScriptException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@ -56,7 +54,6 @@ public class Furnace {
|
||||
private final List<Location> radiusOverheat = new ArrayList<>();
|
||||
private final List<Location> radiusFuelshare = new ArrayList<>();
|
||||
private final List<UUID> accessList = new ArrayList<>();
|
||||
private final Map<String, Integer> cache = new HashMap<>();
|
||||
|
||||
public Furnace(Location location) {
|
||||
this.location = location;
|
||||
@ -244,20 +241,7 @@ public class Furnace {
|
||||
public int getPerformanceTotal(Material material) {
|
||||
String cap = (material.name().contains("BLAST") || material.name().contains("SMOKER") ? "100" : "200");
|
||||
String equation = "(" + level.getPerformance() + " / 100) * " + cap;
|
||||
try {
|
||||
if (!cache.containsKey(equation)) {
|
||||
ScriptEngineManager mgr = new ScriptEngineManager(null);
|
||||
ScriptEngine engine = mgr.getEngineByName("JavaScript");
|
||||
int num = (int) Math.round(Double.parseDouble(engine.eval("(" + level.getPerformance() + " / 100) * " + cap).toString()));
|
||||
cache.put(equation, num);
|
||||
return num;
|
||||
} else {
|
||||
return cache.get(equation);
|
||||
}
|
||||
} catch (ScriptException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return 0;
|
||||
return (int) MathUtils.eval(equation);
|
||||
}
|
||||
|
||||
public boolean addToAccessList(OfflinePlayer player) {
|
||||
|
@ -2,7 +2,6 @@ package com.songoda.epicfurnaces.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.CustomizableGui;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.core.input.ChatPrompt;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
|
@ -16,7 +16,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
@ -16,6 +16,7 @@ import org.bukkit.event.block.BlockFormEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -46,7 +47,6 @@ public class BlockListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
@ -74,7 +74,7 @@ public class BlockListeners implements Listener {
|
||||
plugin.getFurnaceManager().addFurnace(furnace);
|
||||
plugin.getDataManager().createFurnace(furnace);
|
||||
|
||||
plugin.updateHologram(furnace);
|
||||
plugin.updateHolograms(Collections.singleton(furnace));
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||
|
@ -36,7 +36,6 @@ public class InventoryListeners implements Listener {
|
||||
furnace.updateCook();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@EventHandler
|
||||
public void onInventoryClick(InventoryClickEvent event) {
|
||||
if (event.getSlot() != 64537) {
|
||||
|
@ -5,11 +5,8 @@ import com.songoda.core.configuration.Config;
|
||||
import com.songoda.core.configuration.ConfigSetting;
|
||||
import com.songoda.core.hooks.EconomyManager;
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.core.hooks.ProtectionManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class Settings {
|
||||
|
||||
static final Config config = EpicFurnaces.getInstance().getCoreConfig();
|
||||
@ -44,8 +41,7 @@ public class Settings {
|
||||
public static final ConfigSetting HOLOGRAM_PLUGIN = new ConfigSetting(config, "Main.Hologram",
|
||||
HologramManager.getHolograms() == null ? "HolographicDisplays" : HologramManager.getHolograms().getName(),
|
||||
"Which hologram plugin should be used?",
|
||||
"You can choose from \"" + HologramManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining(", ")) + "\".");
|
||||
|
||||
"You can choose from \"" + String.join(", ", HologramManager.getManager().getRegisteredPlugins()) + "\".");
|
||||
|
||||
public static final ConfigSetting HOLOGRAMS = new ConfigSetting(config, "Main.Furnaces Have Holograms", true);
|
||||
|
||||
@ -68,7 +64,7 @@ public class Settings {
|
||||
|
||||
public static final ConfigSetting ECONOMY_PLUGIN = new ConfigSetting(config, "Main.Economy", EconomyManager.getEconomy() == null ? "Vault" : EconomyManager.getEconomy().getName(),
|
||||
"Which economy plugin should be used?",
|
||||
"Supported plugins you have installed: \"" + EconomyManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining("\", \"")) + "\".");
|
||||
"Supported plugins you have installed: \"" + String.join("\", \"", EconomyManager.getManager().getRegisteredPlugins()) + "\".");
|
||||
|
||||
public static final ConfigSetting REWARD_ICON = new ConfigSetting(config, "Interfaces.Reward Icon", "GOLDEN_APPLE");
|
||||
public static final ConfigSetting PERFORMANCE_ICON = new ConfigSetting(config, "Interfaces.Performance Icon", "REDSTONE");
|
||||
|
@ -19,7 +19,7 @@ public class FurnaceTask extends BukkitRunnable {
|
||||
private static FurnaceTask instance;
|
||||
|
||||
private final EpicFurnaces plugin;
|
||||
final HashSet<Location> toRemove = new HashSet();
|
||||
final HashSet<Location> toRemove = new HashSet<>();
|
||||
boolean doParticles;
|
||||
|
||||
private FurnaceTask(EpicFurnaces plugin) {
|
||||
@ -56,7 +56,7 @@ public class FurnaceTask extends BukkitRunnable {
|
||||
}
|
||||
});
|
||||
if (!toRemove.isEmpty()) {
|
||||
toRemove.stream().forEach(l -> plugin.getFurnaceManager().removeFurnace(l));
|
||||
toRemove.forEach(l -> plugin.getFurnaceManager().removeFurnace(l));
|
||||
toRemove.clear();
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.songoda.epicfurnaces.tasks;
|
||||
|
||||
import com.songoda.core.hooks.HologramManager;
|
||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||
import com.songoda.epicfurnaces.furnace.Furnace;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class HologramTask extends BukkitRunnable {
|
||||
@ -28,8 +27,6 @@ public class HologramTask extends BukkitRunnable {
|
||||
public void run() {
|
||||
if (!HologramManager.getManager().isEnabled()) return;
|
||||
|
||||
for (Furnace furnace : plugin.getFurnaceManager().getFurnaces().values()) {
|
||||
plugin.updateHologram(furnace);
|
||||
}
|
||||
plugin.updateHolograms(plugin.getFurnaceManager().getFurnaces().values());
|
||||
}
|
||||
}
|
@ -6,7 +6,6 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.Arrays;
|
||||
@ -52,7 +51,8 @@ public class Methods {
|
||||
str = str.replace(".0", "").replace("/", "");
|
||||
return str;
|
||||
}
|
||||
private static Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
private static final Map<String, Location> serializeCache = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Deserializes a location from the string.
|
||||
|
Loading…
Reference in New Issue
Block a user