From bd74abf170c19203efb63dcad6d673f08bb80c84 Mon Sep 17 00:00:00 2001 From: Christian Koop Date: Mon, 19 Jul 2021 18:05:14 +0200 Subject: [PATCH 1/6] Fix typo --- .../java/com/songoda/epicfarming/farming/Farm.java | 2 +- .../com/songoda/epicfarming/farming/levels/Level.java | 11 ++++++----- .../java/com/songoda/epicfarming/gui/OverviewGui.java | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/songoda/epicfarming/farming/Farm.java b/src/main/java/com/songoda/epicfarming/farming/Farm.java index bc615d2..8f026d0 100644 --- a/src/main/java/com/songoda/epicfarming/farming/Farm.java +++ b/src/main/java/com/songoda/epicfarming/farming/Farm.java @@ -85,7 +85,7 @@ public class Farm { Level level = instance.getLevelManager().getLevel(this.level.getLevel() + 1); int cost; if (type == UpgradeType.EXPERIENCE) { - cost = level.getCostExperiance(); + cost = level.getCostExperience(); } else { cost = level.getCostEconomy(); } diff --git a/src/main/java/com/songoda/epicfarming/farming/levels/Level.java b/src/main/java/com/songoda/epicfarming/farming/levels/Level.java index f397e29..ebedab6 100644 --- a/src/main/java/com/songoda/epicfarming/farming/levels/Level.java +++ b/src/main/java/com/songoda/epicfarming/farming/levels/Level.java @@ -10,20 +10,21 @@ public class Level { private final ArrayList registeredModules; private List description = new ArrayList<>(); - private int level, costExperiance, costEconomy, radius, pages; + private int level, costExperience, costEconomy, radius, pages; private double speedMultiplier; private boolean autoReplant; - Level(int level, int costExperiance, int costEconomy, double speedMultiplier, int radius, boolean autoReplant, int pages, ArrayList registeredModules) { + Level(int level, int costExperience, int costEconomy, double speedMultiplier, int radius, boolean autoReplant, int pages, ArrayList registeredModules) { this.level = level; - this.costExperiance = costExperiance; + this.costExperience = costExperience; this.costEconomy = costEconomy; this.speedMultiplier = speedMultiplier; this.radius = radius; this.autoReplant = autoReplant; this.pages = pages; this.registeredModules = registeredModules; + buildDescription(); } @@ -76,8 +77,8 @@ public class Level { return speedMultiplier; } - public int getCostExperiance() { - return costExperiance; + public int getCostExperience() { + return costExperience; } public int getCostEconomy() { diff --git a/src/main/java/com/songoda/epicfarming/gui/OverviewGui.java b/src/main/java/com/songoda/epicfarming/gui/OverviewGui.java index 1fae458..b808326 100644 --- a/src/main/java/com/songoda/epicfarming/gui/OverviewGui.java +++ b/src/main/java/com/songoda/epicfarming/gui/OverviewGui.java @@ -123,7 +123,7 @@ public class OverviewGui extends CustomizableGui { plugin.getLocale().getMessage("interface.button.upgradewithxp").getMessage(), nextLevel != null ? plugin.getLocale().getMessage("interface.button.upgradewithxplore") - .processPlaceholder("cost", nextLevel.getCostExperiance()).getMessage() + .processPlaceholder("cost", nextLevel.getCostExperience()).getMessage() : plugin.getLocale().getMessage("event.upgrade.maxed").getMessage()), event -> { farm.upgrade(UpgradeType.EXPERIENCE, player); From 21c62bd289e77c9013ecb6d7569a64a5977f5697 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 23 Sep 2021 14:48:21 -0500 Subject: [PATCH 2/6] This event isn't cancellable in 1.8 Oops xD. --- src/main/java/com/songoda/epicfarming/tasks/FarmTask.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/songoda/epicfarming/tasks/FarmTask.java b/src/main/java/com/songoda/epicfarming/tasks/FarmTask.java index 14c00fb..6ac372a 100644 --- a/src/main/java/com/songoda/epicfarming/tasks/FarmTask.java +++ b/src/main/java/com/songoda/epicfarming/tasks/FarmTask.java @@ -1,6 +1,7 @@ package com.songoda.epicfarming.tasks; import com.songoda.core.compatibility.CompatibleMaterial; +import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.utils.BlockUtils; import com.songoda.epicfarming.EpicFarming; import com.songoda.epicfarming.farming.Crop; @@ -76,7 +77,7 @@ public class FarmTask extends BukkitRunnable { public void run() { GrowthTask growthTask = plugin.getGrowthTask(); - if (growthTask.isCancelled()) return; + if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9) && growthTask.isCancelled()) return; for (Farm farm : new ArrayList<>(plugin.getFarmManager().getFarms().values())) { if (!plugin.isEnabled()) return; // Prevent registering a task on plugin disable From 1f229ebedc15320a15a6060b5089b5ca9fc1ef35 Mon Sep 17 00:00:00 2001 From: Brianna Date: Thu, 23 Sep 2021 15:08:05 -0500 Subject: [PATCH 3/6] Make saving a bit faster. --- .../java/com/songoda/epicfarming/EpicFarming.java | 6 ++++-- .../songoda/epicfarming/database/DataManager.java | 1 + .../java/com/songoda/epicfarming/farming/Farm.java | 13 +++++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/songoda/epicfarming/EpicFarming.java b/src/main/java/com/songoda/epicfarming/EpicFarming.java index db57833..0f24f90 100644 --- a/src/main/java/com/songoda/epicfarming/EpicFarming.java +++ b/src/main/java/com/songoda/epicfarming/EpicFarming.java @@ -104,7 +104,8 @@ public class EpicFarming extends SongodaPlugin { saveToFile(); for (Farm farm : farmManager.getFarms().values()) - dataManager.updateItems(farm); + if (farm.needsToBeSaved()) + dataManager.updateItems(farm); } @Override @@ -185,7 +186,8 @@ public class EpicFarming extends SongodaPlugin { saveToFile(); for (Farm farm : farmManager.getFarms().values()) - dataManager.updateItemsAsync(farm); + if (farm.needsToBeSaved()) + dataManager.updateItemsAsync(farm); }, 6000, 6000); } diff --git a/src/main/java/com/songoda/epicfarming/database/DataManager.java b/src/main/java/com/songoda/epicfarming/database/DataManager.java index 842972b..c69885b 100644 --- a/src/main/java/com/songoda/epicfarming/database/DataManager.java +++ b/src/main/java/com/songoda/epicfarming/database/DataManager.java @@ -155,6 +155,7 @@ public class DataManager extends DataManagerAbstract { statement.executeBatch(); } }); + farm.setNeedsToBeSaved(false); } public void getFarms(Consumer> callback) { diff --git a/src/main/java/com/songoda/epicfarming/farming/Farm.java b/src/main/java/com/songoda/epicfarming/farming/Farm.java index 8f026d0..bc1a6fb 100644 --- a/src/main/java/com/songoda/epicfarming/farming/Farm.java +++ b/src/main/java/com/songoda/epicfarming/farming/Farm.java @@ -35,6 +35,8 @@ public class Farm { // Id for database usage. private int id; + private boolean needsToBeSaved = false; + private static final Random random = new Random(); private final List cachedCrops = new ArrayList<>(); private final List items = new ArrayList<>(); @@ -191,6 +193,7 @@ public class Farm { // Should be used in sync. public void addItem(ItemStack toAdd) { + needsToBeSaved = true; synchronized (items) { for (ItemStack item : new ArrayList<>(items)) { if (item.getType() != toAdd.getType() @@ -207,6 +210,7 @@ public class Farm { } public void removeMaterial(Material material, int amount) { + needsToBeSaved = true; synchronized (items) { for (ItemStack item : getItems().toArray(new ItemStack[0])) { if (material == item.getType()) { @@ -238,6 +242,7 @@ public class Farm { } public void setItems(List items) { + needsToBeSaved = true; synchronized (this.items) { this.items.clear(); this.items.addAll(items); @@ -356,4 +361,12 @@ public class Farm { public void setId(int id) { this.id = id; } + + public boolean needsToBeSaved() { + return needsToBeSaved; + } + + public void setNeedsToBeSaved(boolean needsToBeSaved) { + this.needsToBeSaved = needsToBeSaved; + } } From 19710bcb68ef03857b79790566d711fa40018fa4 Mon Sep 17 00:00:00 2001 From: Fernando Pettinelli Date: Wed, 22 Dec 2021 01:31:24 -0300 Subject: [PATCH 4/6] Updated plugin.yml to include DecentHolograms. --- src/main/resources/plugin.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index e130165..86968a4 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,7 +2,7 @@ name: EpicFarming description: EpicFarming main: com.songoda.epicfarming.EpicFarming version: maven-version-number -softdepend: [FabledSkyBlock, Arconix, SkyBlock, Towny, RedProtect, Kingdoms, PlotSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, PlaceholderAPI, Vault, PlayerPoints, Reserve, StackMob, UltimateStacker, WildStacker] +softdepend: [FabledSkyBlock, Arconix, SkyBlock, Towny, RedProtect, Kingdoms, PlotSquared, GriefPrevention, USkyBlock, ASkyBlock, WorldGuard, Factions, PlaceholderAPI, Vault, PlayerPoints, Reserve, StackMob, UltimateStacker, WildStacker, DecentHolograms] author: Songoda api-version: 1.13 commands: From 6a996f9ae8aaee5a4ed464b06d29e84c80b93add Mon Sep 17 00:00:00 2001 From: Fernando Pettinelli Date: Wed, 22 Dec 2021 01:32:52 -0300 Subject: [PATCH 5/6] Removed a variable that is no longer needed. --- src/main/java/com/songoda/epicfarming/EpicFarming.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/songoda/epicfarming/EpicFarming.java b/src/main/java/com/songoda/epicfarming/EpicFarming.java index 0f24f90..a492bff 100644 --- a/src/main/java/com/songoda/epicfarming/EpicFarming.java +++ b/src/main/java/com/songoda/epicfarming/EpicFarming.java @@ -71,7 +71,6 @@ public class EpicFarming extends SongodaPlugin { private static EpicFarming INSTANCE; - private final Config dataConfig = new Config(this, "data.yml"); private final Config levelsFile = new Config(this, "levels.yml"); private final GuiManager guiManager = new GuiManager(this); From 6b42f6b0c4c3101b44604a68db74e54f526dce7f Mon Sep 17 00:00:00 2001 From: Fernando Pettinelli Date: Wed, 22 Dec 2021 01:33:27 -0300 Subject: [PATCH 6/6] Version 3.2.0 --- pom.xml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index ec56455..1a775e6 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.songoda EpicFarming - 3.1.4 + 3.2.0 clean install @@ -117,20 +117,21 @@ org.spigotmc spigot - 1.17 + 1.18 + provided com.songoda SongodaCore - LATEST + 2.6.9 compile com.songoda skyblock - 2.2.13 + 2.3.30