Added "Allow Normal Furnaces" option.

This commit is contained in:
Fernando Pettinelli 2021-02-25 14:18:11 -03:00 committed by Brianna
parent 402362c32b
commit 1b69e4c648
7 changed files with 40 additions and 6 deletions

View File

@ -391,6 +391,13 @@ public class EpicFurnaces extends SongodaPlugin {
}
}
public boolean isLeveledFurnace(ItemStack itemStack) {
NBTCore nbt = NmsManager.getNbt();
NBTItem nbtItem = nbt.of(itemStack);
return nbtItem.has("level") && nbtItem.has("uses");
}
public ItemStack createLeveledFurnace(Material material, int level, int uses) {
ItemStack item = new ItemStack(material, 1);

View File

@ -2,6 +2,7 @@ package com.songoda.epicfurnaces.furnace;
import com.google.common.collect.Multimap;
import com.google.common.collect.MultimapBuilder;
import com.songoda.epicfurnaces.settings.Settings;
import com.songoda.epicfurnaces.utils.GameArea;
import org.bukkit.Location;
import org.bukkit.block.Block;
@ -36,7 +37,7 @@ public class FurnaceManager {
}
public Furnace getFurnace(Location location) {
if (!registeredFurnaces.containsKey(location)) {
if (!Settings.ALLOW_NORMAL_FURNACES.getBoolean() && !registeredFurnaces.containsKey(location)) {
addFurnace(new FurnaceBuilder(location).build());
}
return registeredFurnaces.get(location);

View File

@ -3,6 +3,7 @@ package com.songoda.epicfurnaces.listeners;
import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.furnace.Furnace;
import com.songoda.epicfurnaces.furnace.FurnaceBuilder;
import com.songoda.epicfurnaces.settings.Settings;
import com.songoda.epicfurnaces.utils.GameArea;
import org.bukkit.Location;
import org.bukkit.Material;
@ -57,6 +58,10 @@ public class BlockListeners implements Listener {
ItemStack item = event.getItemInHand();
if (!plugin.isLeveledFurnace(item) && Settings.ALLOW_NORMAL_FURNACES.getBoolean()) {
return;
}
Location location = event.getBlock().getLocation();
Furnace furnace = event.getItemInHand().getItemMeta().hasDisplayName() && plugin.getFurnaceLevel(item) != 1
@ -83,6 +88,11 @@ public class BlockListeners implements Listener {
return;
Furnace furnace = plugin.getFurnaceManager().getFurnace(block);
if (furnace == null) {
return;
}
int level = plugin.getFurnaceManager().getFurnace(block).getLevel().getLevel();
plugin.clearHologram(furnace);

View File

@ -36,8 +36,11 @@ public class FurnaceListeners implements Listener {
@EventHandler
public void onFuel(FurnaceBurnEvent event) {
Furnace furnace = plugin.getFurnaceManager().getFurnace(event.getBlock().getLocation());
if (furnace == null) {
return;
}
Level level = furnace != null ? furnace.getLevel() : plugin.getLevelManager().getLowestLevel();
Level level = furnace.getLevel();
if (level.getFuelDuration() != 0) return;

View File

@ -2,6 +2,7 @@ package com.songoda.epicfurnaces.listeners;
import com.songoda.core.gui.GuiManager;
import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.furnace.Furnace;
import com.songoda.skyblock.SkyBlock;
import org.bukkit.Bukkit;
import org.bukkit.block.Block;
@ -53,8 +54,13 @@ public class InteractListeners implements Listener {
}
Furnace furnace = plugin.getFurnaceManager().getFurnace(block.getLocation());
if (furnace == null) {
return;
}
event.setCancelled(true);
plugin.getFurnaceManager().getFurnace(block.getLocation()).overview(guiManager, player);
furnace.overview(guiManager, player);
}
}

View File

@ -1,6 +1,7 @@
package com.songoda.epicfurnaces.listeners;
import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.furnace.Furnace;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -29,8 +30,10 @@ public class InventoryListeners implements Listener {
|| event.getDestination().getItem(0).getAmount() != 1) {
return;
}
plugin.getFurnaceManager().getFurnace(((org.bukkit.block.Furnace)
event.getDestination().getHolder()).getLocation()).updateCook();
Furnace furnace = plugin.getFurnaceManager().getFurnace(((org.bukkit.block.Furnace)
event.getDestination().getHolder()).getLocation());
if (furnace != null)
furnace.updateCook();
}
@SuppressWarnings("unchecked")

View File

@ -54,6 +54,10 @@ public class Settings {
public static final ConfigSetting CUSTOM_RECIPES = new ConfigSetting(config, "Main.Use Custom Recipes", true);
public static final ConfigSetting NO_REWARDS_FROM_RECIPES = new ConfigSetting(config, "Main.No Rewards From Custom Recipes", true);
public static final ConfigSetting ALLOW_NORMAL_FURNACES = new ConfigSetting(config, "Main.Allow Normal Furnaces", false,
"Should normal furnaces not be converted into",
"Epic Furnaces?");
public static final ConfigSetting PARTICLE_TYPE = new ConfigSetting(config, "Main.Upgrade Particle Type", "SPELL_WITCH",
"The type of particle shown when a furnace is upgraded.");