Compare commits

...

5 Commits

Author SHA1 Message Date
Brianna OKeefe 4aab730dc1 Version 5.1.1 2024-03-11 13:44:46 -05:00
Brianna OKeefe 29b79b3d56 Improved consistency in language. 2024-03-11 13:37:48 -05:00
Brianna OKeefe 70090596f3 Incorrect condition 2024-03-11 13:32:39 -05:00
Brianna OKeefe 37e838b513 More improvements to "plus" logic 2024-03-11 12:52:57 -05:00
Brianna OKeefe 6caafe5892 Reorganized furnace level logic & General Cleanup. 2024-03-11 12:13:35 -05:00
11 changed files with 86 additions and 92 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.craftaro</groupId>
<artifactId>EpicFurnaces</artifactId>
<version>5.1.0</version>
<version>5.1.1</version>
<name>EpicFurnaces</name>
<description>EpicFurnaces allows you to upgrade basic Minecraft features to make the game way more entertaining</description>

View File

@ -25,7 +25,7 @@ import com.craftaro.epicfurnaces.database.migrations._1_InitialMigration;
import com.craftaro.epicfurnaces.furnace.Furnace;
import com.craftaro.epicfurnaces.furnace.FurnaceBuilder;
import com.craftaro.epicfurnaces.furnace.FurnaceManager;
import com.craftaro.epicfurnaces.furnace.levels.LevelManager;
import com.craftaro.epicfurnaces.level.LevelManager;
import com.craftaro.epicfurnaces.handlers.BlacklistHandler;
import com.craftaro.epicfurnaces.listeners.BlockListeners;
import com.craftaro.epicfurnaces.listeners.EntityListeners;

View File

@ -1,7 +1,7 @@
package com.craftaro.epicfurnaces.commands;
import com.craftaro.core.commands.AbstractCommand;
import com.craftaro.epicfurnaces.furnace.levels.Level;
import com.craftaro.epicfurnaces.level.Level;
import com.craftaro.epicfurnaces.EpicFurnaces;
import org.bukkit.Bukkit;
import org.bukkit.Material;

View File

