mirror of
https://github.com/songoda/EpicFurnaces.git
synced 2024-12-04 07:43:22 +01:00
Merge branch 'development'
This commit is contained in:
commit
5f882f4cb4
@ -4,7 +4,7 @@ stages:
|
|||||||
variables:
|
variables:
|
||||||
name: "EpicFurnaces"
|
name: "EpicFurnaces"
|
||||||
path: "/builds/$CI_PROJECT_PATH"
|
path: "/builds/$CI_PROJECT_PATH"
|
||||||
version: "4.5.2"
|
version: "4.5.3"
|
||||||
|
|
||||||
build:
|
build:
|
||||||
stage: build
|
stage: build
|
||||||
|
@ -167,7 +167,7 @@ public class EpicFurnaces extends SongodaPlugin {
|
|||||||
|
|
||||||
org.bukkit.block.Furnace furnaceBlock = ((org.bukkit.block.Furnace) state);
|
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);
|
float percent = (float) (furnaceBlock.getCookTime() - performance) / (200 - performance);
|
||||||
|
|
||||||
|
@ -6,84 +6,80 @@ import com.songoda.epicfurnaces.boost.BoostData;
|
|||||||
import com.songoda.epicfurnaces.utils.Methods;
|
import com.songoda.epicfurnaces.utils.Methods;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommandBoost extends AbstractCommand {
|
public class CommandBoost extends AbstractCommand {
|
||||||
|
|
||||||
final EpicFurnaces plugin;
|
final EpicFurnaces instance;
|
||||||
|
|
||||||
public CommandBoost(EpicFurnaces plugin) {
|
public CommandBoost(EpicFurnaces instance) {
|
||||||
super(false, "boost");
|
super(false, "boost");
|
||||||
this.plugin = plugin;
|
this.instance = instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ReturnType runCommand(CommandSender sender, String... args) {
|
protected ReturnType runCommand(CommandSender sender, String... args) {
|
||||||
if (args.length < 2) {
|
if (args.length < 2) {
|
||||||
|
instance.getLocale().newMessage("&7Syntax error...").sendPrefixedMessage(sender);
|
||||||
return ReturnType.SYNTAX_ERROR;
|
return ReturnType.SYNTAX_ERROR;
|
||||||
}
|
}
|
||||||
if (Bukkit.getPlayer(args[0]) == null) {
|
if (!Methods.isInt(args[1])) {
|
||||||
plugin.getLocale().newMessage("&cThat player does not exist...").sendPrefixedMessage(sender);
|
instance.getLocale().newMessage("&6" + args[1] + " &7is not a number...").sendPrefixedMessage(sender);
|
||||||
return ReturnType.FAILURE;
|
return ReturnType.SYNTAX_ERROR;
|
||||||
} 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);
|
|
||||||
}
|
}
|
||||||
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
|
@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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPermissionNode() {
|
public String getPermissionNode() {
|
||||||
return "epicfurnaces.admin";
|
return "epicfurnaces.boost";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSyntax() {
|
public String getSyntax() {
|
||||||
return "/ef boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]";
|
return "/ef boost <player> <amount> [duration]";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -56,7 +56,9 @@ public class Furnace {
|
|||||||
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) return;
|
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) return;
|
||||||
|
|
||||||
this.uses++;
|
this.uses++;
|
||||||
this.tolevel++;
|
|
||||||
|
if (Settings.UPGRADE_COST.getMaterial().matches(e.getResult()))
|
||||||
|
this.tolevel++;
|
||||||
|
|
||||||
int multi = Settings.LEVEL_MULTIPLIER.getInt();
|
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;
|
if (!block.getType().name().contains("FURNACE") && !block.getType().name().contains("SMOKER")) return;
|
||||||
|
|
||||||
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
||||||
int num = getPerformanceTotal();
|
int num = getPerformanceTotal(block.getType());
|
||||||
|
|
||||||
if (num > 200)
|
int max = (block.getType().name().contains("BLAST") || block.getType().name().contains("SMOKER") ? 100 : 200);
|
||||||
num = 200;
|
if (num >= max)
|
||||||
|
num = max - 1;
|
||||||
|
|
||||||
if (num != 0) {
|
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)));
|
((org.bukkit.block.Furnace) bs).setCookTime(Short.parseShort(Integer.toString(num)));
|
||||||
bs.update();
|
bs.update();
|
||||||
}
|
}
|
||||||
@ -218,13 +221,14 @@ public class Furnace {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public int getPerformanceTotal() {
|
public int getPerformanceTotal(Material material) {
|
||||||
String equation = "(" + level.getPerformance() + " / 100) * 200";
|
String cap = (material.name().contains("BLAST") || material.name().contains("SMOKER") ? "100" : "200");
|
||||||
|
String equation = "(" + level.getPerformance() + " / 100) * " + cap;
|
||||||
try {
|
try {
|
||||||
if (!cache.containsKey(equation)) {
|
if (!cache.containsKey(equation)) {
|
||||||
ScriptEngineManager mgr = new ScriptEngineManager();
|
ScriptEngineManager mgr = new ScriptEngineManager();
|
||||||
ScriptEngine engine = mgr.getEngineByName("JavaScript");
|
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);
|
cache.put(equation, num);
|
||||||
return num;
|
return num;
|
||||||
} else {
|
} else {
|
||||||
|
@ -11,7 +11,7 @@ import java.util.stream.Collectors;
|
|||||||
|
|
||||||
public class Settings {
|
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);
|
public static final ConfigSetting UPGRADE_BY_SMELTING = new ConfigSetting(config, "Main.Upgrade By Smelting Materials", true);
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package com.songoda.epicfurnaces.storage.types;
|
package com.songoda.epicfurnaces.storage.types;
|
||||||
|
|
||||||
import com.songoda.core.configuration.Config;
|
|
||||||
import com.songoda.epicfurnaces.EpicFurnaces;
|
import com.songoda.epicfurnaces.EpicFurnaces;
|
||||||
import com.songoda.epicfurnaces.storage.Storage;
|
import com.songoda.epicfurnaces.storage.Storage;
|
||||||
import com.songoda.epicfurnaces.storage.StorageItem;
|
import com.songoda.epicfurnaces.storage.StorageItem;
|
||||||
@ -109,7 +108,8 @@ public class StorageYaml extends Storage {
|
|||||||
File data = new File(plugin.getDataFolder(), "data.yml");
|
File data = new File(plugin.getDataFolder(), "data.yml");
|
||||||
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
File dataClone = new File(plugin.getDataFolder(), "data-backup-" + System.currentTimeMillis() + ".yml");
|
||||||
try {
|
try {
|
||||||
copyFile(data, dataClone);
|
if (data.exists())
|
||||||
|
copyFile(data, dataClone);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,55 +1,67 @@
|
|||||||
#General Messages
|
# General Messages
|
||||||
|
|
||||||
general.nametag.prefix = "&8[&6EpicFurnaces&8]"
|
general:
|
||||||
general.nametag.next = "&9Next"
|
nametag:
|
||||||
general.nametag.back = "&9Back"
|
prefix: '&8[&6EpicFurnaces&8]'
|
||||||
general.nametag.nameformat = "&eLevel %level% &fFurnace"
|
next: '&9Next'
|
||||||
general.hologram.outoffuel = "&cNo Fuel"
|
back: '&9Back'
|
||||||
general.hologram.stats = "&a%in%&7/&c%out%"
|
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:
|
||||||
interface.furnace.upgradewithxplore = "&7Cost: &a%cost% Levels"
|
furnace:
|
||||||
interface.furnace.upgradewitheconomy = "&aUpgrade with ECO"
|
upgradewithxp: '&aUpgrade with XP'
|
||||||
interface.furnace.upgradewitheconomylore = "&7Cost: &a$%cost%"
|
upgradewithxplore: '&7Cost: &a%cost% Levels'
|
||||||
interface.furnace.currentlevel = "&6Furnace Level &7%level%"
|
upgradewitheconomy: '&aUpgrade with ECO'
|
||||||
interface.furnace.level = "&6Next Level &7%level%"
|
upgradewitheconomylore: '&7Cost: &a$%cost%'
|
||||||
interface.furnace.performance = "&7Performance: &6%amount%"
|
currentlevel: '&6Furnace Level &7%level%'
|
||||||
interface.furnace.reward = "&7Reward: &6%amount%"
|
level: '&6Next Level &7%level%'
|
||||||
interface.furnace.performancetitle = "&a&lPerformance"
|
performance: '&7Performance: &6%amount%'
|
||||||
interface.furnace.rewardtitle = "&c&lReward"
|
reward: '&7Reward: &6%amount%'
|
||||||
interface.furnace.fueldurationtitle = "&7&lFuel Duration"
|
performancetitle: '&a&lPerformance'
|
||||||
interface.furnace.fuelduration = "&7Fuel Duration: &6%amount%"
|
rewardtitle: '&c&lReward'
|
||||||
interface.furnace.fuelshare = "&7Fuel Share: &6%amount%&7."
|
fueldurationtitle: '&7&lFuel Duration'
|
||||||
interface.furnace.fuelsharetitle = "&6&lFuel Share"
|
fuelduration: '&7Fuel Duration: &6%amount%'
|
||||||
interface.furnace.fuelshareinfo = "&7This furnace will power other|&7furnaces within a &6%amount%&7 block radius."
|
fuelshare: '&7Fuel Share: &6%amount%&7.'
|
||||||
interface.furnace.overheat = "&7Overheat: &6%amount%&7."
|
fuelsharetitle: '&6&lFuel Share'
|
||||||
interface.furnace.overheattitle = "&6&lOverheat"
|
fuelshareinfo: '&7This furnace will power other|&7furnaces within a &6%amount%&7 block radius.'
|
||||||
interface.furnace.overheatinfo = "&7This furnace will melt snow |&7and ice within a &6%amount%&7 block radius."
|
overheat: '&7Overheat: &6%amount%&7.'
|
||||||
interface.furnace.performanceinfo = "&7This furnaces performance is |&7currently boosted an extra &6%amount%%&7. | |&7Performance boosts the speed in |&7which a furnace processes |&7materials."
|
overheattitle: '&6&lOverheat'
|
||||||
interface.furnace.rewardinfo = "&7This furnace currently |&7has a &6%amount%%&7 chance of |&7producing multiple resources."
|
overheatinfo: '&7This furnace will melt snow |&7and ice within a &6%amount%&7 block radius.'
|
||||||
interface.furnace.fueldurationinfo = "&7This furnaces fuel duration is |&7currently boosted by &6%amount%%&7. | |&7Fuel Duration boosts how long |&7fuel in the furnace lasts."
|
performanceinfo: '&7This furnaces performance is |&7currently boosted an extra &6%amount%%&7. | |&7Performance boosts the speed in |&7which a furnace processes |&7materials.'
|
||||||
interface.furnace.smeltedx = "&7Smelted &6%amount% Materials&7."
|
rewardinfo: '&7This furnace currently |&7has a &6%amount%%&7 chance of |&7producing multiple resources.'
|
||||||
interface.furnace.tolevel = "&6%amount% %type%s &7away from leveling up."
|
fueldurationinfo: '&7This furnaces fuel duration is |&7currently boosted by &6%amount%%&7. | |&7Fuel Duration boosts how long |&7fuel in the furnace lasts.'
|
||||||
interface.furnace.remotefurnace = "&5&lRemote Control"
|
smeltedx: '&7Smelted &6%amount% Materials&7.'
|
||||||
interface.furnace.remotefurnacelore = "&7Left-Click to assign a nickname.|&7Right-Click to give yourself |&7remote access.|&7Current nickname is: &6%nickname%&7."
|
tolevel: '&6%amount% %type%s &7away from leveling up.'
|
||||||
interface.furnace.utilize = "|&7To utilize remote access|&7use the command:|&6/EF Remote %nickname%"
|
remotefurnace: '&5&lRemote Control'
|
||||||
interface.furnace.remotelist = "&7Players with remote access:"
|
remotefurnacelore: '&7Left-Click to assign a nickname.|&7Right-Click to give yourself |&7remote access.|&7Current nickname is: &6%nickname%&7.'
|
||||||
interface.furnace.alreadymaxed = "&7This furnace is already maxed out!"
|
utilize: '|&7To utilize remote access|&7use the command:|&6/EF Remote %nickname%'
|
||||||
interface.button.boostedstats = "&a&lCurrently boosted!|&7Reward multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
|
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:
|
||||||
event.upgrade.cannotafford = "&cYou cannot afford this upgrade."
|
general:
|
||||||
event.upgrade.success = "&7You successfully upgraded this furnace to &6level %level%&7!"
|
nopermission: '&cYou do not have permission to do that.'
|
||||||
event.upgrade.maxed = "&7You maxed out this furnace at &6level %level%&7."
|
upgrade:
|
||||||
event.remote.enter = "&7Enter a unique nickname for the furnace."
|
cannotafford: '&cYou cannot afford this upgrade.'
|
||||||
event.remote.notfound = "&cRemote furnace not found."
|
success: '&7You successfully upgraded this furnace to &6level %level%&7!'
|
||||||
event.remote.nicknamesuccess = "&aNickname set successfully."
|
maxed: '&7You maxed out this furnace at &6level %level%&7.'
|
||||||
event.remote.nicknameinuse = "&cThat nickname is already in use."
|
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.'
|
||||||
|
Loading…
Reference in New Issue
Block a user