Cleanup :D

This commit is contained in:
Brianna 2019-09-11 12:35:50 -04:00
parent df6b7152a9
commit 5a9e93d9da
4 changed files with 62 additions and 54 deletions

View File

@ -31,6 +31,7 @@ import com.songoda.epicfarming.utils.Methods;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.PluginManager;
@ -199,16 +200,17 @@ public class EpicFarming extends SongodaPlugin {
/*
* Register Levels into LevelManager from configuration.
*/
levelManager.clear();
for (String levelName : getConfig().getConfigurationSection("settings.levels").getKeys(false)) {
for (String levelName : levelsFile.getKeys(false)) {
ConfigurationSection levels = levelsFile.getConfigurationSection(levelName);
int level = Integer.valueOf(levelName.split("-")[1]);
int costExperiance = getConfig().getInt("settings.levels." + levelName + ".Cost-xp");
int costEconomy = getConfig().getInt("settings.levels." + levelName + ".Cost-eco");
int radius = getConfig().getInt("settings.levels." + levelName + ".Radius");
double speedMultiplier = getConfig().getDouble("settings.levels." + levelName + ".Speed-Multiplier");
boolean autoHarvest = getConfig().getBoolean("settings.levels." + levelName + ".Auto-Harvest");
boolean autoReplant = getConfig().getBoolean("settings.levels." + levelName + ".Auto-Replant");
boolean autoBreeding = getConfig().getBoolean("settings.levels." + levelName + ".Auto-Breeding");
int costExperiance = levels.getInt("Cost-xp");
int costEconomy = levels.getInt("Cost-eco");
int radius = levels.getInt("Radius");
double speedMultiplier = levels.getDouble("Speed-Multiplier");
boolean autoHarvest = levels.getBoolean("Auto-Harvest");
boolean autoReplant = levels.getBoolean("Auto-Replant");
boolean autoBreeding = levels.getBoolean("Auto-Breeding");
levelManager.addLevel(level, costExperiance, costEconomy, speedMultiplier, radius, autoHarvest, autoReplant, autoBreeding);
}
}

View File

@ -20,32 +20,32 @@ public class CommandGiveFarmItem extends AbstractCommand {
@Override
protected ReturnType runCommand(CommandSender sender, String... args) {
if (args.length == 2) return ReturnType.SYNTAX_ERROR;
if (args.length == 1) return ReturnType.SYNTAX_ERROR;
Level level = instance.getLevelManager().getLowestLevel();
Player player;
if (args.length != 1 && Bukkit.getPlayer(args[1]) == null) {
if (args.length != 0 && Bukkit.getPlayer(args[0]) == null) {
instance.getLocale().newMessage("&cThat player does not exist or is currently offline.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
} else if (args.length == 1) {
} else if (args.length == 0) {
if (!(sender instanceof Player)) {
instance.getLocale().newMessage("&cYou need to be a player to give a farm item to yourself.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
}
player = (Player) sender;
} else {
player = Bukkit.getPlayer(args[1]);
player = Bukkit.getPlayer(args[0]);
}
if (args.length >= 3 && !instance.getLevelManager().isLevel(Integer.parseInt(args[2]))) {
if (args.length >= 2 && !instance.getLevelManager().isLevel(Integer.parseInt(args[1]))) {
instance.getLocale().newMessage("&cNot a valid level... The current valid levels are: &4"
+ instance.getLevelManager().getLowestLevel().getLevel() + "-"
+ instance.getLevelManager().getHighestLevel().getLevel() + "&c.").sendPrefixedMessage(sender);
return ReturnType.FAILURE;
} else if (args.length != 1) {
} else if (args.length != 0) {
level = instance.getLevelManager().getLevel(Integer.parseInt(args[2]));
level = instance.getLevelManager().getLevel(Integer.parseInt(args[1]));
}
player.getInventory().addItem(instance.makeFarmItem(level));
instance.getLocale().getMessage("command.give.success")

View File

@ -1,37 +1,43 @@
Level-1.Radius: 1
Level-1.Speed-Multiplier: 1
Level-1.Cost-xp: 20
Level-1.Cost-eco: 5000
Level-2.Radius: 2
Level-2.Speed-Multiplier: 1.5
Level-2.Auto-Harvest: true
Level-2.Cost-xp: 20
Level-2.Cost-eco: 5000
Level-3.Radius: 3
Level-3.Speed-Multiplier: 1.5
Level-3.Auto-Harvest: true
Level-3.Auto-Replant: true
Level-3.Auto-Breeding: true
Level-3.Cost-xp: 25
Level-3.Cost-eco: 7500
Level-4.Radius: 3
Level-4.Speed-Multiplier: 2
Level-4.Auto-Harvest: true
Level-4.Auto-Replant: true
Level-4.Auto-Breeding: true
Level-4.Cost-xp: 30
Level-4.Cost-eco: 10000
Level-5.Radius: 3
Level-5.Speed-Multiplier: 2.5
Level-5.Auto-Harvest: true
Level-5.Auto-Replant: true
Level-5.Auto-Breeding: true
Level-5.Cost-xp: 35
Level-5.Cost-eco: 12000
Level-6.Radius: 4
Level-6.Speed-Multiplier: 3
Level-6.Auto-Harvest: true
Level-6.Auto-Replant: true
Level-6.Auto-Breeding: true
Level-6.Cost-xp: 40
Level-6.Cost-eco: 25000
Level-1:
Radius: 1
Speed-Multiplier: 1
Cost-xp: 20
Cost-eco: 5000
Level-2:
Radius: 2
Speed-Multiplier: 1.5
Auto-Harvest: true
Cost-xp: 20
Cost-eco: 5000
Level-3:
Radius: 3
Speed-Multiplier: 1.5
Auto-Harvest: true
Auto-Replant: true
Auto-Breeding: true
Cost-xp: 25
Cost-eco: 7500
Level-4:
Radius: 3
Speed-Multiplier: 2
Auto-Harvest: true
Auto-Replant: true
Auto-Breeding: true
Cost-xp: 30
Cost-eco: 10000
Level-5:
Radius: 3
Speed-Multiplier: 2.5
Auto-Harvest: true
Auto-Replant: true
Auto-Breeding: true
Cost-xp: 35
Cost-eco: 12000
Level-6:
Radius: 4
Speed-Multiplier: 3
Auto-Harvest: true
Auto-Replant: true
Auto-Breeding: true
Cost-xp: 40
Cost-eco: 25000

View File

@ -1,6 +1,6 @@
name: EpicFarming
description: EpicFarming
main: com.songoda.epicfarming.EpicFarmingPlugin
main: com.songoda.epicfarming.EpicFarming
version: maven-version-number
softdepend: [Arconix, SkyBlock, Towny, RedProtect, Kingdoms, PlotSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, PlaceholderAPI]
author: Songoda