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