mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-30 14:33:28 +01:00
Added boosting system.
Fixed some gross code.
This commit is contained in:
parent
b8a6ee3e32
commit
cdbb63fe0c
@ -3,11 +3,15 @@ package com.songoda.epicfarming.api.farming;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface Farm {
|
||||
Inventory getInventory();
|
||||
|
||||
Location getLocation();
|
||||
|
||||
UUID getPlacedBy();
|
||||
|
||||
void setLocation(Location location);
|
||||
|
||||
Level getLevel();
|
||||
|
@ -4,18 +4,21 @@ import com.google.common.base.Preconditions;
|
||||
import com.songoda.arconix.api.mcupdate.MCUpdate;
|
||||
import com.songoda.arconix.api.utils.ConfigWrapper;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epicfarming.api.EpicFarming;
|
||||
import com.songoda.epicfarming.api.farming.Farm;
|
||||
import com.songoda.epicfarming.api.farming.Level;
|
||||
import com.songoda.epicfarming.api.utils.ClaimableProtectionPluginHook;
|
||||
import com.songoda.epicfarming.api.utils.ProtectionPluginHook;
|
||||
import com.songoda.epicfarming.boost.BoostData;
|
||||
import com.songoda.epicfarming.boost.BoostManager;
|
||||
import com.songoda.epicfarming.command.CommandManager;
|
||||
import com.songoda.epicfarming.listeners.BlockListeners;
|
||||
import com.songoda.epicfarming.listeners.InteractListeners;
|
||||
import com.songoda.epicfarming.listeners.InventoryListeners;
|
||||
import com.songoda.epicfarming.farming.EFarm;
|
||||
import com.songoda.epicfarming.farming.EFarmManager;
|
||||
import com.songoda.epicfarming.farming.ELevelManager;
|
||||
import com.songoda.epicfarming.hooks.*;
|
||||
import com.songoda.epicfarming.listeners.BlockListeners;
|
||||
import com.songoda.epicfarming.listeners.InteractListeners;
|
||||
import com.songoda.epicfarming.listeners.InventoryListeners;
|
||||
import com.songoda.epicfarming.player.PlayerActionManager;
|
||||
import com.songoda.epicfarming.player.PlayerData;
|
||||
import com.songoda.epicfarming.tasks.FarmTask;
|
||||
@ -24,7 +27,6 @@ import com.songoda.epicfarming.tasks.HopperTask;
|
||||
import com.songoda.epicfarming.utils.Debugger;
|
||||
import com.songoda.epicfarming.utils.Methods;
|
||||
import com.songoda.epicfarming.utils.SettingsManager;
|
||||
import com.songoda.epicfarming.api.EpicFarming;
|
||||
import org.apache.commons.lang.math.NumberUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
@ -40,6 +42,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
/**
|
||||
@ -61,6 +64,7 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
private ELevelManager levelManager;
|
||||
private PlayerActionManager playerActionManager;
|
||||
private CommandManager commandManager;
|
||||
private BoostManager boostManager;
|
||||
|
||||
private GrowthTask growthTask;
|
||||
private HopperTask hopperTask;
|
||||
@ -114,25 +118,45 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
|
||||
this.farmManager = new EFarmManager();
|
||||
this.playerActionManager = new PlayerActionManager();
|
||||
this.boostManager = new BoostManager();
|
||||
this.commandManager = new CommandManager(this);
|
||||
|
||||
/*
|
||||
* Register Farms into FarmManger from configuration
|
||||
*/
|
||||
if (dataFile.getConfig().contains("Farms")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("Farms").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
if (location == null || location.getWorld() == null) continue;
|
||||
int level = dataFile.getConfig().getInt("Farms." + locationStr + ".level");
|
||||
Bukkit.getScheduler().runTaskLater(this, () -> {
|
||||
if (dataFile.getConfig().contains("Farms")) {
|
||||
for (String locationStr : dataFile.getConfig().getConfigurationSection("Farms").getKeys(false)) {
|
||||
Location location = Arconix.pl().getApi().serialize().unserializeLocation(locationStr);
|
||||
if (location == null || location.getWorld() == null) continue;
|
||||
int level = dataFile.getConfig().getInt("Farms." + locationStr + ".level");
|
||||
|
||||
List<ItemStack> items = (List<ItemStack>) dataFile.getConfig().getList("Farms." + locationStr + ".Contents");
|
||||
List<ItemStack> items = (List<ItemStack>) dataFile.getConfig().getList("Farms." + locationStr + ".Contents");
|
||||
|
||||
EFarm farm = new EFarm(location, levelManager.getLevel(level));
|
||||
farm.loadInventory(items);
|
||||
String placedByStr = dataFile.getConfig().getString("Farms." + locationStr + ".placedBy");
|
||||
|
||||
farmManager.addFarm(location, farm);
|
||||
UUID placedBy = placedByStr == null ? null : UUID.fromString(placedByStr);
|
||||
|
||||
EFarm farm = new EFarm(location, levelManager.getLevel(level), placedBy);
|
||||
farm.loadInventory(items);
|
||||
|
||||
farmManager.addFarm(location, farm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Adding in Boosts
|
||||
if (dataFile.getConfig().contains("data.boosts")) {
|
||||
for (String key : dataFile.getConfig().getConfigurationSection("data.boosts").getKeys(false)) {
|
||||
if (!dataFile.getConfig().contains("data.boosts." + key + ".Player")) continue;
|
||||
BoostData boostData = new BoostData(
|
||||
dataFile.getConfig().getInt("data.boosts." + key + ".Amount"),
|
||||
Long.parseLong(key),
|
||||
UUID.fromString(dataFile.getConfig().getString("data.boosts." + key + ".Player")));
|
||||
|
||||
this.boostManager.addBoostToPlayer(boostData);
|
||||
}
|
||||
}
|
||||
}, 10);
|
||||
|
||||
this.references = new References();
|
||||
|
||||
@ -142,7 +166,7 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
pluginManager.registerEvents(new BlockListeners(this), this);
|
||||
pluginManager.registerEvents(new InteractListeners(this), this);
|
||||
pluginManager.registerEvents(new InventoryListeners(this), this);
|
||||
|
||||
|
||||
// Register default hooks
|
||||
if (pluginManager.isPluginEnabled("ASkyBlock")) this.register(HookASkyBlock::new);
|
||||
if (pluginManager.isPluginEnabled("FactionsFramework")) this.register(HookFactions::new);
|
||||
@ -216,7 +240,17 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
|| farm.getLocation().getWorld() == null) continue;
|
||||
String locationStr = Arconix.pl().getApi().serialize().serializeLocation(farm.getLocation());
|
||||
dataFile.getConfig().set("Farms." + locationStr + ".level", farm.getLevel().getLevel());
|
||||
dataFile.getConfig().set("Farms." + locationStr + ".Contents", ((EFarm)farm).dumpInventory());
|
||||
dataFile.getConfig().set("Farms." + locationStr + ".placedBy", farm.getPlacedBy() == null ? null : farm.getPlacedBy().toString());
|
||||
dataFile.getConfig().set("Farms." + locationStr + ".Contents", ((EFarm) farm).dumpInventory());
|
||||
}
|
||||
|
||||
/*
|
||||
* Dump BoostManager to file.
|
||||
*/
|
||||
for (BoostData boostData : boostManager.getBoosts()) {
|
||||
String endTime = String.valueOf(boostData.getEndTime());
|
||||
dataFile.getConfig().set("data.boosts." + endTime + ".Player", boostData.getPlayer().toString());
|
||||
dataFile.getConfig().set("data.boosts." + endTime + ".Amount", boostData.getMultiplier());
|
||||
}
|
||||
|
||||
//Save to file
|
||||
@ -233,7 +267,7 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
|
||||
private void setupConfig() {
|
||||
settingsManager.updateSettings();
|
||||
|
||||
|
||||
ConfigurationSection levels = getConfig().createSection("settings.levels");
|
||||
|
||||
if (!levels.contains("Level-1")) {
|
||||
@ -369,6 +403,10 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming {
|
||||
return commandManager;
|
||||
}
|
||||
|
||||
public BoostManager getBoostManager() {
|
||||
return boostManager;
|
||||
}
|
||||
|
||||
public PlayerActionManager getPlayerActionManager() {
|
||||
return playerActionManager;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class Locale {
|
||||
private static JavaPlugin plugin;
|
||||
private static final List<Locale> LOCALES = Lists.newArrayList();
|
||||
|
||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.{1}\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||
private static final Pattern NODE_PATTERN = Pattern.compile("(\\w+(?:\\.\\w+)*)\\s*=\\s*\"(.*)\"");
|
||||
private static final String FILE_EXTENSION = ".lang";
|
||||
private static File localeFolder;
|
||||
|
||||
@ -101,21 +101,26 @@ public class Locale {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node and replace its params with a supplied argument.
|
||||
* Get a message set for a specific node and replace its params with a supplied arguments.
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param arg the replacement argument
|
||||
* @param args the replacement arguments
|
||||
* @return the message for the specified node
|
||||
*/
|
||||
public String getMessage(String node, Object arg) {
|
||||
return getMessage(node).replaceAll("\\%.*?\\%", arg.toString());
|
||||
public String getMessage(String node, Object... args) {
|
||||
String message = getMessage(node);
|
||||
for (Object arg : args) {
|
||||
message = message.replaceFirst("%.*?%", arg.toString());
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a message set for a specific node
|
||||
*
|
||||
* @param node the node to get
|
||||
* @param node the node to get
|
||||
* @param defaultValue the default value given that a value for the node was not found
|
||||
*
|
||||
* @return the message for the specified node. Default if none found
|
||||
*/
|
||||
public String getMessageOrDefault(String node, String defaultValue) {
|
||||
@ -144,7 +149,7 @@ public class Locale {
|
||||
|
||||
this.nodes.clear(); // Clear previous data (if any)
|
||||
|
||||
try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
try(BufferedReader reader = new BufferedReader(new FileReader(file))) {
|
||||
String line;
|
||||
for (int lineNumber = 0; (line = reader.readLine()) != null; lineNumber++) {
|
||||
if (line.isEmpty() || line.startsWith("#") /* Comment */) continue;
|
||||
@ -264,8 +269,9 @@ public class Locale {
|
||||
/**
|
||||
* Save a default locale file from the project source directory, to the locale folder
|
||||
*
|
||||
* @param path the path to the file to save
|
||||
* @param path the path to the file to save
|
||||
* @param fileName the name of the file to save
|
||||
*
|
||||
* @return true if the operation was successful, false otherwise
|
||||
*/
|
||||
public static boolean saveDefaultLocale(String path, String fileName) {
|
||||
@ -339,8 +345,7 @@ public class Locale {
|
||||
|
||||
if (!existingLines.contains(key)) {
|
||||
if (!changed) {
|
||||
writer.newLine();
|
||||
writer.newLine();
|
||||
writer.newLine(); writer.newLine();
|
||||
writer.write("# New messages for " + plugin.getName() + " v" + plugin.getDescription().getVersion());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,50 @@
|
||||
package com.songoda.epicfarming.boost;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BoostData {
|
||||
|
||||
private final int multiplier;
|
||||
private final long endTime;
|
||||
private final UUID player;
|
||||
|
||||
public BoostData(int multiplier, long endTime, UUID player) {
|
||||
this.multiplier = multiplier;
|
||||
this.endTime = endTime;
|
||||
this.player = player;
|
||||
}
|
||||
|
||||
public int getMultiplier() {
|
||||
return multiplier;
|
||||
}
|
||||
|
||||
public UUID getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public long getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = 31 * multiplier;
|
||||
|
||||
result = 31 * result + (this.player == null ? 0 : player.hashCode());
|
||||
result = 31 * result + (int) (endTime ^ (endTime >>> 32));
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (!(obj instanceof BoostData)) return false;
|
||||
|
||||
BoostData other = (BoostData) obj;
|
||||
return multiplier == other.multiplier && endTime == other.endTime
|
||||
&& Objects.equals(player, other.player);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package com.songoda.epicfarming.boost;
|
||||
|
||||
import com.songoda.epicfarming.EpicFarmingPlugin;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BoostManager {
|
||||
|
||||
private final Set<BoostData> registeredBoosts = new HashSet<>();
|
||||
|
||||
public void addBoostToPlayer(BoostData data) {
|
||||
this.registeredBoosts.add(data);
|
||||
}
|
||||
|
||||
public void removeBoostFromPlayer(BoostData data) {
|
||||
this.registeredBoosts.remove(data);
|
||||
}
|
||||
|
||||
public Set<BoostData> getBoosts() {
|
||||
return Collections.unmodifiableSet(registeredBoosts);
|
||||
}
|
||||
|
||||
public BoostData getBoost(UUID player) {
|
||||
if (player == null) return null;
|
||||
for (BoostData boostData : registeredBoosts) {
|
||||
if (boostData.getPlayer().toString().equals(player.toString())) {
|
||||
if (System.currentTimeMillis() >= boostData.getEndTime()) {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(EpicFarmingPlugin.getInstance(), () -> removeBoostFromPlayer(boostData), 1);
|
||||
}
|
||||
return boostData;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -3,10 +3,7 @@ package com.songoda.epicfarming.command;
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.epicfarming.EpicFarmingPlugin;
|
||||
import com.songoda.epicfarming.api.EpicFarming;
|
||||
import com.songoda.epicfarming.command.commands.CommandEpicFarming;
|
||||
import com.songoda.epicfarming.command.commands.CommandGiveFarmItem;
|
||||
import com.songoda.epicfarming.command.commands.CommandReload;
|
||||
import com.songoda.epicfarming.command.commands.CommandSettings;
|
||||
import com.songoda.epicfarming.command.commands.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@ -27,11 +24,12 @@ public class CommandManager implements CommandExecutor {
|
||||
|
||||
instance.getCommand("EpicFarming").setExecutor(this);
|
||||
|
||||
AbstractCommand commandEpicSpawners = addCommand(new CommandEpicFarming());
|
||||
AbstractCommand commandEpicFarming = addCommand(new CommandEpicFarming());
|
||||
|
||||
addCommand(new CommandReload(commandEpicSpawners));
|
||||
addCommand(new CommandSettings(commandEpicSpawners));
|
||||
addCommand(new CommandGiveFarmItem(commandEpicSpawners));
|
||||
addCommand(new CommandReload(commandEpicFarming));
|
||||
addCommand(new CommandSettings(commandEpicFarming));
|
||||
addCommand(new CommandGiveFarmItem(commandEpicFarming));
|
||||
addCommand(new CommandBoost(commandEpicFarming));
|
||||
}
|
||||
|
||||
private AbstractCommand addCommand(AbstractCommand abstractCommand) {
|
||||
|
@ -0,0 +1,84 @@
|
||||
package com.songoda.epicfarming.command.commands;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.methods.math.AMath;
|
||||
import com.songoda.epicfarming.EpicFarmingPlugin;
|
||||
import com.songoda.epicfarming.boost.BoostData;
|
||||
import com.songoda.epicfarming.command.AbstractCommand;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
|
||||
public class CommandBoost extends AbstractCommand {
|
||||
|
||||
public CommandBoost(AbstractCommand parent) {
|
||||
super("boost", parent, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ReturnType runCommand(EpicFarmingPlugin instance, CommandSender sender, String... args) {
|
||||
if (args.length < 3) {
|
||||
return ReturnType.SYNTAX_ERROR;
|
||||
}
|
||||
if (Bukkit.getPlayer(args[1]) == null) {
|
||||
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&cThat player does not exist..."));
|
||||
return ReturnType.FAILURE;
|
||||
} else if (!AMath.isInt(args[2])) {
|
||||
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&6" + args[2] + " &7is not a number..."));
|
||||
return ReturnType.FAILURE;
|
||||
} else {
|
||||
Calendar c = Calendar.getInstance();
|
||||
Date currentDate = new Date();
|
||||
c.setTime(currentDate);
|
||||
|
||||
String time = "&7.";
|
||||
|
||||
if (args.length > 3) {
|
||||
if (args[3].contains("m:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.MINUTE, Integer.parseInt(arr2[1]));
|
||||
time = " &7for &6" + arr2[1] + " minutes&7.";
|
||||
} else if (args[3].contains("h:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.HOUR, Integer.parseInt(arr2[1]));
|
||||
time = " &7for &6" + arr2[1] + " hours&7.";
|
||||
} else if (args[3].contains("d:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.HOUR, Integer.parseInt(arr2[1]) * 24);
|
||||
time = " &7for &6" + arr2[1] + " days&7.";
|
||||
} else if (args[3].contains("y:")) {
|
||||
String[] arr2 = (args[3]).split(":");
|
||||
c.add(Calendar.YEAR, Integer.parseInt(arr2[1]));
|
||||
time = " &7for &6" + arr2[1] + " years&7.";
|
||||
} else {
|
||||
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&7" + args[3] + " &7is invalid."));
|
||||
return ReturnType.SUCCESS;
|
||||
}
|
||||
} else {
|
||||
c.add(Calendar.YEAR, 10);
|
||||
}
|
||||
|
||||
BoostData boostData = new BoostData(Integer.parseInt(args[2]), c.getTime().getTime(), Bukkit.getPlayer(args[1]).getUniqueId());
|
||||
instance.getBoostManager().addBoostToPlayer(boostData);
|
||||
sender.sendMessage(TextComponent.formatText(instance.getReferences().getPrefix() + "&7Successfully boosted &6" + Bukkit.getPlayer(args[1]).getName() + "'s &7farms yield rates by &6" + args[2] + "x" + time));
|
||||
}
|
||||
return ReturnType.FAILURE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermissionNode() {
|
||||
return "epicfarming.admin";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSyntax() {
|
||||
return "/efa boost <player> <multiplier> [m:minute, h:hour, d:day, y:year]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDescription() {
|
||||
return "This allows you to boost a players farms yield amounts by a multiplier (Put 2 for double, 3 for triple and so on).";
|
||||
}
|
||||
}
|
@ -1,9 +1,12 @@
|
||||
package com.songoda.epicfarming.farming;
|
||||
|
||||
import com.songoda.arconix.api.methods.formatting.TextComponent;
|
||||
import com.songoda.arconix.api.methods.formatting.TimeComponent;
|
||||
import com.songoda.arconix.plugin.Arconix;
|
||||
import com.songoda.epicfarming.EpicFarmingPlugin;
|
||||
import com.songoda.epicfarming.api.farming.Level;
|
||||
import com.songoda.epicfarming.api.farming.UpgradeType;
|
||||
import com.songoda.epicfarming.boost.BoostData;
|
||||
import com.songoda.epicfarming.player.PlayerData;
|
||||
import com.songoda.epicfarming.utils.Debugger;
|
||||
import com.songoda.epicfarming.utils.Methods;
|
||||
@ -21,16 +24,19 @@ import org.bukkit.plugin.RegisteredServiceProvider;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
public class EFarm implements Farm {
|
||||
|
||||
private Location location;
|
||||
private Level level;
|
||||
private Inventory inventory;
|
||||
private UUID placedBy;
|
||||
|
||||
public EFarm(Location location, Level level) {
|
||||
public EFarm(Location location, Level level, UUID placedBy) {
|
||||
this.location = location;
|
||||
this.level = level;
|
||||
this.placedBy = placedBy;
|
||||
this.inventory = Bukkit.createInventory(null, 54, Methods.formatName(level.getLevel(),false));
|
||||
}
|
||||
|
||||
@ -75,6 +81,14 @@ public class EFarm implements Farm {
|
||||
lore.addAll(nextLevel.getDescription());
|
||||
}
|
||||
|
||||
BoostData boostData = instance.getBoostManager().getBoost(placedBy);
|
||||
if (boostData != null) {
|
||||
String[] parts = instance.getLocale().getMessage("interface.button.boostedstats", Integer.toString(boostData.getMultiplier()), TimeComponent.makeReadable(boostData.getEndTime() - System.currentTimeMillis())).split("\\|");
|
||||
lore.add("");
|
||||
for (String line : parts)
|
||||
lore.add(TextComponent.formatText(line));
|
||||
}
|
||||
|
||||
itemmeta.setLore(lore);
|
||||
item.setItemMeta(itemmeta);
|
||||
|
||||
@ -270,6 +284,11 @@ public class EFarm implements Farm {
|
||||
return location.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getPlacedBy() {
|
||||
return placedBy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
|
@ -77,7 +77,7 @@ public class BlockListeners implements Listener {
|
||||
|
||||
if (location.getBlock().getType() != farmBlock) return;
|
||||
|
||||
EFarm farm = new EFarm(location, instance.getLevelManager().getLevel(level));
|
||||
EFarm farm = new EFarm(location, instance.getLevelManager().getLevel(level), e.getPlayer().getUniqueId());
|
||||
instance.getFarmManager().addFarm(location, farm);
|
||||
|
||||
farm.tillLand(e.getBlock().getLocation());
|
||||
|
@ -3,6 +3,7 @@ package com.songoda.epicfarming.tasks;
|
||||
import com.songoda.epicfarming.EpicFarmingPlugin;
|
||||
import com.songoda.epicfarming.api.EpicFarming;
|
||||
import com.songoda.epicfarming.api.farming.Farm;
|
||||
import com.songoda.epicfarming.boost.BoostData;
|
||||
import com.songoda.epicfarming.farming.Crop;
|
||||
import com.songoda.epicfarming.utils.CropType;
|
||||
import com.songoda.epicfarming.utils.Debugger;
|
||||
@ -70,7 +71,11 @@ public class FarmTask extends BukkitRunnable {
|
||||
if (material == null || farm == null || cropTypeData == null) return false;
|
||||
|
||||
|
||||
ItemStack stack = new ItemStack(cropTypeData.getYieldMaterial(), useBoneMeal(farm) ? random.nextInt(2) + 2 : 1);
|
||||
|
||||
|
||||
BoostData boostData = plugin.getBoostManager().getBoost(farm.getPlacedBy());
|
||||
|
||||
ItemStack stack = new ItemStack(cropTypeData.getYieldMaterial(), (useBoneMeal(farm) ? random.nextInt(2) + 2 : 1) * (boostData == null ? 1 : boostData.getMultiplier()));
|
||||
ItemStack seedStack = new ItemStack(cropTypeData.getSeedMaterial(), random.nextInt(3) + 1 + (useBoneMeal(farm) ? 1 : 0));
|
||||
|
||||
if (!canMove(farm.getInventory(), stack)) return false;
|
||||
|
@ -14,6 +14,8 @@ interface.button.radius = "&7Radius: &6%speed%"
|
||||
interface.button.speed = "&7Speed: &6%speed%x"
|
||||
interface.button.autoharvest = "&7Auto Harvest: &6%status%"
|
||||
interface.button.autoreplant = "&7Auto Replant: &6%status%"
|
||||
interface.button.boostedstats = "&a&lCurrently boosted!|&7Yeild rate multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
|
||||
|
||||
|
||||
#Command Messages
|
||||
|
||||
|
@ -11,4 +11,4 @@ commands:
|
||||
description: View information on this plugin.
|
||||
default: true
|
||||
aliases: [efa]
|
||||
usage: /ed
|
||||
usage: /efa
|
Loading…
Reference in New Issue
Block a user