mirror of
https://github.com/songoda/EpicFarming.git
synced 2024-11-05 18:39:49 +01:00
Merge branch 'development' of gitlab.com:Songoda/epicfarming into development
This commit is contained in:
commit
45c4de0648
@ -14,7 +14,7 @@ build:
|
||||
- find $path/ -type f -name "*.yml" -print0 | xargs -0 sed -i -e s/maven-version-number/$version/g
|
||||
- mvn clean package
|
||||
- find $path/ -depth -path '*original*' -delete
|
||||
- mv $path/$name-Plugin/target/*.jar $path/
|
||||
- mv $path/target/*.jar $path/
|
||||
artifacts:
|
||||
name: $name-$version
|
||||
paths:
|
||||
|
@ -200,7 +200,8 @@ public class EpicFarming extends SongodaPlugin {
|
||||
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);
|
||||
int pages = levels.getInt("Pages", 1);
|
||||
levelManager.addLevel(level, costExperiance, costEconomy, speedMultiplier, radius, autoHarvest, autoReplant, autoBreeding, pages);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,7 +183,7 @@ public class Farm {
|
||||
}
|
||||
|
||||
public boolean willFit(ItemStack item) {
|
||||
if (items.size() < 27) return true;
|
||||
if (items.size() < 27 * level.getPages()) return true;
|
||||
|
||||
for (ItemStack stack : items) {
|
||||
if (stack.isSimilar(item) && stack.getAmount() < stack.getMaxStackSize()) {
|
||||
|
@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
public class Level {
|
||||
|
||||
private int level, costExperiance, costEconomy, radius;
|
||||
private int level, costExperiance, costEconomy, radius, pages;
|
||||
|
||||
private double speedMultiplier;
|
||||
|
||||
@ -15,7 +15,7 @@ public class Level {
|
||||
|
||||
private List<String> description = new ArrayList<>();
|
||||
|
||||
Level(int level, int costExperiance, int costEconomy, double speedMultiplier, int radius, boolean autoHarvest, boolean autoReplant, boolean autoBreeding) {
|
||||
Level(int level, int costExperiance, int costEconomy, double speedMultiplier, int radius, boolean autoHarvest, boolean autoReplant, boolean autoBreeding, int pages) {
|
||||
this.level = level;
|
||||
this.costExperiance = costExperiance;
|
||||
this.costEconomy = costEconomy;
|
||||
@ -24,6 +24,7 @@ public class Level {
|
||||
this.autoHarvest = autoHarvest;
|
||||
this.autoReplant = autoReplant;
|
||||
this.autoBreeding = autoBreeding;
|
||||
this.pages = pages;
|
||||
|
||||
EpicFarming instance = EpicFarming.getInstance();
|
||||
|
||||
@ -45,6 +46,10 @@ public class Level {
|
||||
description.add(instance.getLocale().getMessage("interface.button.autobreeding")
|
||||
.processPlaceholder("status", autoBreeding).getMessage());
|
||||
|
||||
if (pages > 1)
|
||||
description.add(instance.getLocale().getMessage("interface.button.pages")
|
||||
.processPlaceholder("amount", pages).getMessage());
|
||||
|
||||
}
|
||||
|
||||
public List<String> getDescription() {
|
||||
@ -71,6 +76,10 @@ public class Level {
|
||||
return autoBreeding;
|
||||
}
|
||||
|
||||
public int getPages() {
|
||||
return pages;
|
||||
}
|
||||
|
||||
public double getSpeedMultiplier() {
|
||||
return speedMultiplier;
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ public class LevelManager {
|
||||
|
||||
private final NavigableMap<Integer, Level> registeredLevels = new TreeMap<>();
|
||||
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, double speedMultiplier, int radius, boolean autoHarvest, boolean autoReplant, boolean autobreeding) {
|
||||
registeredLevels.put(level, new Level(level, costExperiance, costEconomy, speedMultiplier, radius, autoHarvest, autoReplant, autobreeding));
|
||||
public void addLevel(int level, int costExperiance, int costEconomy, double speedMultiplier, int radius, boolean autoHarvest, boolean autoReplant, boolean autobreeding, int pages) {
|
||||
registeredLevels.put(level, new Level(level, costExperiance, costEconomy, speedMultiplier, radius, autoHarvest, autoReplant, autobreeding, pages));
|
||||
}
|
||||
|
||||
public Level getLevel(int level) {
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.songoda.epicfarming.gui;
|
||||
|
||||
import com.songoda.core.compatibility.CompatibleMaterial;
|
||||
import com.songoda.core.gui.Gui;
|
||||
import com.songoda.core.gui.GuiUtils;
|
||||
import com.songoda.epicfarming.EpicFarming;
|
||||
@ -12,7 +13,6 @@ import com.songoda.epicfarming.utils.Methods;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
|
||||
@ -36,10 +36,6 @@ public class OverviewGui extends Gui {
|
||||
this.setAcceptsItems(true);
|
||||
this.setUnlockedRange(3, 0, 5, 8);
|
||||
|
||||
constructGUI();
|
||||
}
|
||||
|
||||
private void constructGUI() {
|
||||
ItemStack glass1 = GuiUtils.getBorderItem(Setting.GLASS_TYPE_1.getMaterial());
|
||||
ItemStack glass2 = GuiUtils.getBorderItem(Setting.GLASS_TYPE_2.getMaterial());
|
||||
ItemStack glass3 = GuiUtils.getBorderItem(Setting.GLASS_TYPE_3.getMaterial());
|
||||
@ -62,8 +58,20 @@ public class OverviewGui extends Gui {
|
||||
GuiUtils.mirrorFill(this, 2, 3, false, true, glass1);
|
||||
GuiUtils.mirrorFill(this, 2, 4, false, false, glass1);
|
||||
|
||||
Level nextLevel = plugin.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? plugin.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
// enable page events
|
||||
if (level.getPages() > 1) {
|
||||
this.pages = level.getPages();
|
||||
setPrevPage(2, 0, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("general.interface.previous").getMessage()));
|
||||
setNextPage(2, 8, GuiUtils.createButtonItem(CompatibleMaterial.ARROW, plugin.getLocale().getMessage("general.interface.next").getMessage()));
|
||||
setOnPage((event) -> updateInventory());
|
||||
}
|
||||
|
||||
showPage();
|
||||
}
|
||||
|
||||
private void showPage() {
|
||||
|
||||
Level nextLevel = plugin.getLevelManager().getHighestLevel().getLevel() > level.getLevel() ? plugin.getLevelManager().getLevel(level.getLevel() + 1) : null;
|
||||
|
||||
ItemStack item = new ItemStack(Material.valueOf(plugin.getConfig().getString("Main.Farm Block Material")), 1);
|
||||
ItemMeta itemmeta = item.getItemMeta();
|
||||
@ -132,35 +140,42 @@ public class OverviewGui extends Gui {
|
||||
farm.view(player, true);
|
||||
});
|
||||
}
|
||||
|
||||
// events
|
||||
this.setOnOpen((event) -> updateInventory());
|
||||
this.setDefaultAction((event) ->
|
||||
Bukkit.getScheduler().runTaskLater(plugin, this::updateFarm, 0L));
|
||||
this.setOnClose((event) -> farm.close());
|
||||
|
||||
updateInventory();
|
||||
}
|
||||
|
||||
public void updateInventory() {
|
||||
int j = (page - 1) * 27;
|
||||
for (int i = 27; i <= 54; i++) {
|
||||
if (farm.getItems().size() <= (i - 27))
|
||||
if (farm.getItems().size() <= (j))
|
||||
setItem(i, null);
|
||||
else
|
||||
setItem(i, farm.getItems().get(i - 27));
|
||||
setItem(i, farm.getItems().get(j));
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateFarm() {
|
||||
List<ItemStack> items = new ArrayList<>();
|
||||
for (int i = 27; i <= 54; i++) {
|
||||
ItemStack item = getItem(i);
|
||||
if (item == null || item.getType() == Material.AIR) continue;
|
||||
items.add(item);
|
||||
int start = 27 * (page - 1);
|
||||
int j = 27;
|
||||
for (int i = 0; i <= 27 * pages; i++) {
|
||||
if (i > start && i < start + 27) {
|
||||
ItemStack item = getItem(j);
|
||||
j ++;
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
items.add(item);
|
||||
} else {
|
||||
if (i > farm.getItems().size())
|
||||
continue;
|
||||
items.add(farm.getItems().get(i));
|
||||
}
|
||||
}
|
||||
farm.setItems(items);
|
||||
}
|
||||
|
||||
public Inventory getInventory() {
|
||||
return inventory;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
general.nametag.prefix = "&8[&6EpicFarming&8]"
|
||||
general.nametag.farm = "&eLevel %level% &fFarm"
|
||||
general.nametag.lore = ""
|
||||
general.interface.next = "Next"
|
||||
general.interface.previous = "Previous"
|
||||
|
||||
#Interface Messages
|
||||
|
||||
@ -16,6 +18,7 @@ interface.button.speed = "&7Speed: &6%speed%x"
|
||||
interface.button.autoharvest = "&7Auto Harvest: &6%status%"
|
||||
interface.button.autoreplant = "&7Auto Replant: &6%status%"
|
||||
interface.button.autobreeding = "&7Auto Breeding: &6%status%"
|
||||
interface.button.pages = "&7Pages: &6%amount%"
|
||||
interface.button.boostedstats = "&a&lCurrently boosted!|&7Yield rate multiplied by &6%amount%x&7.|&7Expires in &6%time%&7."
|
||||
|
||||
#Command Messages
|
||||
|
@ -23,6 +23,7 @@ Level-4:
|
||||
Auto-Harvest: true
|
||||
Auto-Replant: true
|
||||
Auto-Breeding: true
|
||||
Pages: 2
|
||||
Cost-xp: 30
|
||||
Cost-eco: 10000
|
||||
Level-5:
|
||||
@ -31,6 +32,7 @@ Level-5:
|
||||
Auto-Harvest: true
|
||||
Auto-Replant: true
|
||||
Auto-Breeding: true
|
||||
Pages: 2
|
||||
Cost-xp: 35
|
||||
Cost-eco: 12000
|
||||
Level-6:
|
||||
@ -39,5 +41,6 @@ Level-6:
|
||||
Auto-Harvest: true
|
||||
Auto-Replant: true
|
||||
Auto-Breeding: true
|
||||
Pages: 2
|
||||
Cost-xp: 40
|
||||
Cost-eco: 25000
|
Loading…
Reference in New Issue
Block a user