@ -11,7 +11,7 @@ import com.craftaro.core.math.MathUtils;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.third_party.com.cryptomorin.xseries.XSound;
import com.craftaro.epicfurnaces.EpicFurnaces;
import com.craftaro.epicfurnaces.furnace.levels.Level;
import com.craftaro.epicfurnaces.level.Level;
import com.craftaro.epicfurnaces.settings.Settings;
import com.craftaro.epicfurnaces.boost.BoostData;
import com.craftaro.epicfurnaces.gui.GUIOverview;
@ -103,38 +103,20 @@ public class Furnace implements Data {
return;
}
this.uses++;
this.plugin.getDataHelper().queueFurnaceForUpdate(this);
uses++;
plugin.getDataHelper().queueFurnaceForUpdate(this);
XMaterial material = CompatibleMaterial.getMaterial(event.getResult().getType()).get();
int needed = -1;
if (this.level.getMaterials().containsKey(material)) {
if (level.getMaterials().containsKey(material)) {
int amount = addToLevel(material, 1);
this.plugin.getDataHelper().updateLevelupItems(this, material, amount);
needed = this.level.getMaterials().get(material) - getToLevel(material);
plugin.getDataHelper().updateLevelupItems(this, material, amount);
needed = level.getMaterials().get(material) - getToLevel(material);
}
if (this.level.getReward() == null) {
if (!level.hasReward())
return;
}
String reward = this.level.getReward();
int min = 1;
int max = 1;
if (reward.contains(":")) {
String[] rewardSplit = reward.split(":");
reward = rewardSplit[0].substring(0, rewardSplit[0].length() - 1);
if (rewardSplit[1].contains("-")) {
String[] split = rewardSplit[1].split("-");
min = Integer.parseInt(split[0]);
max = Integer.parseInt(split[1]);
} else {
min = Integer.parseInt(rewardSplit[1]);
max = min;
}
}
if (Settings.UPGRADE_BY_SMELTING.getBoolean() &&
needed == 0 &&
@ -143,7 +125,7 @@ public class Furnace implements Data {
levelUp();
}
this.updateCook();
updateCook();
FurnaceInventory inventory = (FurnaceInventory) ((InventoryHolder) block.getState()).getInventory();
@ -153,16 +135,16 @@ public class Furnace implements Data {
return;
}
int num = Integer.parseInt(reward);
int percent = level.getRewardPercent();
double rand = Math.random() * 100;
if (rand >= num
if (rand >= percent
|| event.getResult().equals(Material.SPONGE)
|| Settings.NO_REWARDS_FROM_RECIPES.getBoolean()
&& this.plugin.getFurnaceRecipeFile().contains("Recipes." + inventory.getSmelting().getType())) {
return;
}
int randomAmount = min == max ? min : (int) (Math.random() * ((max - min) + 1)) + min;
int randomAmount = level.getRandomReward();
BoostData boostData = this.plugin.getBoostManager().getBoost(this.placedBy);
randomAmount = randomAmount * (boostData == null ? 1 : boostData.getMultiplier());

View File

@ -1,7 +1,7 @@
package com.craftaro.epicfurnaces.furnace;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.epicfurnaces.furnace.levels.Level;
import com.craftaro.epicfurnaces.level.Level;
import org.bukkit.Location;
import java.util.List;

View File

@ -11,7 +11,7 @@ import com.craftaro.core.utils.TimeUtils;
import com.craftaro.epicfurnaces.EpicFurnaces;
import com.craftaro.epicfurnaces.boost.BoostData;
import com.craftaro.epicfurnaces.furnace.Furnace;
import com.craftaro.epicfurnaces.furnace.levels.Level;
import com.craftaro.epicfurnaces.level.Level;
import com.craftaro.epicfurnaces.settings.Settings;
import com.craftaro.epicfurnaces.utils.CostType;
import com.craftaro.epicfurnaces.utils.Methods;
@ -73,21 +73,16 @@ public class GUIOverview extends CustomizableGui {
// check how many info icons we have to show
int num = -1;
if (level.getPerformance() != 0) {
if (level.getPerformance() != 0)
num++;
}
if (level.getReward() != null) {
if (level.hasReward())
num++;
}
if (level.getFuelDuration() != 0) {
if (level.getFuelDuration() != 0)
num++;
}
if (level.getFuelShare() != 0) {
if (level.getFuelShare() != 0)
num++;
}
if (level.getOverheat() != 0) {
if (level.getOverheat() != 0)
num++;
}
int current = 0;
@ -98,12 +93,12 @@ public class GUIOverview extends CustomizableGui {
this.plugin.getLocale().getMessage("interface.furnace.performanceinfo")
.processPlaceholder("amount", level.getPerformance()).getMessage().split("\\|")));
}
if (level.getReward() != null) {
if (level.hasReward()) {
setItem("reward", infoIconOrder[num][current++], GuiUtils.createButtonItem(
Settings.REWARD_ICON.getMaterial(XMaterial.GOLDEN_APPLE),
this.plugin.getLocale().getMessage("interface.furnace.rewardtitle").getMessage(),
this.plugin.getLocale().getMessage("interface.furnace.rewardinfo")
.processPlaceholder("amount", level.getReward().split(":")[0].replace("%", ""))
.processPlaceholder("amount", level.getRewardPercent())
.getMessage().split("\\|")));
}
if (level.getFuelDuration() != 0) {

View File

@ -1,4 +1,4 @@
package com.craftaro.epicfurnaces.furnace.levels;
package com.craftaro.epicfurnaces.level;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;
import com.craftaro.epicfurnaces.EpicFurnaces;
@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
public class Level {
private final int level;
private final int costExperience;
private final int costEconomy;
@ -19,7 +20,9 @@ public class Level {
private Map<XMaterial, Integer> materials;
private final String reward;
private final String rewardRaw;
private int rewardPercentage = 100;
private int rewardMin = 1, rewardMax = 1;
private final List<String> description = new ArrayList<>();
@ -28,7 +31,6 @@ public class Level {
this.costExperience = costExperience;
this.costEconomy = costEconomy;
this.performance = performance;
this.reward = reward;
this.fuelDuration = fuelDuration;
this.overheat = overheat;
this.fuelShare = fuelShare;
@ -70,6 +72,25 @@ public class Level {
.processPlaceholder("amount", overheat)
.getMessage());
}
rewardRaw = reward;
if (reward == null)
return;
if (reward.contains(":")) { // Optionally this can be multiple values.
String[] rewardSplit = reward.split(":");
rewardPercentage = Integer.parseInt(rewardSplit[0].substring(0, rewardSplit[0].length() - 1));
if (rewardSplit[1].contains("-")) {
String[] split = rewardSplit[1].split("-");
rewardMin = Integer.parseInt(split[0]);
rewardMax = Integer.parseInt(split[1]);
} else {
rewardMin = Integer.parseInt(rewardSplit[1]);
rewardMax = rewardMin;
}
} else {
rewardPercentage = Integer.parseInt(reward.substring(0, reward.length() - 1));
}
}
@ -88,11 +109,6 @@ public class Level {
}
public String getReward() {
return this.reward;
}
public int getOverheat() {
return this.overheat;
}
@ -120,4 +136,16 @@ public class Level {
public Map<XMaterial, Integer> getMaterials() {
return Collections.unmodifiableMap(this.materials);
}
public int getRandomReward() {
return rewardMin == rewardMax ? rewardMin : (int) (Math.random() * ((rewardMax - rewardMin) + 1)) + rewardMin;
}
public boolean hasReward() {
return rewardRaw != null;
}
public int getRewardPercent() {
return rewardPercentage;
}
}

View File

@ -1,4 +1,4 @@
package com.craftaro.epicfurnaces.furnace.levels;
package com.craftaro.epicfurnaces.level;
import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial;

View File

@ -2,7 +2,8 @@ package com.craftaro.epicfurnaces.listeners;
import com.craftaro.epicfurnaces.EpicFurnaces;
import com.craftaro.epicfurnaces.furnace.Furnace;
import com.craftaro.epicfurnaces.furnace.levels.Level;
import com.craftaro.epicfurnaces.level.Level;
import com.craftaro.epicfurnaces.settings.Settings;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -19,32 +20,29 @@ public class FurnaceListeners implements Listener {
@EventHandler
public void onCook(FurnaceSmeltEvent event) {
Block block = event.getBlock();
if ((event.getBlock().isBlockPowered() && this.plugin.getConfig().getBoolean("Main.Redstone Deactivates Furnaces")) || event.getResult() == null) {
if (event.getBlock().isBlockPowered() && Settings.REDSTONE_DEACTIVATES.getBoolean()) {
event.setCancelled(true);
return;
}
Furnace furnace = this.plugin.getFurnaceManager().getFurnace(block.getLocation());
if (furnace != null) {
if (furnace != null)
furnace.plus(event);
}
}
@EventHandler
public void onFuel(FurnaceBurnEvent event) {
Furnace furnace = this.plugin.getFurnaceManager().getFurnace(event.getBlock().getLocation());
if (furnace == null) {
if (furnace == null)
return;
}
Level level = furnace.getLevel();
if (level.getFuelDuration() != 0) {
if (level.getFuelDuration() == 0)
return;
}
int num = level.getFuelDuration();
int per = (event.getBurnTime() / 100) * num;
event.setBurnTime(event.getBurnTime() + per);
int percent = (event.getBurnTime() / 100) * level.getFuelDuration();
event.setBurnTime(event.getBurnTime() + percent);
}
}

View File

@ -18,20 +18,18 @@ public class FurnaceTask extends BukkitRunnable {
private static FurnaceTask instance;
private final EpicFurnaces plugin;
final HashSet<Location> toRemove = new HashSet<>();
boolean doParticles;
private final HashSet<Location> toRemove = new HashSet<>();
private boolean doParticles;
private FurnaceTask(EpicFurnaces plugin) {
this.plugin = plugin;
}
public static FurnaceTask startTask(EpicFurnaces plugin) {
public static void startTask(EpicFurnaces plugin) {
if (instance == null) {
instance = new FurnaceTask(plugin);
instance.runTaskTimer(plugin, 0, Settings.TICK_SPEED.getInt());
}
return instance;
}
@Override
@ -50,7 +48,7 @@ public class FurnaceTask extends BukkitRunnable {
overheat(furnace);
}
if (furnace.getLevel().getFuelShare() != 0) {
fuelshare(furnace);
fuelShare(furnace);
}
}
});
@ -68,14 +66,12 @@ public class FurnaceTask extends BukkitRunnable {
for (Location location : furnace.getRadius(true)) {
int random = ThreadLocalRandom.current().nextInt(0, 10);
if (random != 1) {
if (random != 1)
continue;
}
Block block = location.getBlock();
if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR) {
if (block.getType() == Material.AIR || block.getRelative(BlockFace.UP).getType() != Material.AIR)
continue;
}
if (block.getType() == Material.SNOW) {
block.setType(Material.AIR);
@ -94,7 +90,7 @@ public class FurnaceTask extends BukkitRunnable {
}
}
private void fuelshare(Furnace furnace) {
private void fuelShare(Furnace furnace) {
if (furnace.getRadius(false) == null || furnace.getRadiusLast(false) != furnace.getLevel().getOverheat()) {
furnace.setRadiusLast(furnace.getLevel().getOverheat(), false);
cache(furnace, false);
@ -103,19 +99,17 @@ public class FurnaceTask extends BukkitRunnable {
for (Location location : furnace.getRadius(false)) {
int random = ThreadLocalRandom.current().nextInt(0, 10);
if (random != 1) {
if (random != 1)
continue;
}
Block block = location.getBlock();
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) {
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER"))
continue;
}
Furnace furnace1 = this.plugin.getFurnaceManager().getFurnace(block);
if (furnace == furnace1) {
if (furnace == furnace1)
continue;
}
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) block.getState());
if (furnaceBlock.getBurnTime() == 0) {
furnaceBlock.setBurnTime((short) 100);
@ -140,15 +134,12 @@ public class FurnaceTask extends BukkitRunnable {
int by = block.getY();
int bz = block.getZ();
for (int fx = -radius; fx <= radius; fx++) {
for (int fy = -2; fy <= 1; fy++) {
for (int fz = -radius; fz <= radius; fz++) {
for (int fx = -radius; fx <= radius; fx++)
for (int fy = -2; fy <= 1; fy++)
for (int fz = -radius; fz <= radius; fz++)
if ((fx * fx) + (fz * fz) <= rSquared) {
Location location = new Location(block.getWorld(), bx + fx, by + fy, bz + fz);
furnace.addToRadius(location, overheat);
}
}
}
}
}
}

View File

@ -27,16 +27,16 @@ interface:
rewardtitle: '&c&lReward'
fueldurationtitle: '&7&lFuel Duration'
fuelduration: '&7Fuel Duration: &6%amount%'
fuelshare: '&7Fuel Share: &6%amount%&7.'
fuelshare: '&7Fuel Share: &6%amount%&7'
fuelsharetitle: '&6&lFuel Share'
fuelshareinfo: '&7This furnace will power other|&7furnaces within a &6%amount%&7 block radius.'
overheat: '&7Overheat: &6%amount%&7.'
overheat: '&7Overheat: &6%amount%&7'
overheattitle: '&6&lOverheat'
overheatinfo: '&7This furnace will melt snow |&7and ice within a &6%amount%&7 block radius.'
performanceinfo: '&7This furnaces performance is |&7currently boosted an extra &6%amount%%&7. | |&7Performance boosts the speed in |&7which a furnace processes |&7materials.'
rewardinfo: '&7This furnace currently |&7has a &6%amount%%&7 chance of |&7producing multiple resources.'
fueldurationinfo: '&7This furnaces fuel duration is |&7currently boosted by &6%amount%%&7. | |&7Fuel Duration boosts how long |&7fuel in the furnace lasts.'
smeltedx: '&7Smelted &6%amount% Materials&7.'
smeltedx: '&7Smelted &6%amount% Materials&7'
itemsneeded: '&7You need one of the following to level up:'
neededitem: '&6%amount% %type%s'
remotefurnace: '&5&lRemote Control'