Merge branch 'development'

This commit is contained in:
Brianna 2019-11-09 12:32:29 -05:00
commit 5f882f4cb4
7 changed files with 124 additions and 112 deletions

View File

@ -4,7 +4,7 @@ stages:
variables:
name: "EpicFurnaces"
path: "/builds/$CI_PROJECT_PATH"
version: "4.5.2"
version: "4.5.3"
build:
stage: build

View File

@ -167,7 +167,7 @@ public class EpicFurnaces extends SongodaPlugin {
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) state);
int performance = (furnaceBlock.getCookTime() - furnace.getPerformanceTotal()) <= 0 ? 0 : furnace.getPerformanceTotal();
int performance = (furnaceBlock.getCookTime() - furnace.getPerformanceTotal(furnaceBlock.getType())) <= 0 ? 0 : furnace.getPerformanceTotal(furnaceBlock.getType());
float percent = (float) (furnaceBlock.getCookTime() - performance) / (200 - performance);

View File

@ -6,84 +6,80 @@ import com.songoda.epicfurnaces.boost.BoostData;
import com.songoda.epicfurnaces.utils.Methods;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.Calendar;
import java.util.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class CommandBoost extends AbstractCommand {
final EpicFurnaces plugin;
final EpicFurnaces instance;
public CommandBoost(EpicFurnaces plugin) {
public CommandBoost(EpicFurnaces instance) {
super(false, "boost");
this.plugin = plugin;
this.instance = instance;
}
@Override
protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length < 2) {
instance.getLocale().newMessage("&7Syntax error...").sendPrefixedMessage(sender);
return ReturnType.SYNTAX_ERROR;
}
if (Bukkit.getPlayer(args[0]) == null) {
plugin.getLocale().newMessage("&cThat player does not exist...").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
} else if (!Methods.isInt(args[1])) {
plugin.getLocale().newMessage("&6" + args[1] + " &7is not a number...").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
} else {
Calendar c = Calendar.getInstance();
Date currentDate = new Date();
c.setTime(currentDate);
String time = "&7.";
if (args.length > 2) {
if (args[2].contains("m:")) {
String[] arr2 = (args[2]).split(":");
c.add(Calendar.MINUTE, Integer.parseInt(arr2[0]));
time = " &7for &6" + arr2[0] + " minutes&7.";
} else if (args[2].contains("h:")) {
String[] arr2 = (args[2]).split(":");
c.add(Calendar.HOUR, Integer.parseInt(arr2[0]));
time = " &7for &6" + arr2[0] + " hours&7.";
} else if (args[2].contains("d:")) {
String[] arr2 = (args[2]).split(":");
c.add(Calendar.HOUR, Integer.parseInt(arr2[0]) * 24);
time = " &7for &6" + arr2[0] + " days&7.";
} else if (args[2].contains("y:")) {
String[] arr2 = (args[2]).split(":");
c.add(Calendar.YEAR, Integer.parseInt(arr2[0]));
time = " &7for &6" + arr2[0] + " years&7.";
} else {
plugin.getLocale().newMessage("&7" + args[2] + " &7is invalid.").sendPrefixedMessage(sender);
return ReturnType.SUCCESS;
}
} else {
c.add(Calendar.YEAR, 10);
}
BoostData boostData = new BoostData(Integer.parseInt(args[2]), c.getTime().getTime(), Bukkit.getPlayer(args[0]).getUniqueId());
plugin.getBoostManager().addBoostToPlayer(boostData);
plugin.getLocale().newMessage("&7Successfully boosted &6" + Bukkit.getPlayer(args[0]).getName()
+ "'s &7furnaces reward amounts by &6" + args[2] + "x" + time).sendPrefixedMessage(sender);
if (!Methods.isInt(args[1])) {
instance.getLocale().newMessage("&6" + args[1] + " &7is not a number...").sendPrefixedMessage(sender);
return ReturnType.SYNTAX_ERROR;
}
return ReturnType.FAILURE;
long duration = 0L;
if (args.length > 2) {
for (int i = 0; i < args.length; i++) {
String line = args[i];
long time = Methods.parseTime(line);
duration += time;
}
}
Player player = Bukkit.getPlayer(args[0]);
if (player == null) {
instance.getLocale().newMessage("&cThat player does not exist or is not online...").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
BoostData boostData = new BoostData(Integer.parseInt(args[1]), duration == 0L ? Long.MAX_VALUE : System.currentTimeMillis() + duration, player.getUniqueId());
instance.getBoostManager().addBoostToPlayer(boostData);
instance.getLocale().newMessage("&7Successfully boosted &6" + Bukkit.getPlayer(args[0]).getName()
+ "'s &7furnace reward amounts &6" + args[1] + "x" + (duration == 0L ? "" : (" for " + Methods.makeReadable(duration))) + "&7.").sendPrefixedMessage(sender);
return ReturnType.SUCCESS;
}
@Override
protected List<String> onTab(CommandSender commandSender, String... strings) {
protected List<String> onTab(CommandSender sender, String... args) {
if (args.length == 1) {
List<String> players = new ArrayList<>();
for (Player player : Bukkit.getOnlinePlayers()) {
players.add(player.getName());
}
return players;
} else if (args.length == 2) {
return Arrays.asList("1", "2", "3", "4", "5");
} else if (args.length == 3) {
return Arrays.asList("1m", "1h", "1d");
}
return null;
}
@Override
public String getPermissionNode() {
return "epicfurnaces.admin";
return "epicfurnaces.boost";
}
@Override
public String getSyntax() {
return "/ef boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]";
return "/ef boost <player> <amount> [duration]";
}
@Override

View File

@ -56,7 +56,9 @@ public class Furnace {
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) return;
this.uses++;
this.tolevel++;
if (Settings.UPGRADE_COST.getMaterial().matches(e.getResult()))
this.tolevel++;
int multi = Settings.LEVEL_MULTIPLIER.getInt();
@ -184,13 +186,14 @@ public class Furnace {
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) return;
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
int num = getPerformanceTotal();
int num = getPerformanceTotal(block.getType());
if (num > 200)
num = 200;
int max = (block.getType().name().contains("BLAST") || block.getType().name().contains("SMOKER") ? 100 : 200);
if (num >= max)
num = max - 1;
if (num != 0) {
BlockState bs = (block.getState()); // max is 200
BlockState bs = (block.getState());
((org.bukkit.block.Furnace) bs).setCookTime(Short.parseShort(Integer.toString(num)));
bs.update();
}
@ -218,13 +221,14 @@ public class Furnace {
}
public int getPerformanceTotal() {
String equation = "(" + level.getPerformance() + " / 100) * 200";
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();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
int num = (int) Math.round(Double.parseDouble(engine.eval("(" + level.getPerformance() + " / 100) * 200").toString()));
int num = (int) Math.round(Double.parseDouble(engine.eval("(" + level.getPerformance() + " / 100) * " + cap).toString()));
cache.put(equation, num);
return num;
} else {

View File

@ -11,7 +11,7 @@ import java.util.stream.Collectors;
public class Settings {
static final Config config = EpicFurnaces.getInstance().getConfig().getCoreConfig();
static final Config config = EpicFurnaces.getInstance().getCoreConfig();
public static final ConfigSetting UPGRADE_BY_SMELTING = new ConfigSetting(config, "Main.Upgrade By Smelting Materials", true);

View File

@ -1,6 +1,5 @@
package com.songoda.epicfurnaces.storage.types;
import com.songoda.core.configuration.Config;
import com.songoda.epicfurnaces.EpicFurnaces;
import com.songoda.epicfurnaces.storage.Storage;
import com.songoda.epicfurnaces.storage.StorageItem;
@ -109,7 +108,8 @@ public class StorageYaml extends Storage {
File data = new File(plugin.getDataFolder(), "data.yml");
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
try {
copyFile(data, dataClone);
if (data.exists())
copyFile(data, dataClone);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -1,55 +1,67 @@
#General Messages
# General Messages
general.nametag.prefix = "&8[&6EpicFurnaces&8]"
general.nametag.next = "&9Next"
general.nametag.back = "&9Back"
general.nametag.nameformat = "&eLevel %level% &fFurnace"
general.hologram.outoffuel = "&cNo Fuel"
general.hologram.stats = "&a%in%&7/&c%out%"
general:
nametag:
prefix: '&8[&6EpicFurnaces&8]'
next: '&9Next'
back: '&9Back'
nameformat: '&eLevel %level% &fFurnace'
hologram:
outoffuel: '&cNo Fuel'
stats: '&a%in%&7/&c%out%'
#Interface Messages
# Interface Messages
interface.furnace.upgradewithxp = "&aUpgrade with XP"
interface.furnace.upgradewithxplore = "&7Cost: &a%cost% Levels"
interface.furnace.upgradewitheconomy = "&aUpgrade with ECO"
interface.furnace.upgradewitheconomylore = "&7Cost: &a$%cost%"
interface.furnace.currentlevel = "&6Furnace Level &7%level%"
interface.furnace.level = "&6Next Level &7%level%"
interface.furnace.performance = "&7Performance: &6%amount%"
interface.furnace.reward = "&7Reward: &6%amount%"
interface.furnace.performancetitle = "&a&lPerformance"
interface.furnace.rewardtitle = "&c&lReward"
interface.furnace.fueldurationtitle = "&7&lFuel Duration"
interface.furnace.fuelduration = "&7Fuel Duration: &6%amount%"
interface.furnace.fuelshare = "&7Fuel Share: &6%amount%&7."
interface.furnace.fuelsharetitle = "&6&lFuel Share"
interface.furnace.fuelshareinfo = "&7This furnace will power other|&7furnaces within a &6%amount%&7 block radius."
interface.furnace.overheat = "&7Overheat: &6%amount%&7."
interface.furnace.overheattitle = "&6&lOverheat"
interface.furnace.overheatinfo = "&7This furnace will melt snow |&7and ice within a &6%amount%&7 block radius."
interface.furnace.performanceinfo = "&7This furnaces performance is |&7currently boosted an extra &6%amount%%&7. | |&7Performance boosts the speed in |&7which a furnace processes |&7materials."
interface.furnace.rewardinfo = "&7This furnace currently |&7has a &6%amount%%&7 chance of |&7producing multiple resources."
interface.furnace.fueldurationinfo = "&7This furnaces fuel duration is |&7currently boosted by &6%amount%%&7. | |&7Fuel Duration boosts how long |&7fuel in the furnace lasts."
interface.furnace.smeltedx = "&7Smelted &6%amount% Materials&7."
interface.furnace.tolevel = "&6%amount% %type%s &7away from leveling up."
interface.furnace.remotefurnace = "&5&lRemote Control"
interface.furnace.remotefurnacelore = "&7Left-Click to assign a nickname.|&7Right-Click to give yourself |&7remote access.|&7Current nickname is: &6%nickname%&7."
interface.furnace.utilize = "|&7To utilize remote access|&7use the command:|&6/EF Remote %nickname%"
interface.furnace.remotelist = "&7Players with remote access:"
interface.furnace.alreadymaxed = "&7This furnace is already maxed out!"
interface.button.boostedstats = "&a&lCurrently boosted!|&7Reward multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
interface:
furnace:
upgradewithxp: '&aUpgrade with XP'
upgradewithxplore: '&7Cost: &a%cost% Levels'
upgradewitheconomy: '&aUpgrade with ECO'
upgradewitheconomylore: '&7Cost: &a$%cost%'
currentlevel: '&6Furnace Level &7%level%'
level: '&6Next Level &7%level%'
performance: '&7Performance: &6%amount%'
reward: '&7Reward: &6%amount%'
performancetitle: '&a&lPerformance'
rewardtitle: '&c&lReward'
fueldurationtitle: '&7&lFuel Duration'
fuelduration: '&7Fuel Duration: &6%amount%'
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.'
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.'
tolevel: '&6%amount% %type%s &7away from leveling up.'
remotefurnace: '&5&lRemote Control'
remotefurnacelore: '&7Left-Click to assign a nickname.|&7Right-Click to give yourself |&7remote access.|&7Current nickname is: &6%nickname%&7.'
utilize: '|&7To utilize remote access|&7use the command:|&6/EF Remote %nickname%'
remotelist: '&7Players with remote access:'
alreadymaxed: '&7This furnace is already maxed out!'
button:
boostedstats: '&a&lCurrently boosted!|&7Reward multiplied by &6%amount%x&7.|&7Expires in &6%time%&7.'
#Command Messages
# Command Messages
command.give.success = "&7You have been given a &6level %level% &7Furnace."
command:
give:
success: '&7You have been given a &6level %level% &7Furnace.'
#Event Messages
# Event Messages
event.general.nopermission = "&cYou do not have permission to do that."
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
event.upgrade.success = "&7You successfully upgraded this furnace to &6level %level%&7!"
event.upgrade.maxed = "&7You maxed out this furnace at &6level %level%&7."
event.remote.enter = "&7Enter a unique nickname for the furnace."
event.remote.notfound = "&cRemote furnace not found."
event.remote.nicknamesuccess = "&aNickname set successfully."
event.remote.nicknameinuse = "&cThat nickname is already in use."
event:
general:
nopermission: '&cYou do not have permission to do that.'
upgrade:
cannotafford: '&cYou cannot afford this upgrade.'
success: '&7You successfully upgraded this furnace to &6level %level%&7!'
maxed: '&7You maxed out this furnace at &6level %level%&7.'
remote:
enter: '&7Enter a unique nickname for the furnace.'
notfound: '&cRemote furnace not found.'
nicknamesuccess: '&aNickname set successfully.'
nicknameinuse: '&cThat nickname is already in use.'