Merge branch 'development'

This commit is contained in:
Brianna 2021-06-12 21:59:22 -05:00
commit 874e6d193e
9 changed files with 42 additions and 8 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>EpicFurnaces</artifactId>
<modelVersion>4.0.0</modelVersion>
<version>4.7.1</version>
<version>4.7</version>
<build>
<defaultGoal>clean install</defaultGoal>
<finalName>EpicFurnaces-${project.version}</finalName>

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

@ -138,7 +138,7 @@ public class Furnace {
BoostData boostData = plugin.getBoostManager().getBoost(placedBy);
randomAmount = randomAmount * (boostData == null ? 1 : boostData.getMultiplier());
event.getResult().setAmount(event.getResult().getAmount() + randomAmount);
event.getResult().setAmount(Math.min(event.getResult().getAmount() + randomAmount, event.getResult().getMaxStackSize()));
}
public void upgrade(Player player, CostType type) {

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;
@ -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);
}
}

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.");