mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2024-11-27 20:35:24 +01:00
Added "Allow Normal Furnaces" option.
This commit is contained in:
parent
402362c32b
commit
1b69e4c648
@ -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);
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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;
|
||||
@ -52,9 +53,14 @@ public class InteractListeners implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
@ -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")
|
||||
|
@ -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.");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user