├── src
└── main
│ ├── resources
│ ├── player_emc.yml
│ ├── block_storage.yml
│ ├── learned_items.yml
│ ├── condensation_chests.yml
│ ├── dissolution_chests.yml
│ ├── plugin.yml
│ └── config.yml
│ └── java
│ └── io
│ └── github
│ └── sefiraat
│ └── equivalencytech
│ ├── runnables
│ ├── RunnableSave.java
│ ├── ManagerRunnables.java
│ └── RunnableEQTick.java
│ ├── configuration
│ ├── ConfigBooleans.java
│ ├── ConfigEMC.java
│ ├── ConfigStrings.java
│ └── ConfigMain.java
│ ├── item
│ ├── EQSlimefunItem.java
│ ├── builders
│ │ ├── DissolutionChest.java
│ │ ├── DarkMatter.java
│ │ ├── RedMatter.java
│ │ ├── MobiusFuel.java
│ │ ├── CondensatorChest.java
│ │ ├── AeternalisFuel.java
│ │ ├── AlchemicalCoal.java
│ │ └── TransmutationOrb.java
│ └── EQItems.java
│ ├── listeners
│ ├── BlockPlaceListener.java
│ ├── PlayerJoinListener.java
│ ├── ManagerEvents.java
│ ├── OrbOpenListener.java
│ ├── CraftListener.java
│ └── ChestPlaceListener.java
│ ├── misc
│ ├── ManagerSupportedPlugins.java
│ ├── Utils.java
│ └── SlimefunEQAddon.java
│ ├── statics
│ ├── SkullTextures.java
│ ├── DebugLogs.java
│ ├── Messages.java
│ └── ContainerStorage.java
│ ├── EquivalencyTech.java
│ ├── gui
│ ├── GUIItems.java
│ └── GuiTransmutationOrb.java
│ ├── commands
│ └── Commands.java
│ └── recipes
│ ├── Recipes.java
│ └── EmcDefinitions.java
├── .idea
├── .gitignore
├── discord.xml
├── vcs.xml
├── encodings.xml
├── compiler.xml
├── misc.xml
├── jarRepositories.xml
└── uiDesigner.xml
├── renovate.json
├── .github
├── FUNDING.yml
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ └── maven.yml
├── images
├── wiki
│ ├── logo_large.png
│ ├── logo_small.png
│ ├── wiki_gui_main.png
│ ├── wiki_craft_orb.png
│ ├── wiki_craft_red.png
│ ├── wiki_eco_hopper.png
│ ├── wiki_gui_input.png
│ ├── logo_white_large.png
│ ├── wiki_craft_mobius.png
│ ├── wiki_gui_emc_item.png
│ ├── wiki_gui_emcinput.png
│ ├── wiki_gui_emcplayer.png
│ ├── wiki_gui_emcvalue.png
│ ├── wiki_gui_knowledge.png
│ ├── logo_small_icon_only.png
│ ├── wiki_gui_emcwithdraw.png
│ ├── wiki_craft_aeternalis.png
│ ├── wiki_craft_alchemical.png
│ ├── wiki_craft_darkmatter.png
│ ├── wiki_craft_condensatorchest.png
│ ├── wiki_craft_dissolutionchest.png
│ └── logo_small_icon_only_inverted.png
└── storefront
│ └── learn_item.gif
├── EquivalencyTech.iml
├── README.md
├── dependency-reduced-pom.xml
└── pom.xml
/src/main/resources/player_emc.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/block_storage.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/learned_items.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/condensation_chests.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/main/resources/dissolution_chests.yml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/renovate.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": [
3 | "config:base"
4 | ]
5 | }
6 |
--------------------------------------------------------------------------------
/.github/FUNDING.yml:
--------------------------------------------------------------------------------
1 | # These are supported funding model platforms
2 |
3 | github: [Sefiraat]
4 |
--------------------------------------------------------------------------------
/images/wiki/logo_large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/logo_large.png
--------------------------------------------------------------------------------
/images/wiki/logo_small.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/logo_small.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_main.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_main.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_orb.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_orb.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_red.png
--------------------------------------------------------------------------------
/images/wiki/wiki_eco_hopper.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_eco_hopper.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_input.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_input.png
--------------------------------------------------------------------------------
/images/storefront/learn_item.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/storefront/learn_item.gif
--------------------------------------------------------------------------------
/images/wiki/logo_white_large.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/logo_white_large.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_mobius.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_mobius.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_emc_item.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_emc_item.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_emcinput.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_emcinput.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_emcplayer.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_emcplayer.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_emcvalue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_emcvalue.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_knowledge.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_knowledge.png
--------------------------------------------------------------------------------
/images/wiki/logo_small_icon_only.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/logo_small_icon_only.png
--------------------------------------------------------------------------------
/images/wiki/wiki_gui_emcwithdraw.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_gui_emcwithdraw.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_aeternalis.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_aeternalis.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_alchemical.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_alchemical.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_darkmatter.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_darkmatter.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_condensatorchest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_condensatorchest.png
--------------------------------------------------------------------------------
/images/wiki/wiki_craft_dissolutionchest.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/wiki_craft_dissolutionchest.png
--------------------------------------------------------------------------------
/images/wiki/logo_small_icon_only_inverted.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Sefiraat/EquivalencyTech/HEAD/images/wiki/logo_small_icon_only_inverted.png
--------------------------------------------------------------------------------
/.idea/discord.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: "[Suggestion]"
5 | labels: Suggestion
6 | assignees: ''
7 |
8 | ---
9 |
10 | **What would you like added to EquiTech?**
11 |
12 | **Does not having this cause an issue?**
13 |
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: EquivalencyTech
2 | version: ${project.version}
3 | main: io.github.sefiraat.equivalencytech.EquivalencyTech
4 | api-version: 1.16
5 | softdepend:
6 | - Slimefun
7 | permissions:
8 | equitech.admin:
9 | description: Allows access to /et
10 | equitech.bypass:
11 | description: Can open/interact with EMC objects owned by other players
--------------------------------------------------------------------------------
/EquivalencyTech.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | SPIGOT
8 | PAPER
9 | ADVENTURE
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug Report
3 | about: Bug Report
4 | title: "[Issue]"
5 | labels: bug
6 | assignees: ''
7 |
8 | ---
9 |
10 | ## Description (Mandatory)
11 |
12 | ## What caused the issue, what steps led up to the issue (Mandatory)
13 |
14 |
15 | ## Log of error, if applicable
16 |
17 | ## Server Type and version (Spigot/Paper etc.)
18 |
19 | ## Minecraft version
20 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | name: Java CI
2 |
3 | on:
4 | push:
5 | branches:
6 | - master
7 | - dev
8 | pull_request:
9 | branches:
10 | - master
11 |
12 | jobs:
13 | build:
14 |
15 | runs-on: ubuntu-latest
16 |
17 | steps:
18 | - uses: actions/checkout@v2.4.0
19 | - name: Set up JDK 8
20 | uses: actions/setup-java@v2.5.0
21 | with:
22 | java-version: 8
23 | distribution: adopt
24 | - name: Build with Maven
25 | run: mvn package --file pom.xml
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/runnables/RunnableSave.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.runnables;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import org.bukkit.scheduler.BukkitRunnable;
5 |
6 | public class RunnableSave extends BukkitRunnable {
7 |
8 | public final EquivalencyTech plugin;
9 |
10 | public RunnableSave(EquivalencyTech plugin) {
11 | this.plugin = plugin;
12 | }
13 |
14 | @Override
15 | public void run() {
16 | plugin.getConfigMainClass().saveAdditionalConfigs();
17 | }
18 | }
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/configuration/ConfigBooleans.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.configuration;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import org.bukkit.configuration.file.FileConfiguration;
5 |
6 | public final class ConfigBooleans {
7 |
8 | FileConfiguration configuration;
9 |
10 | public boolean getDebuggingLogs() {
11 | return configuration.getBoolean("DEBUG.SHOW_DEBUGGING_LOGS");
12 | }
13 | public boolean getEMC2DisableWarning() {return configuration.getBoolean("DISABLE_EMC2_WARNING");}
14 |
15 | public ConfigBooleans(EquivalencyTech plugin) {
16 | configuration = plugin.getConfig();
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/EQSlimefunItem.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item;
2 |
3 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
5 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
6 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
7 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotConfigurable;
8 | import io.github.thebusybiscuit.slimefun4.core.attributes.NotPlaceable;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | public class EQSlimefunItem extends SlimefunItem implements NotPlaceable, NotConfigurable {
12 |
13 | public EQSlimefunItem(ItemGroup category, SlimefunItemStack item, RecipeType recipeType, ItemStack[] recipe) {
14 | super(category, item, recipeType, recipe);
15 | setUseableInWorkbench(true);
16 | }
17 |
18 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/runnables/ManagerRunnables.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.runnables;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 |
5 | public class ManagerRunnables {
6 |
7 | private final EquivalencyTech plugin;
8 |
9 | private RunnableSave runnableSave;
10 | private RunnableEQTick runnableEQTick;
11 |
12 | public RunnableSave getRunnableSave() {
13 | return runnableSave;
14 | }
15 |
16 | public RunnableEQTick getRunnableEQTick() {
17 | return runnableEQTick;
18 | }
19 |
20 | public ManagerRunnables(EquivalencyTech plugin) {
21 | this.plugin = plugin;
22 | setupRunnables();
23 | }
24 |
25 | private void setupRunnables() {
26 |
27 | runnableSave = new RunnableSave(plugin);
28 | runnableSave.runTaskTimer(plugin, 0, 100L);
29 |
30 | runnableEQTick = new RunnableEQTick(plugin);
31 | runnableEQTick.runTaskTimer(plugin, 0, 20L);
32 |
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/listeners/BlockPlaceListener.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.listeners;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
5 | import org.bukkit.Material;
6 | import org.bukkit.event.EventHandler;
7 | import org.bukkit.event.EventPriority;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.block.BlockPlaceEvent;
10 |
11 | public class BlockPlaceListener implements Listener {
12 |
13 | private final EquivalencyTech plugin;
14 |
15 | public BlockPlaceListener(EquivalencyTech plugin) {
16 | this.plugin = plugin;
17 | plugin.getServer().getPluginManager().registerEvents(this, plugin);
18 | }
19 |
20 | @EventHandler(priority = EventPriority.LOWEST)
21 | public void onChestPlace(BlockPlaceEvent e) {
22 | if (ContainerStorage.isCraftable(e.getItemInHand(), plugin) && e.getItemInHand().getType() != Material.CHEST) {
23 | e.setCancelled(true);
24 | }
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/misc/ManagerSupportedPlugins.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.misc;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 |
5 |
6 | public class ManagerSupportedPlugins {
7 |
8 | private final EquivalencyTech plugin;
9 |
10 | private boolean isInstalledSlimefun;
11 | private boolean isInstalledEMC2;
12 | private SlimefunEQAddon slimefunAddon;
13 |
14 | public boolean isInstalledSlimefun() {
15 | return isInstalledSlimefun;
16 | }
17 |
18 | public boolean isInstalledEMC2() {
19 | return isInstalledEMC2;
20 | }
21 |
22 | public SlimefunEQAddon getSlimefunAddon() {
23 | return slimefunAddon;
24 | }
25 |
26 | public ManagerSupportedPlugins(EquivalencyTech plugin) {
27 | this.plugin = plugin;
28 | slimefun();
29 | emc2();
30 | }
31 |
32 | private void slimefun() {
33 | isInstalledSlimefun = plugin.getServer().getPluginManager().isPluginEnabled("Slimefun");
34 | if (isInstalledSlimefun) {
35 | slimefunAddon = new SlimefunEQAddon(plugin);
36 | }
37 | }
38 |
39 | private void emc2() {
40 | isInstalledEMC2 = plugin.getServer().getPluginManager().isPluginEnabled("EMC2");
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/listeners/PlayerJoinListener.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.listeners;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.statics.Messages;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.EventPriority;
7 | import org.bukkit.event.Listener;
8 | import org.bukkit.event.player.PlayerJoinEvent;
9 |
10 | import javax.annotation.Nonnull;
11 |
12 | public class PlayerJoinListener implements Listener {
13 |
14 | private final EquivalencyTech plugin;
15 |
16 | public PlayerJoinListener(@Nonnull EquivalencyTech plugin) {
17 | plugin.getServer().getPluginManager().registerEvents(this, plugin);
18 | this.plugin = plugin;
19 | }
20 |
21 | @EventHandler(priority = EventPriority.HIGH)
22 | public void onPlayerJoin(PlayerJoinEvent e) {
23 | emc2Warning(e);
24 | }
25 |
26 | private void emc2Warning(PlayerJoinEvent e) {
27 | if (plugin.getManagerSupportedPlugins().isInstalledEMC2() && (e.getPlayer().isOp() || e.getPlayer().hasPermission("equitech.admin"))) {
28 | if (!plugin.getConfigMainClass().getBools().getEMC2DisableWarning()) {
29 | for (String s : Messages.messageEMC2Installed(plugin)) {
30 | e.getPlayer().sendMessage(s);
31 | }
32 | }
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/listeners/ManagerEvents.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.listeners;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 |
5 | public class ManagerEvents {
6 |
7 | private final OrbOpenListener orbOpenListener;
8 | private final CraftListener craftListener;
9 | private final PlayerJoinListener playerJoinListener;
10 | private final ChestPlaceListener chestPlaceListener;
11 | private final BlockPlaceListener blockPlaceListener;
12 |
13 | public OrbOpenListener getOrbOpenListener() {
14 | return orbOpenListener;
15 | }
16 |
17 | public CraftListener getCraftListener() {
18 | return craftListener;
19 | }
20 |
21 | public ChestPlaceListener getChestPlaceListener() {
22 | return chestPlaceListener;
23 | }
24 |
25 | public PlayerJoinListener getPlayerJoinListener() {
26 | return playerJoinListener;
27 | }
28 |
29 | public BlockPlaceListener getBlockPlaceListener() {
30 | return blockPlaceListener;
31 | }
32 |
33 | public ManagerEvents(EquivalencyTech plugin) {
34 | orbOpenListener = new OrbOpenListener(plugin);
35 | craftListener = new CraftListener(plugin);
36 | playerJoinListener = new PlayerJoinListener(plugin);
37 | chestPlaceListener = new ChestPlaceListener(plugin);
38 | blockPlaceListener = new BlockPlaceListener(plugin);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/configuration/ConfigEMC.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.configuration;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import org.bukkit.configuration.ConfigurationSection;
5 | import org.bukkit.configuration.file.FileConfiguration;
6 |
7 | import java.util.HashMap;
8 | import java.util.Map;
9 |
10 | public class ConfigEMC {
11 |
12 | private final FileConfiguration configuration;
13 |
14 | public Map getEmcBaseValues() {
15 | Map h = new HashMap<>();
16 | ConfigurationSection c = configuration.getConfigurationSection("EMC_VALUES.BASE");
17 | assert c != null;
18 | for (String s : c.getKeys(false)) {
19 | Double emcValue = c.getDouble(s);
20 | h.put(s, emcValue);
21 | }
22 | return h;
23 | }
24 |
25 | public Map getEmcSlimefunValues() {
26 | Map h = new HashMap<>();
27 | ConfigurationSection c = configuration.getConfigurationSection("EMC_VALUES.SLIMEFUN");
28 | assert c != null;
29 | for (String s : c.getKeys(false)) {
30 | Double emcValue = c.getDouble(s);
31 | h.put(s, emcValue);
32 | }
33 | return h;
34 | }
35 |
36 | public int getBurnRate() {
37 | return configuration.getInt("EMC_VALUES.BURN_RATE");
38 | }
39 |
40 | public ConfigEMC(EquivalencyTech plugin) {
41 | configuration = plugin.getConfig();
42 | }
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/listeners/OrbOpenListener.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.listeners;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.gui.GuiTransmutationOrb;
5 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.EventPriority;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.block.Action;
11 | import org.bukkit.event.player.PlayerInteractEvent;
12 | import org.bukkit.inventory.ItemStack;
13 |
14 | import javax.annotation.Nonnull;
15 |
16 | public class OrbOpenListener implements Listener {
17 |
18 | private final EquivalencyTech plugin;
19 |
20 | public OrbOpenListener(@Nonnull EquivalencyTech plugin) {
21 | plugin.getServer().getPluginManager().registerEvents(this, plugin);
22 | this.plugin = plugin;
23 | }
24 |
25 | @EventHandler(priority = EventPriority.HIGH)
26 | public void onClick(PlayerInteractEvent e) {
27 | if (e.getItem() != null && e.getItem().getItemMeta() != null && (e.getAction().equals(Action.RIGHT_CLICK_AIR) || e.getAction().equals(Action.RIGHT_CLICK_BLOCK))) {
28 | Player player = e.getPlayer();
29 | ItemStack i = e.getItem();
30 | if (ContainerStorage.isTransmutationOrb(i, plugin)) {
31 | e.setCancelled(true);
32 | GuiTransmutationOrb gui = GuiTransmutationOrb.buildGui(plugin, player);
33 | gui.open(player);
34 | }
35 | }
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/DissolutionChest.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
5 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
6 | import io.github.sefiraat.equivalencytech.statics.Messages;
7 | import org.bukkit.Material;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.meta.ItemMeta;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class DissolutionChest {
15 |
16 | private final ItemStack item;
17 | private final EquivalencyTech plugin;
18 |
19 | public ItemStack getItemClone() {
20 | return item.clone();
21 | }
22 | public ItemStack getItem() {
23 | return item;
24 | }
25 |
26 | public EquivalencyTech getPlugin() {
27 | return plugin;
28 | }
29 |
30 | public DissolutionChest(EquivalencyTech plugin) {
31 |
32 | this.plugin = plugin;
33 |
34 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
35 |
36 | item = new ItemStack(Material.CHEST);
37 | ItemMeta im = item.getItemMeta();
38 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemDissolutionChestName());
39 | List lore = new ArrayList<>();
40 | for (String s : c.getItemDissolutionChestLore()) {
41 | lore.add(Messages.THEME_PASSIVE_GRAY + s);
42 | }
43 | im.setLore(lore);
44 | item.setItemMeta(im);
45 |
46 | ContainerStorage.setItemID(item, plugin,"DCHEST");
47 | ContainerStorage.makeDisChest(item, plugin);
48 | ContainerStorage.makeCraftable(item, plugin);
49 |
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/DarkMatter.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
9 | import net.md_5.bungee.api.ChatColor;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.meta.ItemMeta;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class DarkMatter {
17 |
18 | private final ItemStack item;
19 | private final EquivalencyTech plugin;
20 |
21 | public ItemStack getItemClone() {
22 | return item.clone();
23 | }
24 |
25 | public ItemStack getItem() {
26 | return item;
27 | }
28 |
29 | public EquivalencyTech getPlugin() {
30 | return plugin;
31 | }
32 |
33 | public DarkMatter(EquivalencyTech plugin) {
34 |
35 | this.plugin = plugin;
36 |
37 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
38 |
39 | item = SkullCreator. itemFromBase64(SkullTextures.ITEM_DARK_MATTER);
40 | ItemMeta im = item.getItemMeta();
41 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemDarkMatterName());
42 | List lore = new ArrayList<>();
43 | lore.add("");
44 | lore.add(ChatColor.GRAY + c.getGeneralCraftingItem());
45 | im.setLore(lore);
46 | item.setItemMeta(im);
47 |
48 | ContainerStorage.setItemID(item, plugin,"DMATTER");
49 | ContainerStorage.makeDarkMatter(item, plugin);
50 | ContainerStorage.makeCraftable(item, plugin);
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/RedMatter.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
9 | import net.md_5.bungee.api.ChatColor;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.meta.ItemMeta;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class RedMatter {
17 |
18 | private final ItemStack item;
19 | private final EquivalencyTech plugin;
20 |
21 | public ItemStack getItemClone() {
22 | return item.clone();
23 | }
24 |
25 | public ItemStack getItem() {
26 | return item;
27 | }
28 |
29 | public EquivalencyTech getPlugin() {
30 | return plugin;
31 | }
32 |
33 | public RedMatter(EquivalencyTech plugin) {
34 |
35 | this.plugin = plugin;
36 |
37 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
38 |
39 | item = SkullCreator. itemFromBase64(SkullTextures.ITEM_RED_MATTER);
40 | ItemMeta im = item.getItemMeta();
41 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemRedMatterName());
42 | List lore = new ArrayList<>();
43 | lore.add("");
44 | lore.add(ChatColor.GRAY + c.getGeneralCraftingItem());
45 | im.setLore(lore);
46 | item.setItemMeta(im);
47 |
48 | ContainerStorage.setItemID(item, plugin,"RMATTER");
49 | ContainerStorage.makeRedMatter(item, plugin);
50 | ContainerStorage.makeCraftable(item, plugin);
51 |
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/statics/SkullTextures.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.statics;
2 |
3 | public final class SkullTextures {
4 |
5 | private SkullTextures() {
6 | throw new IllegalStateException("Utility class");
7 | }
8 |
9 | public static final String ITEM_TRANSMUTATION_ORB = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjNhMWYwZGZiZjQ2NjQxMmJjMWVmZjY1ZjhlOGZhYTM5NzEyZDQ3YmY5ZmNjMDdhNmE2NGZmODBmZWJjYzljNiJ9fX0=";
10 | public static final String GUI_INFO_ALL = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMTY0MzlkMmUzMDZiMjI1NTE2YWE5YTZkMDA3YTdlNzVlZGQyZDUwMTVkMTEzYjQyZjQ0YmU2MmE1MTdlNTc0ZiJ9fX0=";
11 |
12 | public static final String ITEM_ALCHEMICAL_COAL = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNmFiZWMyNDBhNGNiNTFjYWRjMTg1YTY2MDcyYTJhZWQ3ZjU2MTEyNjk2ZjI0NjU3M2E1MmVlN2RmNGMzMiJ9fX0=";
13 | public static final String ITEM_MOBIUS_FUEL = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjA3ZjI1M2I3MGU1MTUzY2M3M2NjNDgyZTEzYzU5NTE1OWQwNmZkZDhmNTlkNjJiZDExMDI0MTZhZjlkMTU1YiJ9fX0=";
14 | public static final String ITEM_AETERNALIS_FUEL = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTU3NTJjOGY0MjIwZTJiM2UzOTc1NTU2ODQ1NDYwNjEzYWFlYjRkYjBjNjRiYTFjZTk2ZmFiZjNkNmVjMzVkYyJ9fX0=";
15 | public static final String ITEM_DARK_MATTER = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTdjNDAzNmY4MGJmMzYwOTE4MGM3YzRhOTU2ODg1M2ZkODE1ZjE1NGFkODQzOGI5MmYzODUxMDE5ODM1YjA3MCJ9fX0=";
16 | public static final String ITEM_RED_MATTER = "eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOTJjMmY2ZmE3ZWM1MzA0MzVjNDMxNTcyOTM4YjlmZWI5NTljNDIyOThlNTU1NDM0MDI2M2M2NTI3MSJ9fX0=";
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/MobiusFuel.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
9 | import net.md_5.bungee.api.ChatColor;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.meta.ItemMeta;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class MobiusFuel {
17 |
18 | private final ItemStack item;
19 | private final EquivalencyTech plugin;
20 |
21 | public ItemStack getItemClone() {
22 | return item.clone();
23 | }
24 |
25 | public ItemStack getItem() {
26 | return item;
27 | }
28 |
29 | public EquivalencyTech getPlugin() {
30 | return plugin;
31 | }
32 |
33 | public MobiusFuel(EquivalencyTech plugin) {
34 |
35 | this.plugin = plugin;
36 |
37 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
38 |
39 | item = SkullCreator. itemFromBase64(SkullTextures.ITEM_MOBIUS_FUEL);
40 | ItemMeta im = item.getItemMeta();
41 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemMobiusFuelName());
42 | List lore = new ArrayList<>();
43 | lore.add("");
44 | lore.add(ChatColor.GRAY + c.getGeneralCraftingItem());
45 | im.setLore(lore);
46 | item.setItemMeta(im);
47 |
48 | ContainerStorage.setItemID(item, plugin,"COAL2");
49 | ContainerStorage.makeMobiusFuel(item, plugin);
50 | ContainerStorage.makeCraftable(item, plugin);
51 |
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/CondensatorChest.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
5 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
6 | import io.github.sefiraat.equivalencytech.statics.Messages;
7 | import org.bukkit.Material;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.inventory.meta.ItemMeta;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class CondensatorChest {
15 |
16 | private final ItemStack item;
17 | private final EquivalencyTech plugin;
18 |
19 | public ItemStack getItemClone() {
20 | return item.clone();
21 | }
22 | public ItemStack getItem() {
23 | return item;
24 | }
25 |
26 | public EquivalencyTech getPlugin() {
27 | return plugin;
28 | }
29 |
30 | public CondensatorChest(EquivalencyTech plugin) {
31 |
32 | this.plugin = plugin;
33 |
34 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
35 |
36 | item = new ItemStack(Material.CHEST);
37 | ItemMeta im = item.getItemMeta();
38 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemCondensatorChestName());
39 | List lore = new ArrayList<>();
40 | for (String s : c.getItemCondensatorChestLore()) {
41 | lore.add(Messages.THEME_PASSIVE_GRAY + s);
42 | }
43 | lore.add("");
44 | lore.add(Messages.THEME_CLICK_INSTRUCTION + c.getItemCondensatorChestSet());
45 | im.setLore(lore);
46 | item.setItemMeta(im);
47 |
48 | ContainerStorage.setItemID(item, plugin,"CCHEST");
49 | ContainerStorage.makeConChest(item, plugin);
50 | ContainerStorage.makeCraftable(item, plugin);
51 |
52 | }
53 | }
54 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/AeternalisFuel.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
9 | import net.md_5.bungee.api.ChatColor;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.meta.ItemMeta;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class AeternalisFuel {
17 |
18 | private final ItemStack item;
19 | private final EquivalencyTech plugin;
20 |
21 | public ItemStack getItemClone() {
22 | return item.clone();
23 | }
24 | public ItemStack getItem() {
25 | return item;
26 | }
27 |
28 | public EquivalencyTech getPlugin() {
29 | return plugin;
30 | }
31 |
32 | public AeternalisFuel(EquivalencyTech plugin) {
33 |
34 | this.plugin = plugin;
35 |
36 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
37 |
38 | item = SkullCreator. itemFromBase64(SkullTextures.ITEM_AETERNALIS_FUEL);
39 | ItemMeta im = item.getItemMeta();
40 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemAeternalisFuelName());
41 | List lore = new ArrayList<>();
42 | lore.add("");
43 | lore.add(ChatColor.GRAY + c.getGeneralCraftingItem());
44 | im.setLore(lore);
45 | item.setItemMeta(im);
46 |
47 | ContainerStorage.setItemID(item, plugin,"COAL3");
48 | ContainerStorage.makeAeternalisFuel(item, plugin);
49 | ContainerStorage.makeCraftable(item, plugin);
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/AlchemicalCoal.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
9 | import net.md_5.bungee.api.ChatColor;
10 | import org.bukkit.inventory.ItemStack;
11 | import org.bukkit.inventory.meta.ItemMeta;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class AlchemicalCoal {
17 |
18 | private final ItemStack item;
19 | private final EquivalencyTech plugin;
20 |
21 | public ItemStack getItemClone() {
22 | return item.clone();
23 | }
24 |
25 | public ItemStack getItem() {
26 | return item;
27 | }
28 |
29 | public EquivalencyTech getPlugin() {
30 | return plugin;
31 | }
32 |
33 | public AlchemicalCoal(EquivalencyTech plugin) {
34 |
35 | this.plugin = plugin;
36 |
37 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
38 |
39 | item = SkullCreator. itemFromBase64(SkullTextures.ITEM_ALCHEMICAL_COAL);
40 | ItemMeta im = item.getItemMeta();
41 | im.setDisplayName(Messages.THEME_ITEM_NAME_GENERAL + c.getItemAlchemicalCoalName());
42 | List lore = new ArrayList<>();
43 | lore.add("");
44 | lore.add(ChatColor.GRAY + c.getGeneralCraftingItem());
45 | im.setLore(lore);
46 | item.setItemMeta(im);
47 |
48 | ContainerStorage.setItemID(item, plugin,"COAL1");
49 | ContainerStorage.makeAlchemicalCoal(item, plugin);
50 | ContainerStorage.makeCraftable(item, plugin);
51 |
52 | }
53 |
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/builders/TransmutationOrb.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item.builders;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
9 | import org.bukkit.inventory.ItemStack;
10 | import org.bukkit.inventory.meta.ItemMeta;
11 |
12 | import java.util.ArrayList;
13 | import java.util.List;
14 |
15 | public class TransmutationOrb {
16 |
17 | private final ItemStack item;
18 | private final EquivalencyTech plugin;
19 |
20 | public ItemStack getItemClone() {
21 | return item.clone();
22 | }
23 |
24 | public ItemStack getItem() {
25 | return item;
26 | }
27 |
28 | public EquivalencyTech getPlugin() {
29 | return plugin;
30 | }
31 |
32 | public TransmutationOrb(EquivalencyTech plugin) {
33 |
34 | this.plugin = plugin;
35 |
36 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
37 |
38 | item = SkullCreator. itemFromBase64(SkullTextures.ITEM_TRANSMUTATION_ORB);
39 | ItemMeta im = item.getItemMeta();
40 | im.setDisplayName(Messages.THEME_EMC_PURPLE + c.getItemTransmutationOrbName());
41 | List lore = new ArrayList<>();
42 | for (String s : c.getItemTransmutationOrbLore()) {
43 | lore.add(Messages.THEME_PASSIVE_GRAY + s);
44 | }
45 | lore.add("");
46 | lore.add(Messages.THEME_CLICK_INSTRUCTION + c.getItemRightClickToOpen());
47 | im.setLore(lore);
48 | item.setItemMeta(im);
49 |
50 | ContainerStorage.setItemID(item, plugin,"TORB");
51 | ContainerStorage.makeTransmutationOrb(item, plugin);
52 | ContainerStorage.makeCraftable(item, plugin);
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | EquivalencyTech (EquiTech) is an attempt to recreate elements of the [ProjectE](https://www.curseforge.com/minecraft/mc-mods/projecte) mod.
5 |
6 | ## Download EquivalencyTech
7 |
8 | [](https://thebusybiscuit.github.io/builds/Sefiraat/EquivalencyTech/master)
9 |
10 | ## Features
11 | The plugin currently features:
12 | * EMC!
13 | * Turn any unwanted items into EMC
14 | * Synthesize your stored EMC into any other item you want!
15 | * Server owners have full control over the base EMC values of items
16 | * Items that are crafted have their EMC generated based off of these base values (e.g. Diamond = 1000 emc, Diamond Block will automatically be 9000)
17 | * Server owners can override this behavior if required by adding the item into the base.
18 | * Transmutation Orb
19 | * This key item lets users input their unwanted items to convert them to EMC.
20 | * The first time a new item is added, it is 'learned'.
21 | * Learned items can be synthesized using stored EMC.
22 | * Dissolution Chest
23 | * Any items placed/hopped/trasnfered via cargo into this chest will slowly be dissolved into EMC added directly into the players EMC pool
24 | * Condensate Chest
25 | * Shift + Click a Condensate chest with an item to assign it's production type. Assuming the player has enough EMC and the item can be synthesized, the items will begin production.
26 | * Slimefun
27 | * If Slimefun is installed, this plugin's recipes will be added to the Slimefun Guide. **This plugin does not require Slimefun to run**
28 |
29 | ## Planned Features
30 | * Automation Upgrades
31 | * Upgrades to MK2 - MK3 chests for faster throughput
32 | * Slimefun
33 | * As at this first release, only vanilla items + EquiTech items can be condensed / synthesized. A Future update will allow for Slimefun core items to also be added.
34 | * DankTech
35 | * The addition of a new type of pack to DankTech that converts voided items into EMC with a % loss
36 | * The addition of a new type of pack that builds from assigned slots using EMC.
37 |
38 | ## Pages
39 | * **_READ THIS ONE FIRST ->_** [Balancing](https://github.com/Sefiraat/EquivalencyTech/wiki/Balancing) **_<-READ THIS ONE FIRST_**
40 | * [What is EMC?](https://github.com/Sefiraat/EquivalencyTech/wiki/What-is-EMC%3F)
41 | * [Transmutation Orb](https://github.com/Sefiraat/EquivalencyTech/wiki/Transmutation-Orb)
42 | * [Dissolution Chest](https://github.com/Sefiraat/EquivalencyTech/wiki/Dissolution-Chest)
43 | * [Condensate Chest](https://github.com/Sefiraat/EquivalencyTech/wiki/Condensate-Chest)
44 | * [Crafting](https://github.com/Sefiraat/EquivalencyTech/wiki/Crafting)
45 | * [Commands](https://github.com/Sefiraat/EquivalencyTech/wiki/Commands)
46 |
47 |
48 | ## Thanks!
49 |
50 | A big thanks to the owners of **mct.tantrum.org** who have tested nearly everything I have made and really given me direction and drive to make these things.
51 |
52 | Another big shoutout to **GentlemanCheesy** of **mc.talosmp.net** for being my first (and as of writing this, only!) sponsor. A few coffee's a month to make me feel better about making these addons <3
53 |
--------------------------------------------------------------------------------
/.idea/jarRepositories.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/listeners/CraftListener.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.listeners;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.recipes.Recipes;
5 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
6 | import org.bukkit.Material;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.EventHandler;
9 | import org.bukkit.event.Listener;
10 | import org.bukkit.event.inventory.PrepareItemCraftEvent;
11 | import org.bukkit.inventory.ItemStack;
12 |
13 | import java.util.ArrayList;
14 | import java.util.List;
15 |
16 | public class CraftListener implements Listener {
17 |
18 | private final EquivalencyTech plugin;
19 |
20 | public CraftListener(EquivalencyTech plugin) {
21 | this.plugin = plugin;
22 | plugin.getServer().getPluginManager().registerEvents(this, plugin);
23 | }
24 |
25 | @EventHandler
26 | public void onPreCraft(PrepareItemCraftEvent e) {
27 |
28 | if (e.getView().getPlayer() instanceof Player && e.getRecipe() != null) {
29 |
30 | ItemStack[] contents = e.getInventory().getMatrix();
31 | List contentLayer = new ArrayList<>();
32 |
33 | for (ItemStack itemStack : contents) {
34 | ItemStack clone = null;
35 | if (itemStack != null) {
36 | clone = itemStack.clone();
37 | clone.setAmount(1);
38 | }
39 | contentLayer.add(clone);
40 | }
41 |
42 | if (contentLayer.equals(Recipes.recipeCoal1Check())) {
43 | e.getInventory().setResult(plugin.getEqItems().getAlchemicalCoal().getItemClone());
44 |
45 | } else if (contentLayer.equals(Recipes.recipeCoal2Check(plugin))) {
46 | e.getInventory().setResult(plugin.getEqItems().getMobiusFuel().getItemClone());
47 |
48 | } else if (contentLayer.equals(Recipes.recipeCoal3Check(plugin))) {
49 | e.getInventory().setResult(plugin.getEqItems().getAeternalisFuel().getItemClone());
50 |
51 | } else if (contentLayer.equals(Recipes.recipeDarkMatterCheck(plugin))) {
52 | e.getInventory().setResult(plugin.getEqItems().getDarkMatter().getItemClone());
53 |
54 | } else if (contentLayer.equals(Recipes.recipeRedMatterCheck(plugin))) {
55 | e.getInventory().setResult(plugin.getEqItems().getRedMatter().getItemClone());
56 |
57 | } else if (contentLayer.equals(Recipes.recipeTransmutationOrbCheck(plugin))) {
58 | e.getInventory().setResult(plugin.getEqItems().getTransmutationOrb().getItemClone());
59 |
60 | } else if (contentLayer.equals(Recipes.recipeDissolutionChestCheck(plugin))) {
61 | e.getInventory().setResult(plugin.getEqItems().getDissolutionChest().getItemClone());
62 |
63 | } else if (contentsEQ(contentLayer)) {
64 | e.getInventory().setResult(new ItemStack(Material.AIR));
65 | }
66 | }
67 | }
68 |
69 | private boolean contentsEQ(List itemStacks) {
70 | for (ItemStack itemStack : itemStacks) {
71 | if (ContainerStorage.isCraftable(itemStack, plugin)) {
72 | return true;
73 | }
74 | }
75 | return false;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/item/EQItems.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.item;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.item.builders.AeternalisFuel;
5 | import io.github.sefiraat.equivalencytech.item.builders.AlchemicalCoal;
6 | import io.github.sefiraat.equivalencytech.item.builders.CondensatorChest;
7 | import io.github.sefiraat.equivalencytech.item.builders.DarkMatter;
8 | import io.github.sefiraat.equivalencytech.item.builders.DissolutionChest;
9 | import io.github.sefiraat.equivalencytech.item.builders.MobiusFuel;
10 | import io.github.sefiraat.equivalencytech.item.builders.RedMatter;
11 | import io.github.sefiraat.equivalencytech.item.builders.TransmutationOrb;
12 | import io.github.sefiraat.equivalencytech.misc.Utils;
13 | import org.bukkit.inventory.ItemStack;
14 |
15 | import java.util.HashMap;
16 | import java.util.Map;
17 |
18 | public class EQItems {
19 |
20 | private final EquivalencyTech plugin;
21 | private final TransmutationOrb transmutationOrb;
22 | private final AlchemicalCoal alchemicalCoal;
23 | private final MobiusFuel mobiusFuel;
24 | private final AeternalisFuel aeternalisFuel;
25 | private final DarkMatter darkMatter;
26 | private final RedMatter redMatter;
27 | private final DissolutionChest dissolutionChest;
28 | private final CondensatorChest condensatorChest;
29 | private final Map eqItemMap;
30 |
31 | public EquivalencyTech getPlugin() {
32 | return plugin;
33 | }
34 |
35 | public TransmutationOrb getTransmutationOrb() {
36 | return transmutationOrb;
37 | }
38 |
39 | public AlchemicalCoal getAlchemicalCoal() {
40 | return alchemicalCoal;
41 | }
42 |
43 | public MobiusFuel getMobiusFuel() {
44 | return mobiusFuel;
45 | }
46 |
47 | public AeternalisFuel getAeternalisFuel() {
48 | return aeternalisFuel;
49 | }
50 |
51 | public DarkMatter getDarkMatter() {
52 | return darkMatter;
53 | }
54 |
55 | public RedMatter getRedMatter() {
56 | return redMatter;
57 | }
58 |
59 | public DissolutionChest getDissolutionChest() {
60 | return dissolutionChest;
61 | }
62 |
63 | public CondensatorChest getCondensatorChest() {
64 | return condensatorChest;
65 | }
66 |
67 | public Map getEqItemMap() {
68 | return eqItemMap;
69 | }
70 |
71 | public EQItems(EquivalencyTech plugin) {
72 | this.plugin = plugin;
73 | transmutationOrb = new TransmutationOrb(plugin);
74 | alchemicalCoal = new AlchemicalCoal(plugin);
75 | mobiusFuel = new MobiusFuel(plugin);
76 | aeternalisFuel = new AeternalisFuel(plugin);
77 | darkMatter = new DarkMatter(plugin);
78 | redMatter = new RedMatter(plugin);
79 | dissolutionChest = new DissolutionChest(plugin);
80 | condensatorChest = new CondensatorChest(plugin);
81 |
82 | eqItemMap = new HashMap<>();
83 | eqItemMap.put(Utils.eqNameConfig(transmutationOrb.getItem().getItemMeta().getDisplayName()), transmutationOrb.getItemClone());
84 | eqItemMap.put(Utils.eqNameConfig(alchemicalCoal.getItem().getItemMeta().getDisplayName()), alchemicalCoal.getItemClone());
85 | eqItemMap.put(Utils.eqNameConfig(mobiusFuel.getItem().getItemMeta().getDisplayName()), mobiusFuel.getItemClone());
86 | eqItemMap.put(Utils.eqNameConfig(aeternalisFuel.getItem().getItemMeta().getDisplayName()), aeternalisFuel.getItemClone());
87 | eqItemMap.put(Utils.eqNameConfig(darkMatter.getItem().getItemMeta().getDisplayName()), darkMatter.getItemClone());
88 | eqItemMap.put(Utils.eqNameConfig(redMatter.getItem().getItemMeta().getDisplayName()), redMatter.getItemClone());
89 | eqItemMap.put(Utils.eqNameConfig(dissolutionChest.getItem().getItemMeta().getDisplayName()), dissolutionChest.getItemClone());
90 | eqItemMap.put(Utils.eqNameConfig(condensatorChest.getItem().getItemMeta().getDisplayName()), condensatorChest.getItemClone());
91 |
92 | }
93 |
94 |
95 | }
96 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/misc/Utils.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.misc;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.item.builders.CondensatorChest;
5 | import io.github.sefiraat.equivalencytech.item.builders.DissolutionChest;
6 | import io.github.sefiraat.equivalencytech.item.builders.TransmutationOrb;
7 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
8 | import io.github.sefiraat.equivalencytech.statics.Messages;
9 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
10 | import net.md_5.bungee.api.ChatColor;
11 | import org.apache.commons.lang.WordUtils;
12 | import org.bukkit.Material;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.inventory.ItemStack;
15 |
16 | import java.math.BigDecimal;
17 | import java.math.RoundingMode;
18 |
19 | public class Utils {
20 |
21 | private Utils() {
22 | throw new IllegalStateException("Utility class");
23 | }
24 |
25 | public static Double getEMC(EquivalencyTech plugin, ItemStack itemStack) {
26 | SlimefunItem sfItem = null;
27 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
28 | sfItem = SlimefunItem.getByItem(itemStack);
29 | }
30 | if (sfItem != null) {
31 | return plugin.getEmcDefinitions().getEmcSlimefun().get(sfItem.getId());
32 | }
33 | if (ContainerStorage.isCraftable(itemStack, plugin)) {
34 | ItemStack eqStack = plugin.getEqItems().getEqItemMap().get(eqNameConfig(itemStack.getItemMeta().getDisplayName()));
35 | return plugin.getEmcDefinitions().getEmcEQ().get(eqStack.getItemMeta().getDisplayName());
36 | } else {
37 | return plugin.getEmcDefinitions().getEmcExtended().get(itemStack.getType());
38 | }
39 | }
40 |
41 | public static String eqNameConfig(String name) {
42 | return ChatColor.stripColor(name.replace(" ","_"));
43 | }
44 |
45 | public static String toTitleCase(String string) {
46 | final char[] delimiters = { ' ', '_' };
47 | return WordUtils.capitalizeFully(string, delimiters);
48 | }
49 |
50 | public static String materialFriendlyName(Material m) {
51 | return toTitleCase(m.name().replace("_", " "));
52 | }
53 |
54 | public static void givePlayerOrb(EquivalencyTech plugin, Player player) {
55 | TransmutationOrb i = plugin.getEqItems().getTransmutationOrb();
56 | player.getPlayer().getInventory().addItem(i.getItemClone());
57 | player.getPlayer().sendMessage(Messages.messageCommandItemGiven(plugin, i.getItem().getItemMeta().getDisplayName()));
58 | }
59 |
60 | public static void givePlayerDChest(EquivalencyTech plugin, Player player) {
61 | DissolutionChest i = plugin.getEqItems().getDissolutionChest();
62 | player.getPlayer().getInventory().addItem(i.getItemClone());
63 | player.getPlayer().sendMessage(Messages.messageCommandItemGiven(plugin, i.getItem().getItemMeta().getDisplayName()));
64 | }
65 |
66 | public static void givePlayerCChest(EquivalencyTech plugin, Player player) {
67 | CondensatorChest i = plugin.getEqItems().getCondensatorChest();
68 | player.getPlayer().getInventory().addItem(i.getItemClone());
69 | player.getPlayer().sendMessage(Messages.messageCommandItemGiven(plugin, i.getItem().getItemMeta().getDisplayName()));
70 | }
71 |
72 | public static double roundDown(double number, int places) {
73 | BigDecimal value = BigDecimal.valueOf(number);
74 | value = value.setScale(places, RoundingMode.DOWN);
75 | return value.doubleValue();
76 | }
77 |
78 | public static int totalRecipes(EquivalencyTech plugin) {
79 | int recExtended = plugin.getEmcDefinitions().getEmcExtended().size();
80 | int recEQ = plugin.getEmcDefinitions().getEmcEQ().size();
81 | return recExtended + recEQ;
82 | }
83 |
84 | public static boolean canBeSynth(EquivalencyTech plugin, ItemStack itemStack) {
85 | if (itemStack.hasItemMeta()) {
86 | SlimefunItem sfItem = null;
87 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
88 | sfItem = SlimefunItem.getByItem(itemStack);
89 | }
90 | return ContainerStorage.isCraftable(itemStack, plugin) || sfItem != null;
91 | } else {
92 | return true;
93 | }
94 | }
95 |
96 | }
97 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/EquivalencyTech.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech;
2 |
3 | import co.aikar.commands.PaperCommandManager;
4 | import io.github.sefiraat.equivalencytech.commands.Commands;
5 | import io.github.sefiraat.equivalencytech.configuration.ConfigMain;
6 | import io.github.sefiraat.equivalencytech.item.EQItems;
7 | import io.github.sefiraat.equivalencytech.listeners.ManagerEvents;
8 | import io.github.sefiraat.equivalencytech.misc.ManagerSupportedPlugins;
9 | import io.github.sefiraat.equivalencytech.recipes.EmcDefinitions;
10 | import io.github.sefiraat.equivalencytech.recipes.Recipes;
11 | import io.github.sefiraat.equivalencytech.runnables.ManagerRunnables;
12 | import io.github.thebusybiscuit.slimefun4.libraries.dough.updater.GitHubBuildsUpdater;
13 | import org.bstats.bukkit.Metrics;
14 | import org.bstats.charts.SimplePie;
15 | import org.bukkit.plugin.PluginDescriptionFile;
16 | import org.bukkit.plugin.java.JavaPlugin;
17 | import org.bukkit.plugin.java.JavaPluginLoader;
18 |
19 | import java.io.File;
20 |
21 | public class EquivalencyTech extends JavaPlugin {
22 |
23 | private static EquivalencyTech instance;
24 | private PaperCommandManager commandManager;
25 |
26 | private ConfigMain configMainClass;
27 | private EmcDefinitions emcDefinitions;
28 | private EQItems eqItems;
29 | private Recipes recipes;
30 | private ManagerEvents managerEvents;
31 | private ManagerRunnables managerRunnables;
32 | private ManagerSupportedPlugins managerSupportedPlugins;
33 |
34 | private boolean isUnitTest = false;
35 |
36 | public PaperCommandManager getCommandManager() {
37 | return commandManager;
38 | }
39 |
40 | public static EquivalencyTech getInstance() {
41 | return instance;
42 | }
43 |
44 | public ConfigMain getConfigMainClass() {
45 | return configMainClass;
46 | }
47 |
48 | public EmcDefinitions getEmcDefinitions() {
49 | return emcDefinitions;
50 | }
51 |
52 | public EQItems getEqItems() {
53 | return eqItems;
54 | }
55 |
56 | public Recipes getRecipes() {
57 | return recipes;
58 | }
59 |
60 | public ManagerEvents getManagerEvents() {
61 | return managerEvents;
62 | }
63 |
64 | public ManagerRunnables getManagerRunnables() {
65 | return managerRunnables;
66 | }
67 |
68 | public ManagerSupportedPlugins getManagerSupportedPlugins() {
69 | return managerSupportedPlugins;
70 | }
71 |
72 | public EquivalencyTech() {
73 | super();
74 | }
75 |
76 | protected EquivalencyTech(JavaPluginLoader loader, PluginDescriptionFile description, File dataFolder, File file) {
77 | super(loader, description, dataFolder, file);
78 | isUnitTest = true;
79 | }
80 |
81 | @Override
82 | public void onEnable() {
83 |
84 | getLogger().info("########################################");
85 | getLogger().info(" EquivalencyTech - Created by Sefiraat ");
86 | getLogger().info("########################################");
87 |
88 | instance = this;
89 |
90 | if (this.getConfig().getBoolean("auto-update") && this.getDescription().getVersion().startsWith("DEV")) {
91 | new GitHubBuildsUpdater(this, this.getFile(), "Sefiraat/EquivalencyTech/master").start();
92 | }
93 |
94 | configMainClass = new ConfigMain(this);
95 | eqItems = new EQItems(this);
96 | managerSupportedPlugins = new ManagerSupportedPlugins(this);
97 | emcDefinitions = new EmcDefinitions(this);
98 | recipes = new Recipes(this);
99 | managerEvents = new ManagerEvents(this);
100 | managerRunnables = new ManagerRunnables(this);
101 |
102 | registerCommands();
103 |
104 | if (!isUnitTest) {
105 | int pluginId = 11527;
106 | Metrics metrics = new Metrics(this, pluginId);
107 | metrics.addCustomChart(new SimplePie("slimefun", () -> String.valueOf(getManagerSupportedPlugins().isInstalledSlimefun())));
108 | metrics.addCustomChart(new SimplePie("emc2", () -> String.valueOf(getManagerSupportedPlugins().isInstalledEMC2())));
109 | }
110 |
111 | }
112 |
113 | @Override
114 | public void onDisable() {
115 | saveConfig();
116 | configMainClass.saveAdditionalConfigs();
117 | }
118 |
119 | private void registerCommands() {
120 | commandManager = new PaperCommandManager(this);
121 | commandManager.registerCommand(new Commands(this));
122 | }
123 |
124 |
125 |
126 |
127 |
128 |
129 | }
130 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/gui/GUIItems.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.gui;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import dev.triumphteam.gui.guis.GuiItem;
5 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
6 | import io.github.sefiraat.equivalencytech.configuration.ConfigMain;
7 | import io.github.sefiraat.equivalencytech.configuration.ConfigStrings;
8 | import io.github.sefiraat.equivalencytech.misc.Utils;
9 | import io.github.sefiraat.equivalencytech.statics.Messages;
10 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
11 | import net.md_5.bungee.api.ChatColor;
12 | import org.bukkit.Material;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.inventory.ItemFlag;
15 | import org.bukkit.inventory.ItemStack;
16 | import org.bukkit.inventory.meta.ItemMeta;
17 |
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | public class GUIItems {
22 |
23 | private GUIItems() {
24 | throw new IllegalStateException("Utility class");
25 | }
26 |
27 | public static GuiItem guiOrbInfo(EquivalencyTech plugin, Player player) {
28 | GuiItem g = new GuiItem(SkullCreator.itemFromBase64(SkullTextures.GUI_INFO_ALL));
29 | ItemStack i = g.getItemStack();
30 | ItemMeta im = i.getItemMeta();
31 | im.setDisplayName(guiDisplayNameInfo(plugin));
32 | im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
33 | im.setLore(guiDisplayLoreInfo(plugin, player));
34 | i.setItemMeta(im);
35 | g.setItemStack(i);
36 | g.setAction(event -> event.setCancelled(true));
37 | return g;
38 | }
39 |
40 | public static GuiItem guiOrbBorder(EquivalencyTech plugin) {
41 | GuiItem g = new GuiItem(Material.GRAY_STAINED_GLASS_PANE);
42 | ItemStack i = g.getItemStack();
43 | ItemMeta im = i.getItemMeta();
44 | im.setDisplayName(Messages.THEME_PASSIVE_GRAY + plugin.getConfigMainClass().getStrings().getGuiBorderName());
45 | im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
46 | i.setItemMeta(im);
47 | g.setItemStack(i);
48 | g.setAction(event -> event.setCancelled(true));
49 | return g;
50 | }
51 |
52 | public static GuiItem guiOrbFiller(EquivalencyTech plugin) {
53 | GuiItem g = new GuiItem(Material.LIGHT_GRAY_STAINED_GLASS_PANE);
54 | ItemStack i = g.getItemStack();
55 | ItemMeta im = i.getItemMeta();
56 | im.setDisplayName(Messages.THEME_PASSIVE_GRAY + plugin.getConfigMainClass().getStrings().getGuiFillerName());
57 | im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
58 | i.setItemMeta(im);
59 | g.setItemStack(i);
60 | g.setAction(event -> event.setCancelled(true));
61 | return g;
62 | }
63 |
64 | public static GuiItem guiEMCItem(EquivalencyTech plugin, ItemStack itemStack, boolean isVanilla) {
65 |
66 | GuiItem g = new GuiItem(itemStack);
67 | ItemMeta im = itemStack.getItemMeta();
68 |
69 | if (isVanilla) {
70 | im.setDisplayName(ChatColor.WHITE + Utils.materialFriendlyName(itemStack.getType()));
71 | } else {
72 | im.setDisplayName(ChatColor.WHITE + ChatColor.stripColor(im.getDisplayName()));
73 | }
74 |
75 | im.addItemFlags(ItemFlag.HIDE_ENCHANTS);
76 |
77 | im.setLore(getEmcItemLore(plugin, itemStack));
78 | itemStack.setItemMeta(im);
79 | g.setItemStack(itemStack);
80 | return g;
81 | }
82 |
83 | public static List getEmcItemLore(EquivalencyTech plugin, ItemStack itemStack) {
84 | ConfigStrings c = plugin.getConfigMainClass().getStrings();
85 | List lore = new ArrayList<>();
86 | lore.add(Messages.THEME_EMC_PURPLE + "EMC: " + Utils.getEMC(plugin, itemStack));
87 | lore.add("");
88 | lore.add(Messages.THEME_CLICK_INSTRUCTION + "Left Click: " + ChatColor.WHITE + c.getGuiEntryLeftClick());
89 | lore.add(Messages.THEME_CLICK_INSTRUCTION + "Right Click: " + ChatColor.WHITE + c.getGuiEntryRightClick());
90 | return lore;
91 | }
92 |
93 | public static String guiDisplayNameInfo(EquivalencyTech plugin) {
94 | return ChatColor.RED + plugin.getConfigMainClass().getStrings().getGuiInfoName();
95 | }
96 |
97 | public static List guiDisplayLoreInfo(EquivalencyTech plugin, Player player) {
98 | List l = new ArrayList<>();
99 | int recipesKnown = ConfigMain.getLearnedItemAmount(plugin, player);
100 | int recipesTotal = Utils.totalRecipes(plugin);
101 | l.add("" + ChatColor.GOLD + ChatColor.BOLD + plugin.getConfigMainClass().getStrings().getGuiInfoRecipes() + ": " + ChatColor.WHITE + recipesKnown + "/" + recipesTotal);
102 | l.add("");
103 | l.add("" + ChatColor.GOLD + ChatColor.BOLD + "EMC: " + ChatColor.WHITE + ConfigMain.getPlayerEmc(plugin, player));
104 | return l;
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/misc/SlimefunEQAddon.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.misc;
2 |
3 | import dev.dbassett.skullcreator.SkullCreator;
4 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
5 | import io.github.sefiraat.equivalencytech.item.EQSlimefunItem;
6 | import io.github.sefiraat.equivalencytech.recipes.Recipes;
7 | import io.github.sefiraat.equivalencytech.statics.SkullTextures;
8 | import io.github.thebusybiscuit.slimefun4.api.SlimefunAddon;
9 | import io.github.thebusybiscuit.slimefun4.api.items.ItemGroup;
10 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
11 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
12 | import io.github.thebusybiscuit.slimefun4.api.recipes.RecipeType;
13 | import io.github.thebusybiscuit.slimefun4.libraries.dough.recipes.MinecraftRecipe;
14 | import net.md_5.bungee.api.ChatColor;
15 | import org.bukkit.NamespacedKey;
16 | import org.bukkit.inventory.ItemStack;
17 | import org.bukkit.inventory.meta.ItemMeta;
18 | import org.bukkit.plugin.java.JavaPlugin;
19 | import org.jetbrains.annotations.NotNull;
20 | import org.jetbrains.annotations.Nullable;
21 |
22 | import java.util.Collections;
23 |
24 |
25 | public class SlimefunEQAddon implements SlimefunAddon {
26 |
27 | private final EquivalencyTech plugin;
28 |
29 | public SlimefunEQAddon(EquivalencyTech plugin) {
30 |
31 | this.plugin = plugin;
32 |
33 | // Category
34 | NamespacedKey categoryIdMain = new NamespacedKey(plugin, "danktech_main");
35 |
36 | ItemStack categoryItemMain = SkullCreator.itemFromBase64(SkullTextures.ITEM_TRANSMUTATION_ORB);
37 | ItemMeta im = categoryItemMain.getItemMeta();
38 | im.setDisplayName(ChatColor.YELLOW + "EquivalencyTech");
39 | im.setLore(Collections.singletonList("&a> Click to open"));
40 | categoryItemMain.setItemMeta(im);
41 | ItemGroup eqCategory = new ItemGroup(categoryIdMain, categoryItemMain);
42 |
43 | // Items
44 | // Coal 1
45 | SlimefunItemStack coal1Stack = new SlimefunItemStack( "EQ_COAL_1", plugin.getEqItems().getAlchemicalCoal().getItemClone());
46 | SlimefunItem coal1Item = new EQSlimefunItem(eqCategory, coal1Stack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeCoal1());
47 | coal1Item.register(this);
48 | // Coal 2
49 | SlimefunItemStack coal2Stack = new SlimefunItemStack( "EQ_COAL_2", plugin.getEqItems().getMobiusFuel().getItemClone());
50 | SlimefunItem coal2Item = new EQSlimefunItem(eqCategory, coal2Stack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeCoal2(coal1Stack));
51 | coal2Item.register(this);
52 | // Coal 3
53 | SlimefunItemStack coal3Stack = new SlimefunItemStack( "EQ_COAL_3", plugin.getEqItems().getAeternalisFuel().getItemClone());
54 | SlimefunItem coal3Item = new EQSlimefunItem(eqCategory, coal3Stack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeCoal3(coal2Stack));
55 | coal3Item.register(this);
56 | // Dark Matter
57 | SlimefunItemStack darkStack = new SlimefunItemStack( "EQ_DARK_MATTER", plugin.getEqItems().getDarkMatter().getItemClone());
58 | SlimefunItem darkItem = new EQSlimefunItem(eqCategory, darkStack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeDarkMatter(coal3Stack));
59 | darkItem.register(this);
60 | // Red Matter
61 | SlimefunItemStack redStack = new SlimefunItemStack( "EQ_RED_MATTER", plugin.getEqItems().getRedMatter().getItemClone());
62 | SlimefunItem redItem = new EQSlimefunItem(eqCategory, redStack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeRedMatter(coal3Stack, darkStack));
63 | redItem.register(this);
64 | // Transmutation Orb
65 | SlimefunItemStack orbStack = new SlimefunItemStack( "EQ_T_ORB", plugin.getEqItems().getTransmutationOrb().getItemClone());
66 | SlimefunItem orbItem = new EQSlimefunItem(eqCategory, orbStack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeTransmutationOrb(darkStack, redStack));
67 | orbItem.register(this);
68 | // Dissolution Chest
69 | SlimefunItemStack dChestStack = new SlimefunItemStack( "EQ_D_CHEST", plugin.getEqItems().getDissolutionChest().getItemClone());
70 | SlimefunItem dChestItem = new EQSlimefunItem(eqCategory, dChestStack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeDissolutionChest(coal2Stack));
71 | dChestItem.register(this);
72 | // Condensator Chest
73 | SlimefunItemStack cChestStack = new SlimefunItemStack( "EQ_C_CHEST", plugin.getEqItems().getCondensatorChest().getItemClone());
74 | SlimefunItem cChestItem = new EQSlimefunItem(eqCategory, cChestStack, new RecipeType(MinecraftRecipe.SHAPED_CRAFTING), Recipes.getSFRecipeCondensatorChest(coal3Stack, dChestStack));
75 | cChestItem.register(this);
76 | }
77 |
78 | @NotNull
79 | @Override
80 | public JavaPlugin getJavaPlugin() {
81 | return plugin;
82 | }
83 |
84 | @Nullable
85 | @Override
86 | public String getBugTrackerURL() {
87 | return null;
88 | }
89 | }
90 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/configuration/ConfigStrings.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.configuration;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import org.bukkit.configuration.file.FileConfiguration;
5 |
6 | import java.util.List;
7 |
8 | public class ConfigStrings {
9 |
10 | FileConfiguration configuration;
11 |
12 | // region General
13 |
14 | public String getGeneralNoInvSpace() {
15 | return configuration.getString("MESSAGES.GENERAL_NO_INVENTORY_SPACE");
16 | }
17 |
18 | public String getGeneralCraftingItem() {
19 | return configuration.getString("ITEMS.GENERAL_CRAFTING_ITEM");
20 | }
21 |
22 | // endregion
23 |
24 | // region Commands
25 |
26 | public String getCommandSubcommand() {
27 | return configuration.getString("MESSAGES.COMMAND_SUBCOMMAND");
28 | }
29 |
30 | public String getCommandEmcMustHold() {
31 | return configuration.getString("MESSAGES.COMMAND_EMC_ITEM_MUST_HOLD");
32 | }
33 |
34 | public String getCommandEmcNone() {
35 | return configuration.getString("MESSAGES.COMMAND_EMC_NONE");
36 | }
37 |
38 | public String getCommandSelectItem() {
39 | return configuration.getString("MESSAGES.COMMAND_SELECT_ITEM");
40 | }
41 |
42 | public String getCommandItemGiven() {
43 | return configuration.getString("MESSAGES.COMMAND_ITEM_GIVEN");
44 | }
45 |
46 | // endregion
47 |
48 | // region Items
49 |
50 | public String getItemTransmutationOrbName() {
51 | return configuration.getString("ITEMS.TRANSMUTATION_ORB_NAME");
52 | }
53 |
54 | public List getItemTransmutationOrbLore() {
55 | return configuration.getStringList("ITEMS.TRANSMUTATION_ORB_LORE");
56 | }
57 |
58 | public String getItemRightClickToOpen() {
59 | return configuration.getString("ITEMS.TRANSMUTATION_ORB_INFO");
60 | }
61 |
62 | public String getItemAlchemicalCoalName() {
63 | return configuration.getString("ITEMS.ALCHEMICAL_COAL_NAME");
64 | }
65 |
66 | public String getItemMobiusFuelName() {
67 | return configuration.getString("ITEMS.MOBIUS_FUEL_NAME");
68 | }
69 |
70 | public String getItemAeternalisFuelName() {
71 | return configuration.getString("ITEMS.AETERNALIS_FUEL_NAME");
72 | }
73 |
74 | public String getItemDarkMatterName() {
75 | return configuration.getString("ITEMS.DARK_MATTER_NAME");
76 | }
77 |
78 | public String getItemRedMatterName() {
79 | return configuration.getString("ITEMS.RED_MATTER_NAME");
80 | }
81 |
82 | public String getItemDissolutionChestName() {
83 | return configuration.getString("ITEMS.DISSOLUTION_CHEST_NAME");
84 | }
85 |
86 | public List getItemDissolutionChestLore() {
87 | return configuration.getStringList("ITEMS.DISSOLUTION_CHEST_LORE");
88 | }
89 |
90 | public String getItemCondensatorChestName() {
91 | return configuration.getString("ITEMS.CONDENSATOR_CHEST_NAME");
92 | }
93 |
94 | public List getItemCondensatorChestLore() {
95 | return configuration.getStringList("ITEMS.CONDENSATOR_CHEST_LORE");
96 | }
97 |
98 | public String getItemCondensatorChestSet() {
99 | return configuration.getString("ITEMS.CONDENSATOR_CHEST_SET_ITEM");
100 | }
101 |
102 | // endregion
103 |
104 | // region GUI
105 |
106 | public String getGuiBorderName() {
107 | return configuration.getString("GUI.SLOT_BORDER_NAME");
108 | }
109 |
110 | public String getGuiFillerName() {
111 | return configuration.getString("GUI.SLOT_FILLER_NAME");
112 | }
113 |
114 | public String getGuiItemLearned() {
115 | return configuration.getString("GUI.ORB_ITEM_ADDED");
116 | }
117 |
118 | public String getGuiInfoName() {
119 | return configuration.getString("GUI.EMC_INFO_NAME");
120 | }
121 |
122 | public String getGuiInfoRecipes() {
123 | return configuration.getString("GUI.EMC_INFO_LORE_RECIPES");
124 | }
125 |
126 | public String getGuiEntryLeftClick() {
127 | return configuration.getString("GUI.EMC_ITEM_WITHDRAW_ONE");
128 | }
129 |
130 | public String getGuiEntryRightClick() {
131 | return configuration.getString("GUI.EMC_ITEM_WITHDRAW_STACK");
132 | }
133 |
134 | public String getGuiNotEnoughEmc() {
135 | return configuration.getString("GUI.EMC_NOT_ENOUGH");
136 | }
137 |
138 | public String getGuiItemMeta() {
139 | return configuration.getString("GUI.EMC_ITEM_META");
140 | }
141 |
142 | // endregion
143 |
144 | // region Events
145 |
146 | public String getEventAdjPlacement() {
147 | return configuration.getString("MESSAGES.EVENT_PLACE_EMC_CHEST_ADJACENT");
148 | }
149 |
150 | public String getEventCantOpenNotOwner() {
151 | return configuration.getString("MESSAGES.EVENT_CANT_OPEN_NOT_OWNER");
152 | }
153 |
154 | public String getEventItemSet() {
155 | return configuration.getString("MESSAGES.EVENT_CHEST_ITEM_SET");
156 | }
157 |
158 | public String getEventItemUnset() {
159 | return configuration.getString("MESSAGES.EVENT_CHEST_ITEM_UNSET");
160 | }
161 |
162 |
163 | // endregion
164 |
165 | public ConfigStrings(EquivalencyTech plugin) {
166 | configuration = plugin.getConfig();
167 | }
168 |
169 | }
170 |
--------------------------------------------------------------------------------
/dependency-reduced-pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | 4.0.0
4 | io.github.sefiraat
5 | EquivalencyTech
6 | modified
7 |
8 |
9 |
10 | maven-shade-plugin
11 | 3.2.3
12 |
13 |
14 | package
15 |
16 | shade
17 |
18 |
19 |
20 |
21 |
22 |
23 | dev.triumphteam.gui
24 | io.github.sefiraat.equivalencytech.mfgui
25 |
26 |
27 | co.aikar.commands
28 | io.github.sefiraat.equivalencytech.acf
29 |
30 |
31 | co.aikar.locales
32 | io.github.sefiraat.equivalencytech.locales
33 |
34 |
35 | org.bstats
36 | io.github.sefiraat.equivalencytech.bstats
37 |
38 |
39 |
40 |
41 |
42 | maven-surefire-plugin
43 | 3.0.0-M5
44 |
45 | org.junit.jupiter:junit-jupiter
46 | false
47 |
48 |
49 |
50 | org.sonarsource.scanner.maven
51 | sonar-maven-plugin
52 | 3.9.0.2155
53 |
54 |
55 | org.jacoco
56 | jacoco-maven-plugin
57 | 0.8.6
58 |
59 |
60 | prepare
61 |
62 | prepare-agent
63 |
64 |
65 |
66 | report
67 | test
68 |
69 | report
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 | spigot-repo
79 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/
80 |
81 |
82 | papermc
83 | https://papermc.io/repo/repository/maven-public/
84 |
85 |
86 | jitpack.io
87 | https://jitpack.io
88 |
89 |
90 | aikar
91 | https://repo.aikar.co/content/groups/aikar/
92 |
93 |
94 | sk89q-repo
95 | https://maven.enginehub.org/repo/
96 |
97 |
98 | skullcreator-repo
99 | https://github.com/deanveloper/SkullCreator/raw/mvn-repo/
100 |
101 |
102 | repo
103 | https://repo.mattstudios.me/artifactory/public/
104 |
105 |
106 |
107 |
108 | org.spigotmc
109 | spigot-api
110 | 1.17-R0.1-SNAPSHOT
111 | provided
112 |
113 |
114 | com.destroystokyo.paper
115 | paper-api
116 | 1.16.5-R0.1-SNAPSHOT
117 | provided
118 |
119 |
120 | com.github.Slimefun
121 | Slimefun4
122 | RC-28
123 | provided
124 |
125 |
126 | cscorelib2
127 | io.github.thebusybiscuit
128 |
129 |
130 |
131 |
132 |
133 | 1.8
134 | Sefiraat_EquivalencyTech
135 | e1,e2
136 | 1.8
137 | java:S125
138 | https://sonarcloud.io
139 | UTF-8
140 | sefiraat
141 | **
142 | **
143 | java:S6212
144 |
145 |
146 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/commands/Commands.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.commands;
2 |
3 | import co.aikar.commands.BaseCommand;
4 | import co.aikar.commands.annotation.CommandAlias;
5 | import co.aikar.commands.annotation.CommandCompletion;
6 | import co.aikar.commands.annotation.CommandPermission;
7 | import co.aikar.commands.annotation.Default;
8 | import co.aikar.commands.annotation.Description;
9 | import co.aikar.commands.annotation.Subcommand;
10 | import co.aikar.commands.bukkit.contexts.OnlinePlayer;
11 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
12 | import io.github.sefiraat.equivalencytech.misc.Utils;
13 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
14 | import io.github.sefiraat.equivalencytech.statics.Messages;
15 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
16 | import org.bukkit.Material;
17 | import org.bukkit.command.CommandSender;
18 | import org.bukkit.entity.Player;
19 | import org.bukkit.inventory.ItemStack;
20 |
21 | @CommandAlias("EquivalencyTech|ET")
22 | @Description("EquivalencyTech Main")
23 | public class Commands extends BaseCommand {
24 |
25 | private final EquivalencyTech plugin;
26 |
27 | public EquivalencyTech getPlugin() {
28 | return plugin;
29 | }
30 |
31 | public Commands(EquivalencyTech plugin) {
32 | this.plugin = plugin;
33 | }
34 |
35 | @Default
36 | public void onDefault(CommandSender sender) {
37 | if (sender instanceof Player) {
38 | sender.sendMessage(Messages.msgCmdSubcommand(plugin));
39 | }
40 | }
41 |
42 | @Subcommand("ItemEmc")
43 | @Description("Displays the EMC value for the held item.")
44 | public class ItemEmc extends BaseCommand {
45 |
46 | @Default
47 | public void onDefault(CommandSender sender) {
48 | if (sender instanceof Player) {
49 | Player player = (Player) sender;
50 | ItemStack i = player.getInventory().getItemInMainHand();
51 | SlimefunItem sfItem = null;
52 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
53 | sfItem = SlimefunItem.getByItem(i);
54 | }
55 | if (sfItem != null) {
56 | if (plugin.getEmcDefinitions().getEmcSlimefun().containsKey(sfItem.getId())) {
57 | player.sendMessage(Messages.msgCmdEmcDisplay(sfItem.getId(), Utils.getEMC(plugin, i)));
58 | player.sendMessage(Messages.msgCmdEmcDisplayStack(sfItem.getId(), i.getAmount(), Utils.getEMC(plugin, i) * i.getAmount()));
59 | } else {
60 | player.sendMessage(Messages.msgCmdEmcNone(plugin));
61 | }
62 | return;
63 | }
64 | if (i.getType() != Material.AIR) {
65 | if (ContainerStorage.isCraftable(i, plugin)) {
66 | if (plugin.getEmcDefinitions().getEmcEQ().containsKey(i.getItemMeta().getDisplayName())) {
67 | player.sendMessage(Messages.msgCmdEmcDisplay(i.getItemMeta().getDisplayName(), Utils.getEMC(plugin, i)));
68 | player.sendMessage(Messages.msgCmdEmcDisplayStack(i.getItemMeta().getDisplayName(), i.getAmount(), Utils.getEMC(plugin, i) * i.getAmount()));
69 | } else {
70 | player.sendMessage(Messages.msgCmdEmcNone(plugin));
71 | }
72 | return;
73 | }
74 | if (plugin.getEmcDefinitions().getEmcExtended().containsKey(i.getType())) {
75 | player.sendMessage(Messages.msgCmdEmcDisplay(i.getType(), Utils.getEMC(plugin, i)));
76 | player.sendMessage(Messages.msgCmdEmcDisplayStack(i.getType(), i.getAmount(), Utils.getEMC(plugin, i) * i.getAmount()));
77 | } else {
78 | player.sendMessage(Messages.msgCmdEmcNone(plugin));
79 | }
80 | } else {
81 | player.sendMessage(Messages.msgCmdEmcMustHold(plugin));
82 | }
83 | }
84 | }
85 | }
86 |
87 | @Subcommand("Emc")
88 | @Description("Displays the player's emc.")
89 | public class Emc extends BaseCommand {
90 |
91 | @Default
92 | public void onDefault(CommandSender sender) {
93 | if (sender instanceof Player) {
94 | Player player = (Player) sender;
95 | player.sendMessage(Messages.messageCommandEmc(plugin, player));
96 | }
97 | }
98 | }
99 |
100 | @Subcommand("GiveItem")
101 | @CommandPermission("EquiTech.Admin")
102 | @Description("Gives Debug Items")
103 | public class GiveItem extends BaseCommand {
104 |
105 | @Default
106 | public void onDefault(CommandSender sender) {
107 | if (sender instanceof Player) {
108 | sender.sendMessage(Messages.messageCommandSelectItem(plugin));
109 | }
110 | }
111 |
112 | @Subcommand("TransmutationOrb")
113 | @CommandCompletion("@players")
114 | public void onGiveItemOrb(CommandSender sender, OnlinePlayer player) {
115 | if (sender instanceof Player) {
116 | Utils.givePlayerOrb(plugin, player.getPlayer());
117 | }
118 | }
119 |
120 | @Subcommand("DissolutionChest")
121 | @CommandCompletion("@players")
122 | public void onGiveItemDChest(CommandSender sender, OnlinePlayer player) {
123 | if (sender instanceof Player) {
124 | Utils.givePlayerDChest(plugin, player.getPlayer());
125 | }
126 | }
127 |
128 | @Subcommand("CondensateChest")
129 | @CommandCompletion("@players")
130 | public void onGiveItemCChest(CommandSender sender, OnlinePlayer player) {
131 | if (sender instanceof Player) {
132 | Utils.givePlayerCChest(plugin, player.getPlayer());
133 | }
134 | }
135 | }
136 |
137 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/runnables/RunnableEQTick.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.runnables;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.configuration.ConfigMain;
5 | import io.github.sefiraat.equivalencytech.misc.Utils;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
8 | import org.bukkit.Location;
9 | import org.bukkit.Material;
10 | import org.bukkit.block.BlockState;
11 | import org.bukkit.block.Chest;
12 | import org.bukkit.inventory.Inventory;
13 | import org.bukkit.inventory.ItemStack;
14 | import org.bukkit.scheduler.BukkitRunnable;
15 |
16 | import java.text.MessageFormat;
17 | import java.util.HashMap;
18 |
19 | public class RunnableEQTick extends BukkitRunnable {
20 |
21 | public final EquivalencyTech plugin;
22 | public final boolean sf;
23 |
24 | public RunnableEQTick(EquivalencyTech plugin) {
25 | this.plugin = plugin;
26 | sf = EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun();
27 | }
28 |
29 | @Override
30 | public void run() {
31 | processDChests();
32 | processCChests();
33 | }
34 |
35 | private void processDChests() {
36 | for (Location location : ConfigMain.getAllDChestLocations(plugin)) {
37 | if (location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)) {
38 | int chestId = ConfigMain.getDChestIdStore(plugin, location);
39 | String playerUUID = ConfigMain.getOwnerDChest(plugin, chestId);
40 |
41 | BlockState state = location.getBlock().getState();
42 |
43 | if (!(state instanceof Chest)) {
44 | EquivalencyTech.getInstance().getLogger().warning(getErrorDissolutionChest(chestId, location));
45 | continue;
46 | }
47 |
48 | Chest chest = (Chest) location.getBlock().getState();
49 | Inventory inventory = chest.getBlockInventory();
50 | for (ItemStack itemStack : inventory.getContents()) {
51 | if (itemStack != null && itemStack.getType() != Material.AIR) {
52 | boolean isEQ = ContainerStorage.isCraftable(itemStack, plugin);
53 | SlimefunItem sfItem = null;
54 | if (sf) {
55 | sfItem = SlimefunItem.getByItem(itemStack);
56 | }
57 | Material material = itemStack.getType();
58 | Double emcValue = Utils.roundDown((Utils.getEMC(plugin, itemStack) / 100) * 150, 2);
59 | if (emcValue != null && Utils.canBeSynth(plugin, itemStack)) {
60 | String entryName;
61 | if (isEQ) {
62 | entryName = Utils.eqNameConfig(itemStack.getItemMeta().getDisplayName());
63 | } else if (sfItem != null) {
64 | entryName = sfItem.getId();
65 | } else {
66 | entryName = material.toString();
67 | }
68 | if (!ConfigMain.getLearnedItems(plugin, playerUUID).contains(entryName)) {
69 | ConfigMain.addLearnedItem(plugin, playerUUID, entryName);
70 | }
71 | ConfigMain.addPlayerEmc(plugin, playerUUID, emcValue);
72 | itemStack.setAmount(itemStack.getAmount() - 1);
73 | break;
74 | }
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
81 | private void processCChests() {
82 | for (Location location : ConfigMain.getAllCChestLocations(plugin)) {
83 | if (location.getWorld().isChunkLoaded(location.getBlockX() >> 4, location.getBlockZ() >> 4)) {
84 | int chestId = ConfigMain.getCChestIdStore(plugin, location);
85 | String playerUUID = ConfigMain.getOwnerCChest(plugin, chestId);
86 |
87 | BlockState state = location.getBlock().getState();
88 |
89 | if (!(state instanceof Chest)) {
90 | EquivalencyTech.getInstance().getLogger().warning(getErrorCondensateChest(chestId, location));
91 | continue;
92 | }
93 |
94 | Chest chest = (Chest) location.getBlock().getState();
95 | Inventory inventory = chest.getBlockInventory();
96 | ItemStack itemStack = ConfigMain.getCChestItem(plugin, chestId);
97 | if (itemStack != null) {
98 | Double emcValue = Utils.getEMC(plugin, itemStack);
99 | if (emcValue != null) {
100 | Double playerEmc = ConfigMain.getPlayerEmc(plugin, playerUUID);
101 | if (playerEmc >= emcValue) {
102 | HashMap failed = inventory.addItem(itemStack);
103 | if (failed.isEmpty()) {
104 | ConfigMain.removePlayerEmc(plugin, playerUUID, emcValue);
105 | }
106 | }
107 | }
108 | }
109 | }
110 | }
111 | }
112 |
113 | public static String getErrorDissolutionChest(int chestId, Location location) {
114 | return MessageFormat.format(
115 | "A Dissolution chest (ID: {0}has been removed wrongly. " +
116 | "Either replace with a vanilla chest (location : {1}) " +
117 | "or remove from dissolution_chests.yml",
118 | chestId,
119 | location.toString()
120 | );
121 | }
122 |
123 | public static String getErrorCondensateChest(int chestId, Location location) {
124 | return MessageFormat.format(
125 | "A Condensate chest (ID: {0}has been removed wrongly. " +
126 | "Either replace with a vanilla chest (location : {1}) " +
127 | "or remove from condensate_chests.yml",
128 | chestId,
129 | location.toString()
130 | );
131 | }
132 | }
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/statics/DebugLogs.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.statics;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import org.apache.commons.lang.StringUtils;
5 | import org.bukkit.inventory.ItemStack;
6 |
7 | import java.util.logging.Level;
8 |
9 | public final class DebugLogs {
10 |
11 | private DebugLogs() {
12 | throw new IllegalStateException("Utility class");
13 | }
14 |
15 | public static final String NEST = " >";
16 |
17 | // Logs
18 | public static void logEmcBaseValueLoaded(EquivalencyTech plugin, String materialName, Double emcValue) {
19 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
20 | plugin.getLogger().log(Level.INFO,"EMC BASE LOADED : {0} : {1}", new Object[]{materialName, emcValue});
21 | }
22 | }
23 |
24 | public static void logEmcTestingItemStack(EquivalencyTech plugin, String itemStackName, Integer nestLevel) {
25 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
26 | plugin.getLogger().log(Level.INFO,"{0}EMC TESTING : {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), itemStackName});
27 | }
28 | }
29 |
30 | public static void logEmcNoRecipes(EquivalencyTech plugin, Integer nestLevel) {
31 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
32 | plugin.getLogger().log(Level.INFO,"{0}No recipes - not condensable", StringUtils.repeat(NEST, nestLevel));
33 | }
34 | }
35 |
36 | public static void logEmcIsBase(EquivalencyTech plugin, Double emcValue, Integer nestLevel) {
37 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
38 | plugin.getLogger().log(Level.INFO,"{0}Is Base : passing EMC value up : {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), emcValue});
39 | }
40 | }
41 |
42 | public static void logEmcIsRegisteredExtended(EquivalencyTech plugin, Double emcValue, Integer nestLevel) {
43 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
44 | plugin.getLogger().log(Level.INFO,"{0}Is Registered in extended : passing EMC value up : {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), emcValue});
45 | }
46 | }
47 |
48 | public static void logCheckingRecipe(EquivalencyTech plugin, Integer nestLevel) {
49 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
50 | plugin.getLogger().log(Level.INFO,"{0}Recipe found : starting recursion.", StringUtils.repeat(NEST, nestLevel));
51 | }
52 | }
53 |
54 | public static void logEmcPosted(EquivalencyTech plugin, Double emcValue, Integer nestLevel) {
55 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
56 | plugin.getLogger().log(Level.INFO,"{0}All items completed : EMC : {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), emcValue});
57 | }
58 | }
59 |
60 | public static void logEmcNull(EquivalencyTech plugin, Integer nestLevel) {
61 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
62 | plugin.getLogger().log(Level.INFO,"{0}All items completed : One or more items returned null base EMC. Item not added.", StringUtils.repeat(NEST, nestLevel));
63 | }
64 | }
65 |
66 | public static void logRecipeType(EquivalencyTech plugin, String type, Integer nestLevel) {
67 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
68 | plugin.getLogger().log(Level.INFO,"{0}Recipe type : {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), type});
69 | }
70 | }
71 |
72 | public static void logRecipeMultipleOutputs(EquivalencyTech plugin, Double emcTotal, Integer outputVolume, Integer nestLevel) {
73 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
74 | plugin.getLogger().log(Level.INFO,"{0}Recipe has multiple output items. Using : ({1}/{2}", new Object[]{StringUtils.repeat(NEST, nestLevel), emcTotal, outputVolume});
75 | }
76 | }
77 |
78 | public static void logEmcRecipeResult(EquivalencyTech plugin, Double emcValue, Integer nestLevel) {
79 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
80 | plugin.getLogger().log(Level.INFO,"{0}Recipe resulted in EMC of: {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), emcValue});
81 | }
82 | }
83 |
84 | public static void logRecipeCheaper(EquivalencyTech plugin, Integer nestLevel) {
85 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
86 | plugin.getLogger().log(Level.INFO,"{0}Recipe is either first/only or cheapest found so far.", StringUtils.repeat(NEST, nestLevel));
87 | }
88 | }
89 |
90 | public static void logRecipeNotCheaper(EquivalencyTech plugin, Integer nestLevel) {
91 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
92 | plugin.getLogger().log(Level.INFO,"{0}Recipe is valid but a previous recipe is cheaper - this recipe ignored.", StringUtils.repeat(NEST, nestLevel));
93 | }
94 | }
95 |
96 | public static void logEQStart(EquivalencyTech plugin, Integer nestLevel, ItemStack itemStack) {
97 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
98 | plugin.getLogger().log(Level.INFO,"{0}EQ Recipe check starting : ItemStack is : {1}", new Object[]{StringUtils.repeat(NEST, nestLevel), itemStack.getType()});
99 | }
100 | }
101 |
102 | public static void logEQisCrafting(EquivalencyTech plugin, Integer nestLevel) {
103 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
104 | plugin.getLogger().log(Level.INFO,"{0}ItemStack is a EQ craftable - ", new Object[]{StringUtils.repeat(NEST, nestLevel), });
105 | }
106 | }
107 |
108 | public static void logEQisNotCrafting(EquivalencyTech plugin, Integer nestLevel) {
109 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
110 | plugin.getLogger().log(Level.INFO,"{0}ItemStack is NOT EQ craftable - moving to extended/base - ", new Object[]{StringUtils.repeat(NEST, nestLevel)});
111 | }
112 | }
113 |
114 | public static void logBoring(EquivalencyTech plugin, String string) {
115 | if (plugin.getConfigMainClass().getBools().getDebuggingLogs()) {
116 | plugin.getLogger().log(Level.INFO,string);
117 | }
118 | }
119 |
120 | }
121 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/statics/Messages.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.statics;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.configuration.ConfigMain;
5 | import io.github.sefiraat.equivalencytech.misc.Utils;
6 | import net.md_5.bungee.api.ChatColor;
7 | import org.bukkit.Material;
8 | import org.bukkit.entity.Player;
9 |
10 | import java.text.MessageFormat;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public final class Messages {
15 |
16 | public static final String PREFIX = "" + ChatColor.GRAY + "[EMCTech] ";
17 | public static final String SUFFIX = "" + ChatColor.GRAY + "";
18 |
19 | public static final ChatColor THEME_WARNING = ChatColor.YELLOW;
20 | public static final ChatColor THEME_ERROR = ChatColor.RED;
21 | public static final ChatColor THEME_NOTICE = ChatColor.WHITE;
22 | public static final ChatColor THEME_PASSIVE = ChatColor.GRAY;
23 | public static final ChatColor THEME_SUCCESS = ChatColor.GREEN;
24 | public static final ChatColor THEME_EMC_PURPLE = ChatColor.of("#5d2999");
25 | public static final ChatColor THEME_ITEM_NAME_GENERAL = ChatColor.of("#cfab1d");
26 | public static final ChatColor THEME_PASSIVE_GRAY = ChatColor.of("#a3a3a3");
27 | public static final ChatColor THEME_CLICK_INSTRUCTION = ChatColor.of("#cfab1d");
28 | public static final ChatColor THEME_PASSIVE_CONGRATULATE = ChatColor.of("#fff41f");
29 |
30 | private Messages() {
31 | throw new IllegalStateException("Utility class");
32 | }
33 |
34 | // region Commands
35 |
36 | public static String msgCmdSubcommand(EquivalencyTech plugin) {
37 | return PREFIX + THEME_NOTICE + plugin.getConfigMainClass().getStrings().getCommandSubcommand();
38 | }
39 | public static String msgCmdEmcMustHold(EquivalencyTech plugin) {
40 | return PREFIX + THEME_WARNING + plugin.getConfigMainClass().getStrings().getCommandEmcMustHold();
41 | }
42 | public static String msgCmdEmcNone(EquivalencyTech plugin) {
43 | return PREFIX + THEME_WARNING + plugin.getConfigMainClass().getStrings().getCommandEmcNone();
44 | }
45 | public static String msgCmdEmcDisplay(Material m, Double emc) {
46 | return PREFIX + THEME_WARNING + Utils.materialFriendlyName(m) + " x 1 = EMC " + emc;
47 | }
48 | public static String msgCmdEmcDisplay(String s, Double emc) {
49 | return PREFIX + THEME_WARNING + s + " x 1 = EMC " + emc;
50 | }
51 | public static String msgCmdEmcDisplayStack(Material m, Integer amount, Double emc) {
52 | return PREFIX + THEME_WARNING + Utils.materialFriendlyName(m) + " x " + amount + " = EMC " + emc;
53 | }
54 | public static String msgCmdEmcDisplayStack(String s, Integer amount, Double emc) {
55 | return PREFIX + THEME_WARNING + s + " x " + amount + " = EMC " + emc;
56 | }
57 | public static String messageCommandSelectItem(EquivalencyTech plugin) {
58 | return PREFIX + THEME_NOTICE + plugin.getConfigMainClass().getStrings().getCommandSelectItem();
59 | }
60 |
61 | public static String messageCommandItemGiven(EquivalencyTech plugin, String itemName) {
62 | return PREFIX + THEME_NOTICE + MessageFormat.format(plugin.getConfigMainClass().getStrings().getCommandItemGiven(), itemName);
63 | }
64 |
65 | public static String messageCommandEmc(EquivalencyTech plugin, Player player) {
66 | return PREFIX + THEME_NOTICE + "You have " + THEME_SUCCESS + ConfigMain.getPlayerEmc(plugin, player) + THEME_NOTICE + " EMC.";
67 | }
68 |
69 | // endregion
70 |
71 | // region GUI
72 |
73 | public static String messageGuiItemLearned(EquivalencyTech plugin) {
74 | return PREFIX + THEME_PASSIVE_CONGRATULATE + plugin.getConfigMainClass().getStrings().getGuiItemLearned();
75 | }
76 |
77 | public static String messageGuiEmcGiven(EquivalencyTech plugin, Player player, double emcBase, double emcTotal, int itemAmt, int burnRate) {
78 | return PREFIX + THEME_SUCCESS + "+" + emcTotal + " EMC " + THEME_PASSIVE + "(" + emcBase + " * " + itemAmt + ")" + THEME_ERROR + " burn rate = " + burnRate + "%" + THEME_NOTICE + " : [EMC : " + ConfigMain.getPlayerEmc(plugin, player) + "]";
79 | }
80 |
81 | public static String messageGuiEmcRemoved(EquivalencyTech plugin, Player player, double emcBase, double emcTotal, int itemAmt) {
82 | return PREFIX + THEME_ERROR + "-" + emcTotal + " EMC " + THEME_PASSIVE + "(" + emcBase + " * " + itemAmt + ") : " + THEME_NOTICE + " [EMC : " + ConfigMain.getPlayerEmc(plugin, player) + "]";
83 | }
84 |
85 | public static String messageGuiEmcNotEnough(EquivalencyTech plugin, Player player) {
86 | return PREFIX + THEME_ERROR + plugin.getConfigMainClass().getStrings().getGuiNotEnoughEmc() + THEME_NOTICE + " [EMC : " + ConfigMain.getPlayerEmc(plugin, player) + "]";
87 | }
88 |
89 | public static String messageGuiNoSpace(EquivalencyTech plugin) {
90 | return PREFIX + THEME_ERROR + plugin.getConfigMainClass().getStrings().getGeneralNoInvSpace();
91 | }
92 |
93 | public static String messageGuiItemMeta(EquivalencyTech plugin) {
94 | return PREFIX + THEME_ERROR + plugin.getConfigMainClass().getStrings().getGuiItemMeta();
95 | }
96 |
97 | // endregion
98 |
99 | // region Events
100 |
101 | public static String messageEventEMCChestPlace(EquivalencyTech plugin) {
102 | return PREFIX + THEME_ERROR + plugin.getConfigMainClass().getStrings().getEventAdjPlacement();
103 | }
104 |
105 | public static String messageEventCantOpenNotOwner(EquivalencyTech plugin) {
106 | return PREFIX + THEME_ERROR + plugin.getConfigMainClass().getStrings().getEventCantOpenNotOwner();
107 | }
108 |
109 | public static String messageEventItemSet(EquivalencyTech plugin) {
110 | return PREFIX + THEME_SUCCESS + plugin.getConfigMainClass().getStrings().getEventItemSet();
111 | }
112 |
113 | public static String messageEventItemUnset(EquivalencyTech plugin) {
114 | return PREFIX + THEME_SUCCESS + plugin.getConfigMainClass().getStrings().getEventItemUnset();
115 | }
116 |
117 | public static List messageEMC2Installed(EquivalencyTech plugin) {
118 | List message = new ArrayList<>();
119 | message.add(THEME_ERROR + "You have both EquiTech and EMC2 installed.");
120 | message.add(THEME_NOTICE + "Be warned that this may cause issues. Visit the sites below for more. This message does NOT mean you need to remove EMC2/EquiTech.");
121 | message.add("");
122 | message.add(THEME_NOTICE + "Disable this message in the EquiTech config.");
123 | message.add("");
124 | message.add( THEME_WARNING + "https://github.com/Sefiraat/EquivalencyTech/");
125 | message.add(THEME_WARNING + "https://github.com/Seggan/EMC2");
126 | return message;
127 | }
128 |
129 | // endregion
130 |
131 | }
132 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 | 4.0.0
6 |
7 | io.github.sefiraat
8 | EquivalencyTech
9 | modified
10 |
11 |
12 |
13 |
14 | org.apache.maven.plugins
15 | maven-shade-plugin
16 | 3.2.4
17 |
18 |
19 |
20 | dev.triumphteam.gui
21 | io.github.sefiraat.equivalencytech.mfgui
22 |
23 |
24 | co.aikar.commands
25 | io.github.sefiraat.equivalencytech.acf
26 |
27 |
28 | co.aikar.locales
29 | io.github.sefiraat.equivalencytech.locales
30 |
31 |
32 | org.bstats
33 | io.github.sefiraat.equivalencytech.bstats
34 |
35 |
36 |
37 |
38 |
39 | package
40 |
41 | shade
42 |
43 |
44 |
45 |
46 |
47 |
48 | org.apache.maven.plugins
49 | maven-surefire-plugin
50 | 3.0.0-M5
51 |
52 |
53 | org.junit.jupiter:junit-jupiter
54 | false
55 |
56 |
57 |
58 |
59 | org.sonarsource.scanner.maven
60 | sonar-maven-plugin
61 | 3.9.1.2184
62 |
63 |
64 |
65 | org.jacoco
66 | jacoco-maven-plugin
67 | 0.8.7
68 |
69 |
70 |
71 | prepare
72 |
73 |
74 | prepare-agent
75 |
76 |
77 |
78 |
79 | report
80 | test
81 |
82 |
83 | report
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | 1.8
93 | 1.8
94 | UTF-8
95 | Sefiraat_EquivalencyTech
96 | sefiraat
97 | https://sonarcloud.io
98 |
99 | e1,e2
100 | java:S6212
101 | **
102 |
103 | java:S125
104 | **
105 |
106 |
107 |
108 |
109 | spigot-repo
110 | https://hub.spigotmc.org/nexus/content/repositories/snapshots/
111 |
112 |
113 | papermc
114 | https://papermc.io/repo/repository/maven-public/
115 |
116 |
117 | jitpack.io
118 | https://jitpack.io
119 |
120 |
121 | aikar
122 | https://repo.aikar.co/content/groups/aikar/
123 |
124 |
125 | sk89q-repo
126 | https://maven.enginehub.org/repo/
127 |
128 |
129 | skullcreator-repo
130 | https://github.com/deanveloper/SkullCreator/raw/mvn-repo/
131 |
132 |
133 | repo
134 | https://repo.mattstudios.me/artifactory/public/
135 |
136 |
137 |
138 |
139 |
140 | org.spigotmc
141 | spigot-api
142 | 1.17-R0.1-SNAPSHOT
143 | provided
144 |
145 |
146 | com.destroystokyo.paper
147 | paper-api
148 | 1.16.5-R0.1-SNAPSHOT
149 | provided
150 |
151 |
152 | dev.triumphteam
153 | triumph-gui
154 | 3.1.1
155 |
156 |
157 | org.bstats
158 | bstats-bukkit
159 | 3.0.0
160 | compile
161 |
162 |
163 | co.aikar
164 | acf-paper
165 | 0.5.0-SNAPSHOT
166 |
167 |
168 | com.google.code.findbugs
169 | jsr305
170 | 3.0.2
171 |
172 |
173 | com.github.Slimefun
174 | Slimefun4
175 | RC-28
176 | provided
177 |
178 |
179 | io.github.thebusybiscuit
180 | cscorelib2
181 |
182 |
183 |
184 |
185 | dev.dbassett
186 | skullcreator
187 | 3.0.1
188 | compile
189 |
190 |
191 |
192 |
--------------------------------------------------------------------------------
/src/main/resources/config.yml:
--------------------------------------------------------------------------------
1 | # MAKE SURE THE VALUES BELOW ARE A GOOD REPRESENTATION OF YOUR SERVERS ECONOMY.
2 | # THE DEFAULT BURN RATE IS 0. THIS SHOULD BE SET TO BETWEEN 0 - 99
3 | # Burn Rate = % amount of EMC lost per condense. BURN_RATE: 20 = 20%
4 | auto-update: true
5 | DISABLE_EMC2_WARNING: false
6 | EMC_VALUES:
7 | BURN_RATE: 0
8 | BASE:
9 | GRASS_BLOCK: 1
10 | DIRT: 1
11 | PODZOL: 1
12 | CRIMSON_NYLIUM: 1
13 | WARPED_NYLIUM: 1
14 | COBBLESTONE: 1
15 | DIORITE: 1
16 | ANDESITE: 1
17 | GRANITE: 1
18 | OAK_SAPLING: 2
19 | SPRUCE_SAPLING: 2
20 | BIRCH_SAPLING: 2
21 | JUNGLE_SAPLING: 2
22 | ACACIA_SAPLING: 2
23 | DARK_OAK_SAPLING: 2
24 | SAND: 1
25 | RED_SAND: 1
26 | GRAVEL: 1
27 | GOLD_ORE: 0
28 | IRON_ORE: 0
29 | COAL_ORE: 0
30 | NETHER_GOLD_ORE: 0
31 | OAK_LOG: 4
32 | SPRUCE_LOG: 4
33 | BIRCH_LOG: 4
34 | JUNGLE_LOG: 4
35 | ACACIA_LOG: 4
36 | DARK_OAK_LOG: 4
37 | CRIMSON_STEM: 4
38 | WARPED_STEM: 4
39 | STRIPPED_OAK_LOG: 4
40 | STRIPPED_SPRUCE_LOG: 4
41 | STRIPPED_BIRCH_LOG: 4
42 | STRIPPED_JUNGLE_LOG: 4
43 | STRIPPED_ACACIA_LOG: 4
44 | STRIPPED_DARK_OAK_LOG: 4
45 | STRIPPED_CRIMSON_STEM: 4
46 | STRIPPED_WARPED_STEM: 4
47 | STRIPPED_OAK_WOOD: 4
48 | STRIPPED_SPRUCE_WOOD: 4
49 | STRIPPED_BIRCH_WOOD: 4
50 | STRIPPED_JUNGLE_WOOD: 4
51 | STRIPPED_ACACIA_WOOD: 4
52 | STRIPPED_DARK_OAK_WOOD: 4
53 | STRIPPED_CRIMSON_HYPHAE: 4
54 | STRIPPED_WARPED_HYPHAE: 4
55 | OAK_WOOD: 4
56 | SPRUCE_WOOD: 4
57 | BIRCH_WOOD: 4
58 | JUNGLE_WOOD: 4
59 | ACACIA_WOOD: 4
60 | DARK_OAK_WOOD: 4
61 | CRIMSON_HYPHAE: 4
62 | WARPED_HYPHAE: 4
63 | OAK_LEAVES: 1
64 | SPRUCE_LEAVES: 1
65 | BIRCH_LEAVES: 1
66 | JUNGLE_LEAVES: 1
67 | ACACIA_LEAVES: 1
68 | DARK_OAK_LEAVES: 1
69 | WET_SPONGE: 16
70 | LAPIS_ORE: 0
71 | COBWEB: 4
72 | GRASS: 1
73 | FERN: 1
74 | DEAD_BUSH: 1
75 | SEAGRASS: 1
76 | SEA_PICKLE: 4
77 | DANDELION: 2
78 | POPPY: 2
79 | BLUE_ORCHID: 2
80 | ALLIUM: 2
81 | AZURE_BLUET: 2
82 | RED_TULIP: 2
83 | ORANGE_TULIP: 2
84 | WHITE_TULIP: 2
85 | PINK_TULIP: 2
86 | OXEYE_DAISY: 2
87 | CORNFLOWER: 2
88 | LILY_OF_THE_VALLEY: 2
89 | WITHER_ROSE: 32
90 | BROWN_MUSHROOM: 4
91 | RED_MUSHROOM: 4
92 | CRIMSON_FUNGUS: 4
93 | WARPED_FUNGUS: 4
94 | CRIMSON_ROOTS: 2
95 | WARPED_ROOTS: 2
96 | WEEPING_VINES: 2
97 | TWISTING_VINES: 2
98 | SUGAR_CANE: 2
99 | KELP: 1
100 | BAMBOO: 1
101 | OBSIDIAN: 16
102 | CHORUS_PLANT: 2
103 | CHORUS_FLOWER: 8
104 | DIAMOND_ORE: 0
105 | REDSTONE_ORE: 0
106 | ICE: 1
107 | CACTUS: 1
108 | PUMPKIN: 4
109 | CARVED_PUMPKIN: 4
110 | NETHERRACK: 1
111 | SOUL_SAND: 2
112 | SOUL_SOIL: 2
113 | BASALT: 1
114 | BROWN_MUSHROOM_BLOCK: 4
115 | RED_MUSHROOM_BLOCK: 4
116 | MUSHROOM_STEM: 4
117 | VINE: 2
118 | MYCELIUM: 8
119 | LILY_PAD: 8
120 | END_STONE: 2
121 | DRAGON_EGG: 16384
122 | EMERALD_ORE: 0
123 | NETHER_QUARTZ_ORE: 0
124 | SUNFLOWER: 2
125 | LILAC: 2
126 | ROSE_BUSH: 2
127 | PEONY: 2
128 | TALL_GRASS: 1
129 | LARGE_FERN: 1
130 | TURTLE_EGG: 64
131 | DEAD_TUBE_CORAL_BLOCK: 8
132 | DEAD_BRAIN_CORAL_BLOCK: 8
133 | DEAD_BUBBLE_CORAL_BLOCK: 8
134 | DEAD_FIRE_CORAL_BLOCK: 8
135 | DEAD_HORN_CORAL_BLOCK: 8
136 | TUBE_CORAL_BLOCK: 8
137 | BRAIN_CORAL_BLOCK: 8
138 | BUBBLE_CORAL_BLOCK: 8
139 | FIRE_CORAL_BLOCK: 8
140 | HORN_CORAL_BLOCK: 8
141 | TUBE_CORAL: 8
142 | BRAIN_CORAL: 8
143 | BUBBLE_CORAL: 8
144 | FIRE_CORAL: 8
145 | HORN_CORAL: 8
146 | DEAD_TUBE_CORAL: 8
147 | DEAD_BRAIN_CORAL: 8
148 | DEAD_BUBBLE_CORAL: 8
149 | DEAD_FIRE_CORAL: 8
150 | DEAD_HORN_CORAL: 8
151 | TUBE_CORAL_FAN: 8
152 | BRAIN_CORAL_FAN: 8
153 | BUBBLE_CORAL_FAN: 8
154 | FIRE_CORAL_FAN: 8
155 | HORN_CORAL_FAN: 8
156 | DEAD_TUBE_CORAL_FAN: 8
157 | DEAD_BRAIN_CORAL_FAN: 8
158 | DEAD_BUBBLE_CORAL_FAN: 8
159 | DEAD_FIRE_CORAL_FAN: 8
160 | DEAD_HORN_CORAL_FAN: 8
161 | SCUTE: 32
162 | APPLE: 8
163 | DIAMOND: 2048
164 | IRON_INGOT: 64
165 | GOLD_INGOT: 128
166 | NETHERITE_SCRAP: 4096
167 | STRING: 4
168 | FEATHER: 2
169 | GUNPOWDER: 8
170 | WHEAT_SEEDS: 2
171 | WHEAT: 2
172 | FLINT: 1
173 | PORKCHOP: 4
174 | WATER_BUCKET: 128
175 | LAVA_BUCKET: 256
176 | SADDLE: 256
177 | REDSTONE: 16
178 | COAL: 16
179 | SNOWBALL: 2
180 | MILK_BUCKET: 256
181 | CLAY_BALL: 8
182 | SLIME_BALL: 8
183 | EGG: 4
184 | GLOWSTONE_DUST: 8
185 | COD: 64
186 | SALMON: 64
187 | TROPICAL_FISH: 128
188 | PUFFERFISH: 64
189 | INK_SAC: 16
190 | COCOA_BEANS: 16
191 | LAPIS_LAZULI: 16
192 | BONE: 4
193 | MELON_SLICE: 2
194 | BEEF: 4
195 | CHICKEN: 4
196 | ROTTEN_FLESH: 4
197 | ENDER_PEARL: 8
198 | BLAZE_ROD: 8
199 | GHAST_TEAR: 16
200 | NETHER_WART: 8
201 | SPIDER_EYE: 4
202 | EMERALD: 128
203 | CARROT: 2
204 | POTATO: 2
205 | POISONOUS_POTATO: 8
206 | SKELETON_SKULL: 128
207 | WITHER_SKELETON_SKULL: 128
208 | ZOMBIE_HEAD: 128
209 | CREEPER_HEAD: 128
210 | DRAGON_HEAD: 1024
211 | NETHER_STAR: 1024
212 | QUARTZ: 32
213 | PRISMARINE_SHARD: 8
214 | PRISMARINE_CRYSTALS: 16
215 | RABBIT: 2
216 | RABBIT_FOOT: 16
217 | RABBIT_HIDE: 2
218 | NAME_TAG: 256
219 | MUTTON: 2
220 | CHORUS_FRUIT: 4
221 | BEETROOT: 2
222 | BEETROOT_SEEDS: 2
223 | DRAGON_BREATH: 512
224 | ELYTRA: 0
225 | SHULKER_SHELL: 32
226 | TRIDENT: 512
227 | PHANTOM_MEMBRANE: 16
228 | NAUTILUS_SHELL: 128
229 | HEART_OF_THE_SEA: 8192
230 | BELL: 128
231 | SWEET_BERRIES: 2
232 | SHROOMLIGHT: 4
233 | HONEYCOMB: 1
234 | CRYING_OBSIDIAN: 64
235 | BLACKSTONE: 2
236 | GILDED_BLACKSTONE: 16
237 | HONEY_BOTTLE: 1
238 | PLAYER_HEAD: 0
239 | RAW_IRON: 32
240 | RAW_GOLD: 64
241 | RAW_COPPER: 16
242 | COPPER_INGOT: 32
243 | SLIMEFUN:
244 | COPPER_DUST: 32
245 | IRON_DUST: 32
246 | GOLD_DUST: 64
247 | TIN_DUST: 32
248 | MAGNESIUM_DUST: 32
249 | ZINC_DUST: 32
250 | LEAD_DUST: 32
251 | SILVER_DUST: 32
252 | ALUMINUM_DUST: 32
253 | NETHER_ICE: 128
254 | BUCKET_OF_OIL: 0
255 | SIFTED_ORE: 0
256 | BASIC_CIRCUIT_BOARD: 1024
257 | MESSAGES:
258 | COMMAND_SUBCOMMAND: "Please select a valid sub command"
259 | COMMAND_SELECT_ITEM: "Please select an item type"
260 | COMMAND_EMC_ITEM_MUST_HOLD: "You must be holding a item to see it's EMC value"
261 | COMMAND_EMC_NONE: "This item cannot be condensed into EMC"
262 | COMMAND_ITEM_GIVEN: "You have been given a {0}"
263 | GENERAL_NO_INVENTORY_SPACE: "You do not have enough space for this item"
264 | EVENT_CANT_OPEN_NOT_OWNER: "You cannot open an EMC block that is owned by another player."
265 | EVENT_PLACE_EMC_CHEST_ADJACENT: "You cannot place a EMC Chest next to another chest."
266 | EVENT_CHEST_ITEM_SET: "Item synthesis set to held item."
267 | EVENT_CHEST_ITEM_UNSET: "Item synthesis stopped."
268 | ITEMS:
269 | GENERAL_CRAFTING_ITEM: "Crafting Ingredient"
270 | TRANSMUTATION_ORB_NAME: "Transmutation Orb"
271 | TRANSMUTATION_ORB_LORE:
272 | - "A powerful magical artifact that"
273 | - "allows you to condense all sorts"
274 | - "of items into EMC."
275 | - "EMC can be turned into other items"
276 | - "through a simple alchemical process"
277 | TRANSMUTATION_ORB_INFO: "Right click to open"
278 | ALCHEMICAL_COAL_NAME: "Alchemical Coal"
279 | MOBIUS_FUEL_NAME: "Mobius Fuel"
280 | AETERNALIS_FUEL_NAME: "Aeternalis Fuel"
281 | DARK_MATTER_NAME: "Dark Matter"
282 | RED_MATTER_NAME: "Red Matter"
283 | DISSOLUTION_CHEST_NAME: "Dissolution Chest"
284 | DISSOLUTION_CHEST_LORE:
285 | - "This chest can break down it's contents"
286 | - "into EMC that is added into the placing"
287 | - "player's EMC pool."
288 | CONDENSATOR_CHEST_NAME: "Condensate Chest"
289 | CONDENSATOR_CHEST_LORE:
290 | - "This chest can condense EMC back into"
291 | - "items of Equivalent Value from the placing"
292 | - "player's EMC pool."
293 | - "Items synthesised in this manner require 50%"
294 | - "more EMC."
295 | CONDENSATOR_CHEST_SET_ITEM: "Shift + Right Click this chest while holding any item to set it."
296 | GUI:
297 | SLOT_BORDER_NAME: "EquiTech"
298 | SLOT_FILLER_NAME: "No recipe here"
299 | ORB_ITEM_ADDED: "You have learned how to synthesize a new item!"
300 | EMC_ITEM_WITHDRAW_ONE: "Synthesize 1"
301 | EMC_ITEM_WITHDRAW_STACK: "Synthesize Stack"
302 | EMC_INFO_NAME: "EMC Knowledge"
303 | EMC_INFO_LORE_RECIPES: "EMC Items Unlocked"
304 | EMC_NOT_ENOUGH: "Not enough EMC"
305 | EMC_ITEM_META: "Only basic items can be condensed (No enchants, names etc.)"
306 | DEBUG:
307 | SHOW_DEBUGGING_LOGS: false
--------------------------------------------------------------------------------
/.idea/uiDesigner.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | -
6 |
7 |
8 | -
9 |
10 |
11 | -
12 |
13 |
14 | -
15 |
16 |
17 | -
18 |
19 |
20 |
21 |
22 |
23 | -
24 |
25 |
26 |
27 |
28 |
29 | -
30 |
31 |
32 |
33 |
34 |
35 | -
36 |
37 |
38 |
39 |
40 |
41 | -
42 |
43 |
44 |
45 |
46 | -
47 |
48 |
49 |
50 |
51 | -
52 |
53 |
54 |
55 |
56 | -
57 |
58 |
59 |
60 |
61 | -
62 |
63 |
64 |
65 |
66 | -
67 |
68 |
69 |
70 |
71 | -
72 |
73 |
74 | -
75 |
76 |
77 |
78 |
79 | -
80 |
81 |
82 |
83 |
84 | -
85 |
86 |
87 |
88 |
89 | -
90 |
91 |
92 |
93 |
94 | -
95 |
96 |
97 |
98 |
99 | -
100 |
101 |
102 | -
103 |
104 |
105 | -
106 |
107 |
108 | -
109 |
110 |
111 | -
112 |
113 |
114 |
115 |
116 | -
117 |
118 |
119 | -
120 |
121 |
122 |
123 |
124 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/statics/ContainerStorage.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.statics;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import org.bukkit.NamespacedKey;
5 | import org.bukkit.inventory.ItemStack;
6 | import org.bukkit.inventory.meta.ItemMeta;
7 | import org.bukkit.persistence.PersistentDataContainer;
8 | import org.bukkit.persistence.PersistentDataType;
9 | import org.jetbrains.annotations.Nullable;
10 |
11 | import java.util.Objects;
12 |
13 | public final class ContainerStorage {
14 |
15 | public static final String CS_ID = "id";
16 | public static final String CS_IS_TRANSMUTATION_ORB = "is_orb";
17 | public static final String CS_IS_CRAFTING = "is_craft";
18 | public static final String CS_IS_COAL_1 = "is_coal_1";
19 | public static final String CS_IS_COAL_2 = "is_coal_2";
20 | public static final String CS_IS_COAL_3 = "is_coal_3";
21 | public static final String CS_IS_DRK = "is_drk";
22 | public static final String CS_IS_RED = "is_red";
23 | public static final String CS_IS_DISCST = "is_dis_chest";
24 | public static final String CS_IS_CONCST = "is_con_chest";
25 |
26 | public static boolean containerHasData(ItemStack i, NamespacedKey key, PersistentDataType, ?> type) {
27 | if (i != null && i.hasItemMeta()) {
28 | ItemMeta im = i.getItemMeta();
29 | assert im != null;
30 | return im.getPersistentDataContainer().has(key, type);
31 | }
32 | return false;
33 | }
34 |
35 | @Nullable
36 | public static Integer getDataInteger(ItemStack i, NamespacedKey key) {
37 | if (i.hasItemMeta()) {
38 | ItemMeta im = i.getItemMeta();
39 | assert im != null;
40 | if (im.getPersistentDataContainer().has(key, PersistentDataType.INTEGER)) {
41 | return Objects.requireNonNull(i.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.INTEGER));
42 | }
43 | }
44 | return null;
45 | }
46 |
47 | @Nullable
48 | public static Long getDataLong(ItemStack i, NamespacedKey key) {
49 | if (i.hasItemMeta()) {
50 | ItemMeta im = i.getItemMeta();
51 | assert im != null;
52 | if (im.getPersistentDataContainer().has(key, PersistentDataType.LONG)) {
53 | return Objects.requireNonNull(i.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.LONG));
54 | }
55 | }
56 | return null;
57 | }
58 |
59 | @Nullable
60 | public static String getDataString(ItemStack i, NamespacedKey key) {
61 | if (i.hasItemMeta()) {
62 | ItemMeta im = i.getItemMeta();
63 | assert im != null;
64 | if (im.getPersistentDataContainer().has(key, PersistentDataType.STRING)) {
65 | return Objects.requireNonNull(i.getItemMeta().getPersistentDataContainer().get(key, PersistentDataType.STRING));
66 | }
67 | }
68 | return null;
69 | }
70 |
71 | public static void setData(ItemStack i, NamespacedKey key, int value) {
72 | if (i.hasItemMeta()) {
73 | ItemMeta im = i.getItemMeta();
74 | assert im != null;
75 | PersistentDataContainer c = im.getPersistentDataContainer();
76 | c.set(key, PersistentDataType.INTEGER, value);
77 | i.setItemMeta(im);
78 | }
79 | }
80 |
81 | public static void setData(ItemStack i, NamespacedKey key, String value) {
82 | if (i.hasItemMeta()) {
83 | ItemMeta im = i.getItemMeta();
84 | assert im != null;
85 | PersistentDataContainer c = im.getPersistentDataContainer();
86 | c.set(key, PersistentDataType.STRING, value);
87 | i.setItemMeta(im);
88 | }
89 | }
90 |
91 | public static void setData(ItemStack i, NamespacedKey key, long value) {
92 | if (i.hasItemMeta()) {
93 | ItemMeta im = i.getItemMeta();
94 | assert im != null;
95 | PersistentDataContainer c = im.getPersistentDataContainer();
96 | c.set(key, PersistentDataType.LONG, value);
97 | i.setItemMeta(im);
98 | }
99 | }
100 |
101 | public static void removeData(ItemStack i, NamespacedKey key) {
102 | if (i.hasItemMeta()) {
103 | ItemMeta im = i.getItemMeta();
104 | assert im != null;
105 | PersistentDataContainer c = im.getPersistentDataContainer();
106 | c.remove(key);
107 | i.setItemMeta(im);
108 | }
109 | }
110 |
111 | public static void setItemID(ItemStack i, EquivalencyTech plugin, String string) {
112 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_ID);
113 | setData(i, key, string);
114 | }
115 |
116 | @Nullable
117 | public static String getItemID(ItemStack i, EquivalencyTech plugin) {
118 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_ID);
119 | return getDataString(i, key);
120 | }
121 |
122 | public static boolean isTransmutationOrb(ItemStack i, EquivalencyTech plugin) {
123 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_TRANSMUTATION_ORB);
124 | return containerHasData(i, key, PersistentDataType.INTEGER);
125 | }
126 |
127 | public static void makeTransmutationOrb(ItemStack i, EquivalencyTech plugin) {
128 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_TRANSMUTATION_ORB);
129 | setData(i, key, 1);
130 | }
131 |
132 | public static boolean isCraftable(ItemStack i, EquivalencyTech plugin) {
133 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_CRAFTING);
134 | return containerHasData(i, key, PersistentDataType.INTEGER);
135 | }
136 |
137 | public static void makeCraftable(ItemStack i, EquivalencyTech plugin) {
138 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_CRAFTING);
139 | setData(i, key, 1);
140 | }
141 |
142 | public static boolean isAlchemicalCoal(ItemStack i, EquivalencyTech plugin) {
143 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_COAL_1);
144 | return containerHasData(i, key, PersistentDataType.INTEGER);
145 | }
146 |
147 | public static void makeAlchemicalCoal(ItemStack i, EquivalencyTech plugin) {
148 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_COAL_1);
149 | setData(i, key, 1);
150 | }
151 |
152 | public static boolean isMobiusFuel(ItemStack i, EquivalencyTech plugin) {
153 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_COAL_2);
154 | return containerHasData(i, key, PersistentDataType.INTEGER);
155 | }
156 |
157 | public static void makeMobiusFuel(ItemStack i, EquivalencyTech plugin) {
158 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_COAL_2);
159 | setData(i, key, 1);
160 | }
161 |
162 | public static boolean isAeternalisFuel(ItemStack i, EquivalencyTech plugin) {
163 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_COAL_3);
164 | return containerHasData(i, key, PersistentDataType.INTEGER);
165 | }
166 |
167 | public static void makeAeternalisFuel(ItemStack i, EquivalencyTech plugin) {
168 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_COAL_3);
169 | setData(i, key, 1);
170 | }
171 |
172 | public static boolean isDarkMatter(ItemStack i, EquivalencyTech plugin) {
173 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_DRK);
174 | return containerHasData(i, key, PersistentDataType.INTEGER);
175 | }
176 |
177 | public static void makeDarkMatter(ItemStack i, EquivalencyTech plugin) {
178 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_DRK);
179 | setData(i, key, 1);
180 | }
181 |
182 | public static boolean isRedMatter(ItemStack i, EquivalencyTech plugin) {
183 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_RED);
184 | return containerHasData(i, key, PersistentDataType.INTEGER);
185 | }
186 |
187 | public static void makeRedMatter(ItemStack i, EquivalencyTech plugin) {
188 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_RED);
189 | setData(i, key, 1);
190 | }
191 |
192 | public static boolean isDisChest(ItemStack i, EquivalencyTech plugin) {
193 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_DISCST);
194 | return containerHasData(i, key, PersistentDataType.INTEGER);
195 | }
196 |
197 | public static void makeDisChest(ItemStack i, EquivalencyTech plugin) {
198 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_DISCST);
199 | setData(i, key, 1);
200 | }
201 |
202 | public static boolean isConChest(ItemStack i, EquivalencyTech plugin) {
203 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_CONCST);
204 | return containerHasData(i, key, PersistentDataType.INTEGER);
205 | }
206 |
207 | public static void makeConChest(ItemStack i, EquivalencyTech plugin) {
208 | NamespacedKey key = new NamespacedKey(plugin.getInstance(), CS_IS_CONCST);
209 | setData(i, key, 1);
210 | }
211 |
212 | private ContainerStorage() {
213 | throw new IllegalStateException("Utility class");
214 | }
215 |
216 | }
217 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/listeners/ChestPlaceListener.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.listeners;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.configuration.ConfigMain;
5 | import io.github.sefiraat.equivalencytech.misc.Utils;
6 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
7 | import io.github.sefiraat.equivalencytech.statics.Messages;
8 | import org.bukkit.Location;
9 | import org.bukkit.Material;
10 | import org.bukkit.block.Block;
11 | import org.bukkit.block.BlockFace;
12 | import org.bukkit.block.Chest;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.event.Event;
15 | import org.bukkit.event.EventHandler;
16 | import org.bukkit.event.EventPriority;
17 | import org.bukkit.event.Listener;
18 | import org.bukkit.event.block.Action;
19 | import org.bukkit.event.block.BlockBreakEvent;
20 | import org.bukkit.event.block.BlockPlaceEvent;
21 | import org.bukkit.event.player.PlayerInteractEvent;
22 | import org.bukkit.inventory.Inventory;
23 | import org.bukkit.inventory.ItemStack;
24 |
25 | import java.util.ArrayList;
26 | import java.util.List;
27 |
28 | public class ChestPlaceListener implements Listener {
29 |
30 | private final EquivalencyTech plugin;
31 |
32 | public ChestPlaceListener(EquivalencyTech plugin) {
33 | this.plugin = plugin;
34 | plugin.getServer().getPluginManager().registerEvents(this, plugin);
35 | }
36 |
37 | @EventHandler(priority = EventPriority.LOW)
38 | public void onChestPlace(BlockPlaceEvent e) {
39 | if (e.getBlockPlaced().getType() == Material.CHEST) {
40 | boolean isDis = isDis(e);
41 | boolean isCon = isCon(e);
42 | if (e.isCancelled()) {
43 | return;
44 | }
45 | if (isDis) {
46 | placeDisChest(e);
47 | return;
48 | }
49 | if (isCon) {
50 | placeConChest(e);
51 | return;
52 | }
53 | if (nearbyEMCChest(e)) {
54 | e.getPlayer().sendMessage(Messages.messageEventEMCChestPlace(plugin));
55 | e.setCancelled(true);
56 | }
57 | }
58 | }
59 |
60 | private void placeConChest(BlockPlaceEvent e) {
61 | if (noNearbyChest(e.getBlockPlaced())) {
62 | Location location = e.getBlockPlaced().getLocation();
63 | ConfigMain.addCChestStore(plugin, location);
64 | ConfigMain.setupCChest(plugin, ConfigMain.getCChestIdStore(plugin, location), e.getPlayer());
65 | } else {
66 | e.setCancelled(true);
67 | }
68 | }
69 |
70 | private void placeDisChest(BlockPlaceEvent e) {
71 | if (noNearbyChest(e.getBlockPlaced())) {
72 | Location location = e.getBlockPlaced().getLocation();
73 | ConfigMain.addDChestStore(plugin, location);
74 | ConfigMain.setupDChest(plugin, ConfigMain.getDChestIdStore(plugin, location), e.getPlayer());
75 | } else {
76 | e.setCancelled(true);
77 | }
78 | }
79 |
80 | @EventHandler
81 | public void onChestBreak(BlockBreakEvent e) {
82 | Location location = e.getBlock().getLocation();
83 | Integer disID = ConfigMain.getDChestIdStore(plugin, location);
84 | Integer conID = ConfigMain.getCChestIdStore(plugin, location);
85 | if (disID != null || conID != null) {
86 | e.setCancelled(true);
87 | Chest chest = (Chest) e.getBlock().getState();
88 | Inventory inventory = chest.getBlockInventory();
89 | for (ItemStack itemStack : inventory.getContents()) {
90 | if (itemStack != null && itemStack.getType() != Material.AIR) {
91 | e.getBlock().getWorld().dropItemNaturally(location, itemStack);
92 | itemStack.setAmount(0);
93 | }
94 | }
95 | e.getBlock().setType(Material.AIR);
96 | if (disID != null) {
97 | e.getBlock().getWorld().dropItemNaturally(location, plugin.getEqItems().getDissolutionChest().getItemClone());
98 | ConfigMain.removeDChestStore(plugin, disID);
99 | ConfigMain.removeDChest(plugin, disID);
100 | }
101 | if (conID != null) {
102 | e.getBlock().getWorld().dropItemNaturally(location, plugin.getEqItems().getCondensatorChest().getItemClone());
103 | ConfigMain.removeCChestStore(plugin, conID);
104 | ConfigMain.removeCChest(plugin, conID);
105 | }
106 | }
107 |
108 | }
109 |
110 | @EventHandler(priority = EventPriority.LOW)
111 | public void onChestInteract(PlayerInteractEvent e) {
112 | if (e.getClickedBlock() != null) {
113 | Location location = e.getClickedBlock().getLocation();
114 | Integer disID = ConfigMain.getDChestIdStore(plugin, location);
115 | Integer conID = ConfigMain.getCChestIdStore(plugin, location);
116 | if (disID != null) {
117 | if (isChestBeingOpened(e) && !hasPermissionDChest(disID, e.getPlayer())) {
118 | e.getPlayer().sendMessage(Messages.messageEventCantOpenNotOwner(plugin));
119 | e.setCancelled(true);
120 | }
121 | }
122 | if (conID != null) {
123 | if (isChestBeingOpened(e)) {
124 | openChest(e);
125 | } else if (isChestBeingSet(e)) {
126 | setChest(e);
127 | }
128 | }
129 | }
130 | }
131 |
132 |
133 | private boolean isDis(BlockPlaceEvent e) {
134 | return ContainerStorage.isDisChest(e.getItemInHand(), plugin);
135 | }
136 |
137 | private boolean isCon(BlockPlaceEvent e) {
138 | return ContainerStorage.isConChest(e.getItemInHand(), plugin);
139 | }
140 |
141 | private boolean nearbyEMCChest(BlockPlaceEvent e) {
142 | List blockList = new ArrayList<>();
143 | Block block = e.getBlockPlaced();
144 | blockList.add(block.getRelative(BlockFace.NORTH));
145 | blockList.add(block.getRelative(BlockFace.SOUTH));
146 | blockList.add(block.getRelative(BlockFace.EAST));
147 | blockList.add(block.getRelative(BlockFace.WEST));
148 | for (Block b : blockList) {
149 | if (b.getType() == Material.CHEST && (getDisId(b) != null || getConId(b) != null)) {
150 | return true;
151 | }
152 | }
153 | return false;
154 | }
155 |
156 | private boolean noNearbyChest(Block block) {
157 | List blockList = new ArrayList<>();
158 | blockList.add(block.getRelative(BlockFace.NORTH));
159 | blockList.add(block.getRelative(BlockFace.SOUTH));
160 | blockList.add(block.getRelative(BlockFace.EAST));
161 | blockList.add(block.getRelative(BlockFace.WEST));
162 | for (Block b : blockList) {
163 | if (b.getType() == Material.CHEST) {
164 | return false;
165 | }
166 | }
167 | return true;
168 | }
169 |
170 | private boolean hasPermissionDChest(Integer disId, Player player) {
171 | return ConfigMain.isOwnerDChest(plugin, player, disId) || player.isOp() || player.hasPermission("equitech.bypass");
172 | }
173 |
174 | private boolean hasPermissionCChest(Integer conId, Player player) {
175 | return ConfigMain.isOwnerCChest(plugin, player, conId) || player.isOp() || player.hasPermission("equitech.bypass");
176 | }
177 |
178 | private Integer getDisId(Block block) {
179 | return ConfigMain.getDChestIdStore(plugin, block.getLocation());
180 | }
181 |
182 | private Integer getConId(Block block) {
183 | return ConfigMain.getCChestIdStore(plugin, block.getLocation());
184 | }
185 |
186 | private boolean isChestBeingOpened(PlayerInteractEvent e) {
187 | return e.getClickedBlock().getType() == Material.CHEST &&
188 | e.getAction() == Action.RIGHT_CLICK_BLOCK &&
189 | !e.getPlayer().isSneaking() &&
190 | e.useInteractedBlock() != Event.Result.DENY;
191 | }
192 |
193 | private boolean isChestBeingSet(PlayerInteractEvent e) {
194 | return e.getClickedBlock().getType() == Material.CHEST &&
195 | e.getAction() == Action.RIGHT_CLICK_BLOCK &&
196 | e.getPlayer().isSneaking() &&
197 | e.useInteractedBlock() != Event.Result.DENY;
198 | }
199 |
200 | private void openChest(PlayerInteractEvent e) {
201 | Integer conId = getConId(e.getClickedBlock());
202 | if (conId != null && !hasPermissionCChest(conId, e.getPlayer())) {
203 | e.getPlayer().sendMessage(Messages.messageEventCantOpenNotOwner(plugin));
204 | e.setCancelled(true);
205 | }
206 | }
207 |
208 | private void setChest(PlayerInteractEvent e) {
209 | Integer conId = getConId(e.getClickedBlock());
210 | if (conId == null || hasPermissionCChest(conId, e.getPlayer())) {
211 | ItemStack itemStack = e.getPlayer().getInventory().getItemInMainHand().clone();
212 | if (itemStack.getType() == Material.AIR) {
213 | ConfigMain.setCChestItem(plugin, conId, null);
214 | e.getPlayer().sendMessage(Messages.messageEventItemUnset(plugin));
215 | return;
216 | }
217 | itemStack.setAmount(1);
218 | Double emcValue = Utils.getEMC(plugin, itemStack);
219 | if (Utils.canBeSynth(plugin, itemStack) && emcValue != null) {
220 | ConfigMain.setCChestItem(plugin, conId, itemStack);
221 | e.getPlayer().sendMessage(Messages.messageEventItemSet(plugin));
222 | } else {
223 | e.getPlayer().sendMessage(Messages.msgCmdEmcNone(plugin));
224 | }
225 | } else {
226 | e.getPlayer().sendMessage(Messages.messageEventCantOpenNotOwner(plugin));
227 | }
228 | e.setCancelled(true);
229 | }
230 |
231 |
232 | }
233 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/gui/GuiTransmutationOrb.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.gui;
2 |
3 | import dev.triumphteam.gui.builder.item.ItemBuilder;
4 | import dev.triumphteam.gui.guis.GuiItem;
5 | import dev.triumphteam.gui.guis.PaginatedGui;
6 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
7 | import io.github.sefiraat.equivalencytech.configuration.ConfigMain;
8 | import io.github.sefiraat.equivalencytech.misc.Utils;
9 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
10 | import io.github.sefiraat.equivalencytech.statics.Messages;
11 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
12 | import org.bukkit.Material;
13 | import org.bukkit.entity.Player;
14 | import org.bukkit.event.inventory.InventoryAction;
15 | import org.bukkit.event.inventory.InventoryClickEvent;
16 | import org.bukkit.inventory.ItemStack;
17 | import org.jetbrains.annotations.NotNull;
18 |
19 | import java.util.Arrays;
20 | import java.util.List;
21 |
22 | public class GuiTransmutationOrb extends PaginatedGui {
23 |
24 | public final EquivalencyTech plugin;
25 | public final Player player;
26 |
27 | protected static final List ARRAY_FILLER_SLOTS = Arrays.asList(0, 1, 2, 3, 5, 6, 7, 8, 45, 47, 48, 50, 51, 53);
28 | protected static final Integer INFO_SLOT = 4;
29 | protected static final Integer INPUT_SLOT = 49;
30 | protected static final Integer PAGE_SIZE = 36;
31 |
32 | public GuiTransmutationOrb(int rows, int pageSize, @NotNull String title, EquivalencyTech plugin, Player player) {
33 | super(rows, pageSize, title);
34 | this.plugin = plugin;
35 | this.player = player;
36 | }
37 |
38 | public static GuiTransmutationOrb buildGui(EquivalencyTech plugin, Player player) {
39 |
40 | int backSlot = 46;
41 | int forwardSlot = 52;
42 |
43 | GuiTransmutationOrb gui = new GuiTransmutationOrb(
44 | 6,
45 | GuiTransmutationOrb.PAGE_SIZE,
46 | Messages.THEME_EMC_PURPLE + plugin.getConfigMainClass().getStrings().getItemTransmutationOrbName(),
47 | plugin,
48 | player
49 | );
50 |
51 | gui.setItem(GuiTransmutationOrb.ARRAY_FILLER_SLOTS, GUIItems.guiOrbBorder(plugin));
52 | gui.setItem(GuiTransmutationOrb.INFO_SLOT, GUIItems.guiOrbInfo(plugin, player));
53 |
54 | List learnedItems = ConfigMain.getLearnedItems(plugin, player.getUniqueId().toString());
55 |
56 | int leftOverSlots = GuiTransmutationOrb.PAGE_SIZE - (learnedItems.size() % GuiTransmutationOrb.PAGE_SIZE);
57 |
58 | for (String s : learnedItems) {
59 |
60 | ItemStack itemStack;
61 | GuiItem guiItem;
62 | boolean isVanilla = false;
63 |
64 | SlimefunItem sfItem = null;
65 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
66 | sfItem = SlimefunItem.getById(s);
67 | }
68 |
69 | if (!plugin.getEqItems().getEqItemMap().containsKey(s) && sfItem == null) {
70 | isVanilla = true;
71 | }
72 |
73 | if (isVanilla) {
74 | itemStack = new ItemStack(Material.valueOf(s));
75 | } else if (sfItem != null) {
76 | itemStack = sfItem.getItem().clone();
77 | } else {
78 | itemStack = plugin.getEqItems().getEqItemMap().get(s).clone();
79 | }
80 |
81 | if (Utils.getEMC(plugin, itemStack) == null) {
82 | // A learned item has null emc - likely removed from the config post go live - skip
83 | leftOverSlots += 1;
84 | continue;
85 | }
86 |
87 | guiItem = GUIItems.guiEMCItem(plugin, itemStack, isVanilla);
88 |
89 | guiItem.setAction(event -> emcItemClicked(event, plugin));
90 | gui.addItem(guiItem);
91 | }
92 |
93 |
94 | for (int i = 0; i < leftOverSlots; i++) {
95 | gui.addItem(GUIItems.guiOrbFiller(plugin));
96 | }
97 |
98 | setInputSlot(plugin, gui);
99 |
100 | gui.setItem(backSlot, ItemBuilder.from(Material.PAPER).setName("Previous").asGuiItem(event -> {
101 | event.setCancelled(true);
102 | gui.previous();
103 | }));
104 |
105 | gui.setItem(forwardSlot, ItemBuilder.from(Material.PAPER).setName("Next").asGuiItem(event -> {
106 | event.setCancelled(true);
107 | gui.next();
108 | }));
109 |
110 | gui.setDragAction(event -> event.setCancelled(true));
111 | gui.setDefaultClickAction(event -> {
112 | if (event.isShiftClick()) {
113 | if (event.getAction() == InventoryAction.MOVE_TO_OTHER_INVENTORY && !event.getClickedInventory().equals(event.getInventory())) {
114 | inputItemAction(event, plugin, gui, true);
115 | }
116 | event.setCancelled(true);
117 | }
118 | });
119 |
120 | return gui;
121 |
122 | }
123 |
124 | private static void setInputSlot(EquivalencyTech plugin, GuiTransmutationOrb gui) {
125 | gui.addSlotAction(GuiTransmutationOrb.INPUT_SLOT, event -> {
126 | inputItemAction(event, plugin, gui, false);
127 | event.setCancelled(true);
128 | });
129 | }
130 |
131 | private static void inputItemAction(InventoryClickEvent e, EquivalencyTech plugin, PaginatedGui gui, boolean shifted) {
132 |
133 | Player player = (Player) e.getWhoClicked();
134 | ItemStack itemStack;
135 |
136 | if (shifted) {
137 | itemStack = e.getCurrentItem();
138 | } else {
139 | itemStack = player.getItemOnCursor();
140 | }
141 |
142 | boolean isEQ = ContainerStorage.isCraftable(itemStack, plugin);
143 | SlimefunItem sfItem = null;
144 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
145 | sfItem = SlimefunItem.getByItem(itemStack);
146 | }
147 |
148 | if (itemStack.hasItemMeta() && !isEQ && sfItem == null) {
149 | player.sendMessage(Messages.messageGuiItemMeta(plugin));
150 | return;
151 | }
152 |
153 | Material material = itemStack.getType();
154 | Double emcValue = Utils.getEMC(plugin, itemStack);
155 |
156 | boolean mustClose = false;
157 | if (emcValue != null) {
158 | double totalEmc = emcValue * itemStack.getAmount();
159 | String entryName;
160 | if (isEQ) {
161 | entryName = Utils.eqNameConfig(itemStack.getItemMeta().getDisplayName());
162 | } else if (sfItem != null) {
163 | entryName = sfItem.getId();
164 | } else {
165 | entryName = material.toString();
166 | }
167 | if (!ConfigMain.getLearnedItems(plugin, player.getUniqueId().toString()).contains(entryName)) {
168 | ConfigMain.addLearnedItem(plugin, player.getUniqueId().toString(), entryName);
169 | player.sendMessage(Messages.messageGuiItemLearned(plugin));
170 | mustClose = true;
171 | }
172 | ConfigMain.addPlayerEmc(plugin, player, emcValue, totalEmc, itemStack.getAmount());
173 | itemStack.setAmount(0);
174 | } else {
175 | player.sendMessage(Messages.msgCmdEmcNone(plugin));
176 | }
177 | if (mustClose) {
178 | gui.close(player);
179 | }
180 | }
181 |
182 | private static void emcItemClicked(InventoryClickEvent e, EquivalencyTech plugin) {
183 | e.setCancelled(true);
184 | switch (e.getClick()) {
185 | case LEFT:
186 | emcWithdrawOne(e, plugin);
187 | break;
188 | case RIGHT:
189 | emcWithdrawStack(e, plugin);
190 | break;
191 | default:
192 | break;
193 | }
194 | }
195 |
196 | private static void emcWithdrawOne(InventoryClickEvent e, EquivalencyTech plugin) {
197 |
198 | Player player = (Player) e.getWhoClicked();
199 |
200 | if (player.getInventory().firstEmpty() == -1) {
201 | player.sendMessage(Messages.messageGuiNoSpace(plugin));
202 | return;
203 | }
204 |
205 | ItemStack clickedItem = e.getCurrentItem();
206 | boolean isEQ = ContainerStorage.isCraftable(clickedItem, plugin);
207 | SlimefunItem sfItem = null;
208 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
209 | sfItem = SlimefunItem.getByItem(clickedItem);
210 | }
211 | double playerEmc = ConfigMain.getPlayerEmc(plugin, player);
212 | Double emcValue = Utils.getEMC(plugin, clickedItem);
213 | String itemName;
214 |
215 | if (isEQ) {
216 | itemName = Utils.eqNameConfig(clickedItem.getItemMeta().getDisplayName());
217 | } else if (sfItem != null) {
218 | itemName = sfItem.getId();
219 | } else {
220 | itemName = clickedItem.getType().toString();
221 | }
222 |
223 | if (playerEmc >= emcValue) {
224 | ItemStack itemStack;
225 | if (isEQ) {
226 | itemStack = plugin.getEqItems().getEqItemMap().get(itemName).clone();
227 | } else if (sfItem != null) {
228 | itemStack = sfItem.getItem().clone();
229 | } else {
230 | itemStack = new ItemStack(e.getCurrentItem().getType());
231 | }
232 | player.getInventory().addItem(itemStack);
233 | ConfigMain.removePlayerEmc(plugin, player, emcValue);
234 | player.sendMessage(Messages.messageGuiEmcRemoved(plugin, player, emcValue, emcValue, 1));
235 | } else {
236 | player.sendMessage(Messages.messageGuiEmcNotEnough(plugin, player));
237 | }
238 | }
239 |
240 | private static void emcWithdrawStack(InventoryClickEvent e, EquivalencyTech plugin) {
241 |
242 | Player player = (Player) e.getWhoClicked();
243 | double playerEmc = ConfigMain.getPlayerEmc(plugin, player);
244 | ItemStack clickedItem = e.getCurrentItem();
245 | Material material = clickedItem.getType();
246 |
247 | boolean isEQ = ContainerStorage.isCraftable(e.getCurrentItem(), plugin);
248 | SlimefunItem sfItem = null;
249 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
250 | sfItem = SlimefunItem.getByItem(clickedItem);
251 | }
252 |
253 | String itemName;
254 | Double emcValue = Utils.getEMC(plugin, clickedItem);
255 |
256 | if (isEQ) {
257 | itemName = Utils.eqNameConfig(e.getCurrentItem().getItemMeta().getDisplayName());
258 | } else if (sfItem != null) {
259 | itemName = sfItem.getId();
260 | } else {
261 | itemName = material.toString();
262 | }
263 |
264 | int amount = clickedItem.getMaxStackSize();
265 | if (emcValue != null) {
266 | double emcValueStack = emcValue * amount;
267 | if (player.getInventory().firstEmpty() == -1) {
268 | player.sendMessage(Messages.messageGuiNoSpace(plugin));
269 | return;
270 | }
271 | if (playerEmc < emcValueStack) {
272 | double maxPossible = playerEmc / emcValue;
273 | maxPossible = Math.floor(maxPossible);
274 | amount = (int) maxPossible;
275 | emcValueStack = emcValue * amount;
276 | }
277 | if (amount == 0) {
278 | player.sendMessage(Messages.messageGuiEmcNotEnough(plugin, player));
279 | return;
280 | }
281 |
282 | ItemStack itemStack;
283 | if (isEQ) {
284 | itemStack = plugin.getEqItems().getEqItemMap().get(itemName).clone();
285 | } else if (sfItem != null) {
286 | itemStack = sfItem.getItem().clone();
287 | } else {
288 | itemStack = new ItemStack(e.getCurrentItem().getType());
289 | }
290 |
291 | itemStack.setAmount(amount);
292 | player.getInventory().addItem(itemStack);
293 | ConfigMain.removePlayerEmc(plugin, player, emcValueStack);
294 | player.sendMessage(Messages.messageGuiEmcRemoved(plugin, player, emcValue, emcValueStack, amount));
295 | }
296 | }
297 |
298 |
299 |
300 | }
301 |
302 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/recipes/Recipes.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.recipes;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;;
4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItemStack;
5 | import org.bukkit.Material;
6 | import org.bukkit.NamespacedKey;
7 | import org.bukkit.inventory.ItemStack;
8 | import org.bukkit.inventory.Recipe;
9 | import org.bukkit.inventory.ShapedRecipe;
10 |
11 | import java.util.ArrayList;
12 | import java.util.HashMap;
13 | import java.util.List;
14 | import java.util.Map;
15 |
16 | public class Recipes {
17 |
18 | public Recipes(EquivalencyTech plugin) {
19 | addRecipes(plugin);
20 | }
21 |
22 | private void addRecipes(EquivalencyTech plugin) {
23 | plugin.getServer().addRecipe(Recipes.recipeCoal1(plugin));
24 | plugin.getServer().addRecipe(Recipes.recipeCoal2(plugin));
25 | plugin.getServer().addRecipe(Recipes.recipeCoal3(plugin));
26 | plugin.getServer().addRecipe(Recipes.recipeDarkMatter(plugin));
27 | plugin.getServer().addRecipe(Recipes.recipeRedMatter(plugin));
28 | plugin.getServer().addRecipe(Recipes.recipeTransmutationOrb(plugin));
29 | plugin.getServer().addRecipe(Recipes.recipeDissolutionChest(plugin));
30 | plugin.getServer().addRecipe(Recipes.recipeCondensatorChest(plugin));
31 | }
32 |
33 | public static Recipe recipeCoal1(EquivalencyTech plugin) {
34 | ItemStack i = plugin.getEqItems().getAlchemicalCoal().getItemClone();
35 | NamespacedKey key = new NamespacedKey(plugin, "coal1");
36 | ShapedRecipe r = new ShapedRecipe(key, i);
37 | r.shape("NNN","NN "," ");
38 | r.setIngredient('N', Material.COAL);
39 | return r;
40 | }
41 |
42 | public static List recipeCoal1Check() {
43 | List itemStacks = new ArrayList<>();
44 | itemStacks.add(new ItemStack(Material.COAL));
45 | itemStacks.add(new ItemStack(Material.COAL));
46 | itemStacks.add(new ItemStack(Material.COAL));
47 | itemStacks.add(new ItemStack(Material.COAL));
48 | itemStacks.add(new ItemStack(Material.COAL));
49 | itemStacks.add(null);
50 | itemStacks.add(null);
51 | itemStacks.add(null);
52 | itemStacks.add(null);
53 | return itemStacks;
54 | }
55 |
56 | public static Recipe recipeCoal2(EquivalencyTech plugin) {
57 | ItemStack i = plugin.getEqItems().getMobiusFuel().getItemClone();
58 | NamespacedKey key = new NamespacedKey(plugin, "coal2");
59 | ShapedRecipe r = new ShapedRecipe(key, i);
60 | r.shape("NNN","NN "," ");
61 | r.setIngredient('N', Material.PLAYER_HEAD);
62 | return r;
63 | }
64 |
65 | public static List recipeCoal2Check(EquivalencyTech plugin) {
66 | List itemStacks = new ArrayList<>();
67 | itemStacks.add(plugin.getEqItems().getAlchemicalCoal().getItemClone());
68 | itemStacks.add(plugin.getEqItems().getAlchemicalCoal().getItemClone());
69 | itemStacks.add(plugin.getEqItems().getAlchemicalCoal().getItemClone());
70 | itemStacks.add(plugin.getEqItems().getAlchemicalCoal().getItemClone());
71 | itemStacks.add(plugin.getEqItems().getAlchemicalCoal().getItemClone());
72 | itemStacks.add(null);
73 | itemStacks.add(null);
74 | itemStacks.add(null);
75 | itemStacks.add(null);
76 | return itemStacks;
77 | }
78 |
79 | public static Recipe recipeCoal3(EquivalencyTech plugin) {
80 | ItemStack i = plugin.getEqItems().getAeternalisFuel().getItemClone();
81 | NamespacedKey key = new NamespacedKey(plugin, "coal3");
82 | ShapedRecipe r = new ShapedRecipe(key, i);
83 | r.shape("NNN","NN "," ");
84 | r.setIngredient('N', Material.PLAYER_HEAD);
85 | return r;
86 | }
87 |
88 | public static List recipeCoal3Check(EquivalencyTech plugin) {
89 | List itemStacks = new ArrayList<>();
90 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
91 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
92 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
93 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
94 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
95 | itemStacks.add(null);
96 | itemStacks.add(null);
97 | itemStacks.add(null);
98 | itemStacks.add(null);
99 | return itemStacks;
100 | }
101 |
102 |
103 | public static Recipe recipeDarkMatter(EquivalencyTech plugin) {
104 | ItemStack i = plugin.getEqItems().getDarkMatter().getItemClone();
105 | NamespacedKey key = new NamespacedKey(plugin, "darkmatter");
106 | ShapedRecipe r = new ShapedRecipe(key, i);
107 | r.shape("NNN","NEN","NNN");
108 | r.setIngredient('N', Material.PLAYER_HEAD);
109 | r.setIngredient('E', Material.NETHERITE_BLOCK);
110 | return r;
111 | }
112 |
113 | public static List recipeDarkMatterCheck(EquivalencyTech plugin) {
114 | List itemStacks = new ArrayList<>();
115 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
116 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
117 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
118 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
119 | itemStacks.add(new ItemStack(Material.NETHERITE_BLOCK));
120 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
121 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
122 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
123 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
124 | return itemStacks;
125 | }
126 |
127 | public static Recipe recipeRedMatter(EquivalencyTech plugin) {
128 | ItemStack i = plugin.getEqItems().getDarkMatter().getItemClone();
129 | NamespacedKey key = new NamespacedKey(plugin, "redmatter");
130 | ShapedRecipe r = new ShapedRecipe(key, i);
131 | r.shape("NNN","EEE","NNN");
132 | r.setIngredient('N', Material.PLAYER_HEAD);
133 | r.setIngredient('E', Material.PLAYER_HEAD);
134 | return r;
135 | }
136 |
137 | public static List recipeRedMatterCheck(EquivalencyTech plugin) {
138 | List itemStacks = new ArrayList<>();
139 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
140 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
141 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
142 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
143 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
144 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
145 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
146 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
147 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
148 | return itemStacks;
149 | }
150 |
151 | public static Recipe recipeTransmutationOrb(EquivalencyTech plugin) {
152 | ItemStack i = plugin.getEqItems().getDarkMatter().getItemClone();
153 | NamespacedKey key = new NamespacedKey(plugin, "t_orb");
154 | ShapedRecipe r = new ShapedRecipe(key, i);
155 | r.shape("BDB","DRD","BDB");
156 | r.setIngredient('B', Material.DIAMOND_BLOCK);
157 | r.setIngredient('D', Material.PLAYER_HEAD);
158 | r.setIngredient('R', Material.PLAYER_HEAD);
159 | return r;
160 | }
161 |
162 |
163 | public static List recipeTransmutationOrbCheck(EquivalencyTech plugin) {
164 | List itemStacks = new ArrayList<>();
165 | itemStacks.add(new ItemStack(Material.DIAMOND_BLOCK));
166 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
167 | itemStacks.add(new ItemStack(Material.DIAMOND_BLOCK));
168 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
169 | itemStacks.add(plugin.getEqItems().getRedMatter().getItemClone());
170 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
171 | itemStacks.add(new ItemStack(Material.DIAMOND_BLOCK));
172 | itemStacks.add(plugin.getEqItems().getDarkMatter().getItemClone());
173 | itemStacks.add(new ItemStack(Material.DIAMOND_BLOCK));
174 | return itemStacks;
175 | }
176 |
177 | public static List recipeDissolutionChestCheck(EquivalencyTech plugin) {
178 | List itemStacks = new ArrayList<>();
179 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
180 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
181 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
182 | itemStacks.add(new ItemStack(Material.DIAMOND_BLOCK));
183 | itemStacks.add(new ItemStack(Material.CHEST));
184 | itemStacks.add(new ItemStack(Material.DIAMOND_BLOCK));
185 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
186 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
187 | itemStacks.add(plugin.getEqItems().getMobiusFuel().getItemClone());
188 | return itemStacks;
189 | }
190 |
191 | public static Recipe recipeDissolutionChest(EquivalencyTech plugin) {
192 | ItemStack i = plugin.getEqItems().getDarkMatter().getItemClone();
193 | NamespacedKey key = new NamespacedKey(plugin, "d_chest");
194 | ShapedRecipe r = new ShapedRecipe(key, i);
195 | r.shape("MMM","DCD","MMM");
196 | r.setIngredient('M', Material.PLAYER_HEAD);
197 | r.setIngredient('D', Material.DIAMOND_BLOCK);
198 | r.setIngredient('C', Material.CHEST);
199 | return r;
200 | }
201 |
202 | public static List recipeCondensatorChestCheck(EquivalencyTech plugin) {
203 | List itemStacks = new ArrayList<>();
204 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
205 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
206 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
207 | itemStacks.add(new ItemStack(Material.NETHERITE_BLOCK));
208 | itemStacks.add(plugin.getEqItems().getDissolutionChest().getItemClone());
209 | itemStacks.add(new ItemStack(Material.NETHERITE_BLOCK));
210 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
211 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
212 | itemStacks.add(plugin.getEqItems().getAeternalisFuel().getItemClone());
213 | return itemStacks;
214 | }
215 |
216 | public static Recipe recipeCondensatorChest(EquivalencyTech plugin) {
217 | ItemStack i = plugin.getEqItems().getDarkMatter().getItemClone();
218 | NamespacedKey key = new NamespacedKey(plugin, "c_chest");
219 | ShapedRecipe r = new ShapedRecipe(key, i);
220 | r.shape("MMM","DCD","MMM");
221 | r.setIngredient('M', Material.PLAYER_HEAD);
222 | r.setIngredient('D', Material.NETHERITE_BLOCK);
223 | r.setIngredient('C', Material.CHEST);
224 | return r;
225 | }
226 |
227 | public static ItemStack[] getSFRecipeCoal1() {
228 | return new ItemStack[] {
229 | new ItemStack(Material.COAL), new ItemStack(Material.COAL), new ItemStack(Material.COAL),
230 | new ItemStack(Material.COAL), new ItemStack(Material.COAL), null,
231 | null, null, null
232 | };
233 | }
234 |
235 | public static ItemStack[] getSFRecipeCoal2(SlimefunItemStack itemStack) {
236 | return new ItemStack[] {
237 | itemStack, itemStack, itemStack,
238 | itemStack, itemStack, null,
239 | null, null, null
240 | };
241 | }
242 |
243 | public static ItemStack[] getSFRecipeCoal3(SlimefunItemStack itemStack) {
244 | return new ItemStack[] {
245 | itemStack, itemStack, itemStack,
246 | itemStack, itemStack, null,
247 | null, null, null
248 | };
249 | }
250 |
251 | public static ItemStack[] getSFRecipeDarkMatter(SlimefunItemStack itemStack) {
252 | return new ItemStack[] {
253 | itemStack, itemStack, itemStack,
254 | itemStack, new ItemStack(Material.NETHERITE_BLOCK), itemStack,
255 | itemStack, itemStack, itemStack
256 | };
257 | }
258 |
259 | public static ItemStack[] getSFRecipeRedMatter(SlimefunItemStack fuelStack, SlimefunItemStack matterStack) {
260 | return new ItemStack[] {
261 | fuelStack, fuelStack, fuelStack,
262 | matterStack,matterStack,matterStack,
263 | fuelStack, fuelStack, fuelStack
264 | };
265 | }
266 |
267 | public static ItemStack[] getSFRecipeTransmutationOrb(SlimefunItemStack darkMatterStack, SlimefunItemStack redMatterStack) {
268 | return new ItemStack[] {
269 | new ItemStack(Material.DIAMOND_BLOCK), darkMatterStack, new ItemStack(Material.DIAMOND_BLOCK),
270 | darkMatterStack, redMatterStack, darkMatterStack,
271 | new ItemStack(Material.DIAMOND_BLOCK), darkMatterStack, new ItemStack(Material.DIAMOND_BLOCK)
272 | };
273 | }
274 |
275 | public static ItemStack[] getSFRecipeDissolutionChest(SlimefunItemStack mobiusStack) {
276 | return new ItemStack[] {
277 | mobiusStack, mobiusStack, mobiusStack,
278 | new ItemStack(Material.DIAMOND_BLOCK), new ItemStack(Material.CHEST), new ItemStack(Material.DIAMOND_BLOCK),
279 | mobiusStack, mobiusStack, mobiusStack
280 | };
281 | }
282 |
283 | public static ItemStack[] getSFRecipeCondensatorChest(SlimefunItemStack mobiusStack, SlimefunItemStack disChestStack) {
284 | return new ItemStack[] {
285 | mobiusStack, mobiusStack, mobiusStack,
286 | new ItemStack(Material.NETHERITE_BLOCK),disChestStack, new ItemStack(Material.NETHERITE_BLOCK),
287 | mobiusStack, mobiusStack, mobiusStack
288 | };
289 | }
290 |
291 | public static Map, ItemStack> getEQRecipes(EquivalencyTech plugin) {
292 | Map, ItemStack> recipes = new HashMap<>();
293 | recipes.put(recipeCoal1Check(), plugin.getEqItems().getAlchemicalCoal().getItemClone());
294 | recipes.put(recipeCoal2Check(plugin), plugin.getEqItems().getMobiusFuel().getItemClone());
295 | recipes.put(recipeCoal3Check(plugin), plugin.getEqItems().getAeternalisFuel().getItemClone());
296 | recipes.put(recipeDarkMatterCheck(plugin), plugin.getEqItems().getDarkMatter().getItemClone());
297 | recipes.put(recipeRedMatterCheck(plugin), plugin.getEqItems().getRedMatter().getItemClone());
298 | recipes.put(recipeTransmutationOrbCheck(plugin), plugin.getEqItems().getTransmutationOrb().getItemClone());
299 | recipes.put(recipeDissolutionChestCheck(plugin), plugin.getEqItems().getDissolutionChest().getItemClone());
300 | recipes.put(recipeCondensatorChestCheck(plugin), plugin.getEqItems().getCondensatorChest().getItemClone());
301 | return recipes;
302 | }
303 |
304 | public static List getEQRecipe(EquivalencyTech plugin, ItemStack itemStack) {
305 | if (itemStack.equals(plugin.getEqItems().getAlchemicalCoal().getItem())) {
306 | return recipeCoal1Check();
307 | } else if (itemStack.equals(plugin.getEqItems().getMobiusFuel().getItem())) {
308 | return recipeCoal2Check(plugin);
309 | } else if (itemStack.equals(plugin.getEqItems().getAeternalisFuel().getItem())) {
310 | return recipeCoal3Check(plugin);
311 | } else if (itemStack.equals(plugin.getEqItems().getDarkMatter().getItem())) {
312 | return recipeDarkMatterCheck(plugin);
313 | } else if (itemStack.equals(plugin.getEqItems().getRedMatter().getItem())) {
314 | return recipeRedMatterCheck(plugin);
315 | } else if (itemStack.equals(plugin.getEqItems().getTransmutationOrb().getItem())) {
316 | return recipeTransmutationOrbCheck(plugin);
317 | } else if (itemStack.equals(plugin.getEqItems().getDissolutionChest().getItem())) {
318 | return recipeDissolutionChestCheck(plugin);
319 | } else if (itemStack.equals(plugin.getEqItems().getCondensatorChest().getItem())) {
320 | return recipeCondensatorChestCheck(plugin);
321 | }
322 | return new ArrayList<>();
323 | }
324 |
325 | }
326 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/recipes/EmcDefinitions.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.recipes;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.statics.ContainerStorage;
5 | import io.github.sefiraat.equivalencytech.statics.DebugLogs;
6 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
7 | import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
8 | import io.github.thebusybiscuit.slimefun4.implementation.items.backpacks.SlimefunBackpack;
9 | import org.apache.commons.lang.StringUtils;
10 | import org.bukkit.Bukkit;
11 | import org.bukkit.Material;
12 | import org.bukkit.inventory.FurnaceRecipe;
13 | import org.bukkit.inventory.ItemStack;
14 | import org.bukkit.inventory.Recipe;
15 | import org.bukkit.inventory.ShapedRecipe;
16 | import org.bukkit.inventory.ShapelessRecipe;
17 | import org.bukkit.inventory.SmithingRecipe;
18 | import org.bukkit.inventory.StonecuttingRecipe;
19 |
20 | import javax.annotation.Nullable;
21 | import java.math.BigDecimal;
22 | import java.math.RoundingMode;
23 | import java.util.EnumMap;
24 | import java.util.HashMap;
25 | import java.util.List;
26 | import java.util.Map;
27 |
28 | public class EmcDefinitions {
29 |
30 | private final Map emcBase = new EnumMap<> (Material.class);
31 | private final Map emcSFBase = new HashMap<>();
32 | private final Map emcExtended = new EnumMap<> (Material.class);
33 | private final Map emcEQ = new HashMap<>();
34 | private final Map emcSlimefun = new HashMap<>();
35 |
36 | public Map getEmcExtended() {
37 | return emcExtended;
38 | }
39 |
40 | public Map getEmcEQ() {
41 | return emcEQ;
42 | }
43 |
44 | public Map getEmcSlimefun() {
45 | return emcSlimefun;
46 | }
47 |
48 | public EmcDefinitions(EquivalencyTech plugin) {
49 | fillBase(plugin);
50 | fillSpecialCases();
51 | fillExtended(plugin);
52 | fillEQItems(plugin);
53 | fillSlimefun(plugin);
54 | }
55 |
56 | private void fillBase(EquivalencyTech plugin) {
57 | Map h = plugin.getConfigMainClass().getEmc().getEmcBaseValues();
58 | for (Map.Entry entry : h.entrySet()) {
59 | if (Material.matchMaterial(entry.getKey()) == null) {
60 | continue;
61 | }
62 | emcBase.put(Material.matchMaterial(entry.getKey()), entry.getValue());
63 | DebugLogs.logEmcBaseValueLoaded(plugin, entry.getKey(), entry.getValue());
64 | }
65 | Map slimefunBase = plugin.getConfigMainClass().getEmc().getEmcSlimefunValues();
66 | for (Map.Entry entry : slimefunBase.entrySet()) {
67 | emcSFBase.put(entry.getKey(), entry.getValue());
68 | DebugLogs.logEmcBaseValueLoaded(plugin, entry.getKey(), entry.getValue());
69 | }
70 | }
71 |
72 | private void fillSpecialCases() {
73 | // Used to escape loops where the item isn't BASe but also has a reversing craft.
74 | emcExtended.put(Material.NETHERITE_INGOT, specialCaseNetheriteIngot());
75 | emcExtended.put(Material.DRIED_KELP, specialCaseDriedKelp());
76 | emcExtended.put(Material.BONE_MEAL, specialCaseBoneMeal());
77 | }
78 |
79 | private Double specialCaseNetheriteIngot() {
80 | return (emcBase.get(Material.GOLD_INGOT) * 4) + (emcBase.get(Material.NETHERITE_SCRAP) * 4);
81 | }
82 | private Double specialCaseDriedKelp() {
83 | return emcBase.get(Material.KELP);
84 | }
85 | private Double specialCaseBoneMeal() {
86 | return emcBase.get(Material.BONE) / 3;
87 | }
88 |
89 | private void fillExtended(EquivalencyTech plugin) {
90 | for (Material m : Material.values()) {
91 | if (!m.isLegacy() && m.isItem()) {
92 | ItemStack i = new ItemStack(m);
93 | Double emcValue = getEmcValue(plugin, i, 1);
94 | if (emcValue != null) {
95 | DebugLogs.logEmcPosted(plugin, emcValue, 1);
96 | emcExtended.put(i.getType(), roundDown(emcValue,2));
97 | } else {
98 | DebugLogs.logEmcNull(plugin, 1);
99 | }
100 | }
101 | }
102 | }
103 |
104 | private void fillEQItems(EquivalencyTech plugin) {
105 | for (Map.Entry, ItemStack> recipeMap : Recipes.getEQRecipes(plugin).entrySet()) {
106 | ItemStack checkedItem = recipeMap.getValue();
107 | DebugLogs.logBoring(plugin, checkedItem.getItemMeta().getDisplayName());
108 | Double itemAmount = 0D;
109 | for (ItemStack recipeItem : recipeMap.getKey()) {
110 | Double testAmount = getEQEmcValue(plugin, recipeItem, 1);
111 | if (testAmount != null) {
112 | itemAmount += testAmount;
113 | }
114 | }
115 | DebugLogs.logBoring(plugin, checkedItem.getItemMeta().getDisplayName() + " added to EQ for : " + itemAmount);
116 | emcEQ.put(checkedItem.getItemMeta().getDisplayName(), roundDown(itemAmount,2));
117 | }
118 | }
119 |
120 | private void fillSlimefun(EquivalencyTech plugin) {
121 | if (EquivalencyTech.getInstance().getManagerSupportedPlugins().isInstalledSlimefun()) {
122 | for (SlimefunItem item : Slimefun.getRegistry().getEnabledSlimefunItems()) {
123 | if (item instanceof SlimefunBackpack || !item.getAddon().getName().equals("Slimefun")) {
124 | continue;
125 | }
126 | DebugLogs.logBoring(plugin, item.getId() + " being checked");
127 | Double emcValue = getSFEmcValue(plugin, item.getItem(), 1);
128 | if (emcValue != null && emcValue != 0D) {
129 | DebugLogs.logEmcPosted(plugin, emcValue, 1);
130 | emcSlimefun.put(item.getId(), roundDown(emcValue,2));
131 | } else {
132 | DebugLogs.logEmcNull(plugin, 1);
133 | }
134 | }
135 | }
136 | }
137 |
138 | private Double getSFEmcValue(EquivalencyTech plugin, ItemStack item, Integer nestLevel) {
139 | SlimefunItem sfItem = SlimefunItem.getByItem(item);
140 | if (sfItem == null) { // Vanilla
141 | DebugLogs.logBoring(plugin, item.getType().toString() + StringUtils.repeat(" >", nestLevel) + " Vanilla - getting found vanilla value");
142 | return getEmcValue(plugin, item, nestLevel + 1);
143 | }
144 | if (emcSFBase.containsKey(sfItem.getId())) {
145 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Item in SF Base");
146 | Double emcBaseValue = emcSFBase.get(sfItem.getId());
147 | if (emcBaseValue == 0) {
148 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Zero base val");
149 | return null;
150 | } else {
151 | DebugLogs.logEmcIsBase(plugin, emcBaseValue, nestLevel);
152 | return emcBaseValue;
153 | }
154 | }
155 | if (emcSlimefun.containsKey(sfItem.getId())) { // Is Slimefun and already calculated
156 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Already calculated at : " + emcSlimefun.get(sfItem.getId()));
157 | return emcSlimefun.get(sfItem.getId());
158 | }
159 | ItemStack[] recipe = sfItem.getRecipe();
160 | Double amount = 0D;
161 | if (recipe == null) {
162 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Not in base and no recipes. Nulling out.");
163 | return null;
164 | }
165 | for (ItemStack recipeItem : recipe) {
166 | if (recipeItem != null) {
167 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Checking recipe item");
168 | Double stackAmount = getSFEmcValue(plugin, recipeItem, nestLevel + 1);
169 | if (stackAmount == null) {
170 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Null");
171 | return null;
172 | }
173 | amount += (stackAmount / sfItem.getRecipeOutput().getAmount());
174 | }
175 | }
176 | if (amount == 0D) {
177 | DebugLogs.logBoring(plugin, sfItem.getId() + StringUtils.repeat(" >", nestLevel) + " Stack is null due to 0. If base items is missing?");
178 | return null;
179 | }
180 | return amount;
181 | }
182 |
183 | @Nullable
184 | private Double getEQEmcValue(EquivalencyTech plugin, ItemStack itemStack, Integer nestLevel) {
185 | if (itemStack != null) {
186 | DebugLogs.logEQStart(plugin, nestLevel, itemStack);
187 | if (ContainerStorage.isCraftable(itemStack, plugin)) {
188 | double amount = 0D;
189 | DebugLogs.logEQisCrafting(plugin, nestLevel);
190 | if (emcEQ.containsKey(itemStack.getItemMeta().getDisplayName())) {
191 | amount = getEmcEQ().get(itemStack.getItemMeta().getDisplayName());
192 | DebugLogs.logEmcIsRegisteredExtended(plugin, amount, nestLevel);
193 | } else {
194 | List itemStacks = Recipes.getEQRecipe(plugin, itemStack);
195 | for (ItemStack itemStack1 : itemStacks) {
196 | if (itemStack1 != null) {
197 | Double stackAmount = getEQEmcValue(plugin, itemStack1, nestLevel + 1);
198 | if (stackAmount != null) {
199 | amount += stackAmount;
200 | } else {
201 | DebugLogs.logEmcNull(plugin, nestLevel);
202 | return null;
203 | }
204 | }
205 | }
206 | }
207 | return amount;
208 | } else {
209 | DebugLogs.logEQisNotCrafting(plugin, nestLevel);
210 | return getEmcValue(plugin, itemStack, nestLevel + 1);
211 | }
212 | } else {
213 | return 0D;
214 | }
215 | }
216 |
217 | @Nullable
218 | private Double getEmcValue(EquivalencyTech plugin, ItemStack i, Integer nestLevel) {
219 | List recipeList = Bukkit.getServer().getRecipesFor(i);
220 | Material m = i.getType();
221 | Double eVal = 0D;
222 | DebugLogs.logEmcTestingItemStack(plugin, i.getType().name(), nestLevel);
223 | if (nestLevel > 15) {
224 | // Recipe is most likely looping and should abort. Need a better method
225 | return null;
226 | }
227 | if (emcBase.containsKey(m)) {
228 | // Item is in the base list (config.yml) draw from there first
229 | Double emcBaseValue = emcBase.get(m);
230 | if (emcBaseValue == 0) {
231 | return null;
232 | } else {
233 | DebugLogs.logEmcIsBase(plugin, emcBaseValue, nestLevel);
234 | return emcBaseValue;
235 | }
236 | } else if (emcExtended.containsKey(m)) {
237 | // Item is in the extended list (already registered during fillExtended)
238 | DebugLogs.logEmcIsRegisteredExtended(plugin, emcExtended.get(m), nestLevel);
239 | return emcExtended.get(m);
240 | } else if (recipeList.isEmpty()) {
241 | // Recipe is not in Base and has no recipes, so it cannot be EMC'd
242 | DebugLogs.logEmcNoRecipes(plugin, nestLevel);
243 | return null;
244 | } else {
245 | // Item not yet registered but DOES have valid recipes, lets check them out!
246 | for (Recipe r : Bukkit.getServer().getRecipesFor(i)) {
247 | Double tempVal = checkRecipe(plugin, r,nestLevel + 1);
248 | if (tempVal != null && (eVal.equals(0D) || tempVal < eVal)) {
249 | DebugLogs.logRecipeCheaper(plugin, nestLevel);
250 | eVal = tempVal;
251 | } else if (tempVal != null) {
252 | DebugLogs.logRecipeNotCheaper(plugin, nestLevel);
253 | }
254 | }
255 | }
256 | DebugLogs.logEmcRecipeResult(plugin, eVal, nestLevel);
257 | return eVal;
258 | }
259 |
260 | private Double roundDown(Double value, int places) {
261 | BigDecimal decimal = BigDecimal.valueOf(value);
262 | decimal = decimal.setScale(places, RoundingMode.DOWN);
263 | return decimal.doubleValue();
264 | }
265 |
266 | @Nullable
267 | private Double checkRecipe(EquivalencyTech plugin, Recipe recipe, Integer nestLevel) {
268 |
269 | DebugLogs.logCheckingRecipe(plugin, nestLevel);
270 |
271 | if (recipe instanceof ShapedRecipe) {
272 | ShapedRecipe shapedRecipe = (ShapedRecipe) recipe;
273 | return checkShaped(plugin, shapedRecipe, nestLevel);
274 | } else if (recipe instanceof ShapelessRecipe) {
275 | ShapelessRecipe shapelessRecipe = (ShapelessRecipe) recipe;
276 | return checkShapeless(plugin, shapelessRecipe, nestLevel);
277 | } else if (recipe instanceof FurnaceRecipe) {
278 | FurnaceRecipe furnaceRecipe = (FurnaceRecipe) recipe;
279 | return checkFurnace(plugin, furnaceRecipe, nestLevel);
280 | } else if (recipe instanceof StonecuttingRecipe) {
281 | StonecuttingRecipe stonecuttingRecipe = (StonecuttingRecipe) recipe;
282 | return checkStoneCutter(plugin, stonecuttingRecipe, nestLevel);
283 | } else if (recipe instanceof SmithingRecipe) {
284 | SmithingRecipe smithingRecipe = (SmithingRecipe) recipe;
285 | return checkSmithing(plugin, smithingRecipe, nestLevel);
286 | }
287 |
288 | return null;
289 | }
290 |
291 | @Nullable
292 | private Double checkShaped(EquivalencyTech plugin, ShapedRecipe recipe, int nestLevel) {
293 | DebugLogs.logRecipeType(plugin, "Shaped", nestLevel);
294 | double eVal= 0D;
295 | for (ItemStack i2 : recipe.getIngredientMap().values()) {
296 | if (i2 != null) {
297 | Double prVal = 0D;
298 | if (!i2.getType().equals(Material.AIR)) {
299 | prVal = getEmcValue(plugin, i2, nestLevel + 1);
300 | }
301 | if (prVal != null) {
302 | if (recipe.getResult().getAmount() > 1) {
303 | DebugLogs.logRecipeMultipleOutputs(plugin, prVal, recipe.getResult().getAmount(), nestLevel);
304 | eVal = eVal + (prVal / recipe.getResult().getAmount());
305 | } else {
306 | eVal = eVal + prVal;
307 | }
308 | } else {
309 | return null;
310 | }
311 | }
312 | }
313 | return eVal;
314 | }
315 |
316 | @Nullable
317 | private Double checkShapeless(EquivalencyTech plugin, ShapelessRecipe recipe, int nestLevel) {
318 | DebugLogs.logRecipeType(plugin, "Shapeless", nestLevel);
319 | Double eVal = 0D;
320 | for (ItemStack i2 : recipe.getIngredientList()) {
321 | Double prVal;
322 | prVal = getEmcValue(plugin, i2, nestLevel + 1);
323 | if (prVal != null) {
324 | if (recipe.getResult().getAmount() > 1) {
325 | DebugLogs.logRecipeMultipleOutputs(plugin, prVal, recipe.getResult().getAmount(), nestLevel);
326 | eVal = eVal + (prVal / recipe.getResult().getAmount());
327 | } else {
328 | eVal = eVal + prVal;
329 | }
330 | } else {
331 | return null;
332 | }
333 | }
334 | return eVal;
335 | }
336 |
337 | @Nullable
338 | private Double checkFurnace(EquivalencyTech plugin, FurnaceRecipe recipe, int nestLevel) {
339 | DebugLogs.logRecipeType(plugin, "Furnace", nestLevel);
340 | Double prVal;
341 | prVal = getEmcValue(plugin, recipe.getInput(), nestLevel + 1);
342 | if (prVal != null) {
343 | if (recipe.getResult().getAmount() > 1) {
344 | DebugLogs.logRecipeMultipleOutputs(plugin, prVal, recipe.getResult().getAmount(), nestLevel);
345 | return prVal / recipe.getResult().getAmount();
346 | } else {
347 | return prVal;
348 | }
349 | } else {
350 | return null;
351 | }
352 | }
353 |
354 | @Nullable
355 | private Double checkStoneCutter(EquivalencyTech plugin, StonecuttingRecipe recipe, int nestLevel) {
356 | DebugLogs.logRecipeType(plugin, "Stonecutting", nestLevel);
357 | Double prVal;
358 | prVal = getEmcValue(plugin, recipe.getInput(), nestLevel + 1);
359 | if (prVal != null) {
360 | if (recipe.getResult().getAmount() > 1) {
361 | DebugLogs.logRecipeMultipleOutputs(plugin, prVal, recipe.getResult().getAmount(), nestLevel);
362 | return prVal / recipe.getResult().getAmount();
363 | } else {
364 | return prVal;
365 | }
366 | } else {
367 | return null;
368 | }
369 | }
370 |
371 | @Nullable
372 | private Double checkSmithing(EquivalencyTech plugin, SmithingRecipe recipe, int nestLevel) {
373 | DebugLogs.logRecipeType(plugin, "Smithing", nestLevel);
374 | Double baseVal;
375 | Double additionVal;
376 | baseVal = getEmcValue(plugin, recipe.getBase().getItemStack(), nestLevel + 1);
377 | additionVal = getEmcValue(plugin, recipe.getAddition().getItemStack(), nestLevel + 1);
378 | if (baseVal != null && additionVal != null) {
379 | double combinedVal = (baseVal + additionVal);
380 | if (recipe.getResult().getAmount() > 1) {
381 | DebugLogs.logRecipeMultipleOutputs(plugin, baseVal, recipe.getResult().getAmount(), nestLevel);
382 | return combinedVal / recipe.getResult().getAmount();
383 | } else {
384 | return combinedVal;
385 | }
386 | } else {
387 | return null;
388 | }
389 | }
390 |
391 | @Nullable
392 | public Double getEmcValue(Material material) {
393 | if (emcExtended.containsKey(material)) {
394 | return emcExtended.get(material);
395 | }
396 | return null;
397 | }
398 |
399 | }
400 |
--------------------------------------------------------------------------------
/src/main/java/io/github/sefiraat/equivalencytech/configuration/ConfigMain.java:
--------------------------------------------------------------------------------
1 | package io.github.sefiraat.equivalencytech.configuration;
2 |
3 | import io.github.sefiraat.equivalencytech.EquivalencyTech;
4 | import io.github.sefiraat.equivalencytech.misc.Utils;
5 | import io.github.sefiraat.equivalencytech.statics.Messages;
6 | import org.bukkit.ChatColor;
7 | import org.bukkit.Location;
8 | import org.bukkit.configuration.ConfigurationSection;
9 | import org.bukkit.configuration.InvalidConfigurationException;
10 | import org.bukkit.configuration.file.FileConfiguration;
11 | import org.bukkit.configuration.file.YamlConfiguration;
12 | import org.bukkit.entity.Player;
13 | import org.bukkit.inventory.ItemStack;
14 |
15 | import javax.annotation.Nullable;
16 | import java.io.File;
17 | import java.io.IOException;
18 | import java.util.ArrayList;
19 | import java.util.List;
20 |
21 | public class ConfigMain {
22 |
23 | private final EquivalencyTech plugin;
24 |
25 | private final ConfigStrings strings;
26 | private final ConfigEMC emc;
27 | private final ConfigBooleans bools;
28 |
29 | private File learnedItemsConfigFile;
30 | private FileConfiguration learnedItemsConfig;
31 | private File playerEMCConfigFile;
32 | private FileConfiguration playerEMCConfig;
33 | private File blockStoreConfigFile;
34 | private FileConfiguration blockStoreConfig;
35 | private File dChestConfigFile;
36 | private FileConfiguration dChestConfig;
37 | private File cChestConfigFile;
38 | private FileConfiguration cChestConfig;
39 |
40 | public ConfigStrings getStrings() {
41 | return strings;
42 | }
43 | public ConfigEMC getEmc() {
44 | return emc;
45 | }
46 | public ConfigBooleans getBools() {
47 | return bools;
48 | }
49 |
50 | public File getLearnedItemsConfigFile() {
51 | return learnedItemsConfigFile;
52 | }
53 |
54 | public FileConfiguration getLearnedItemsConfig() {
55 | return learnedItemsConfig;
56 | }
57 |
58 | public File getPlayerEMCConfigFile() {
59 | return playerEMCConfigFile;
60 | }
61 |
62 | public FileConfiguration getPlayerEMCConfig() {
63 | return playerEMCConfig;
64 | }
65 |
66 | public File getBlockStoreConfigFile() {
67 | return blockStoreConfigFile;
68 | }
69 |
70 | public FileConfiguration getBlockStoreConfig() {
71 | return blockStoreConfig;
72 | }
73 |
74 | public File getDChestConfigFile() {
75 | return dChestConfigFile;
76 | }
77 |
78 | public FileConfiguration getDChestConfig() {
79 | return dChestConfig;
80 | }
81 |
82 | public File getCChestConfigFile() {
83 | return cChestConfigFile;
84 | }
85 |
86 | public FileConfiguration getCChestConfig() {
87 | return cChestConfig;
88 | }
89 |
90 | public static final String DIS_CHEST_CFG = "DIS_CHESTS";
91 | public static final String CON_CHEST_CFG = "CON_CHESTS";
92 |
93 | public ConfigMain(EquivalencyTech plugin) {
94 |
95 | this.plugin = plugin;
96 |
97 | strings = new ConfigStrings(plugin);
98 | emc = new ConfigEMC(plugin);
99 | bools = new ConfigBooleans(plugin);
100 |
101 | sortConfigs();
102 | }
103 |
104 | private void sortConfigs() {
105 | plugin.getConfig().options().copyDefaults(true);
106 | plugin.saveConfig();
107 | createAdditionalConfigs();
108 | }
109 |
110 | private void createAdditionalConfigs() {
111 | createLearnedConfig();
112 | createEmcConfig();
113 | createBlockStoreConfig();
114 | createDChestConfig();
115 | createCChestConfig();
116 | }
117 |
118 | public void saveAdditionalConfigs() {
119 | saveEmcConfig();
120 | saveLearnedConfig();
121 | saveBlockStoreConfig();
122 | saveDChestConfig();
123 | saveCChestConfig();
124 | }
125 |
126 | private void createLearnedConfig() {
127 | learnedItemsConfigFile = new File(plugin.getDataFolder(), "learned_items.yml");
128 | if (!learnedItemsConfigFile.exists()) {
129 | learnedItemsConfigFile.getParentFile().mkdirs();
130 | plugin.saveResource("learned_items.yml", false);
131 | }
132 | learnedItemsConfig = new YamlConfiguration();
133 | try {
134 | learnedItemsConfig.load(learnedItemsConfigFile);
135 | } catch (IOException | InvalidConfigurationException e) {
136 | e.printStackTrace();
137 | }
138 | }
139 |
140 | private void saveLearnedConfig() {
141 | try {
142 | learnedItemsConfig.save(learnedItemsConfigFile);
143 | } catch (IOException e) {
144 | plugin.getLogger().warning("Unable to save " + learnedItemsConfigFile.getName());
145 | }
146 | }
147 |
148 | private void createEmcConfig() {
149 | playerEMCConfigFile = new File(plugin.getDataFolder(), "player_emc.yml");
150 | if (!playerEMCConfigFile.exists()) {
151 | playerEMCConfigFile.getParentFile().mkdirs();
152 | plugin.saveResource("player_emc.yml", false);
153 | }
154 | playerEMCConfig = new YamlConfiguration();
155 | try {
156 | playerEMCConfig.load(playerEMCConfigFile);
157 | } catch (IOException | InvalidConfigurationException e) {
158 | e.printStackTrace();
159 | }
160 | }
161 |
162 | private void saveEmcConfig() {
163 | try {
164 | playerEMCConfig.save(playerEMCConfigFile);
165 | } catch (IOException e) {
166 | plugin.getLogger().warning("Unable to save " + playerEMCConfigFile.getName());
167 | }
168 | }
169 |
170 | private void createBlockStoreConfig() {
171 | blockStoreConfigFile = new File(plugin.getDataFolder(), "block_storage.yml");
172 | if (!blockStoreConfigFile.exists()) {
173 | blockStoreConfigFile.getParentFile().mkdirs();
174 | plugin.saveResource("block_storage.yml", false);
175 | }
176 | blockStoreConfig = new YamlConfiguration();
177 | try {
178 | blockStoreConfig.load(blockStoreConfigFile);
179 | } catch (IOException | InvalidConfigurationException e) {
180 | e.printStackTrace();
181 | }
182 | }
183 |
184 | private void saveBlockStoreConfig() {
185 | try {
186 | blockStoreConfig.save(blockStoreConfigFile);
187 | } catch (IOException e) {
188 | plugin.getLogger().warning("Unable to save " + blockStoreConfigFile.getName());
189 | }
190 | }
191 |
192 | private void createDChestConfig() {
193 | dChestConfigFile = new File(plugin.getDataFolder(), "dissolution_chests.yml");
194 | if (!dChestConfigFile.exists()) {
195 | dChestConfigFile.getParentFile().mkdirs();
196 | plugin.saveResource("dissolution_chests.yml", false);
197 | }
198 | dChestConfig = new YamlConfiguration();
199 | try {
200 | dChestConfig.load(dChestConfigFile);
201 | } catch (IOException | InvalidConfigurationException e) {
202 | e.printStackTrace();
203 | }
204 | }
205 |
206 | private void saveDChestConfig() {
207 | try {
208 | dChestConfig.save(dChestConfigFile);
209 | } catch (IOException e) {
210 | plugin.getLogger().warning("Unable to save " + dChestConfigFile.getName());
211 | }
212 | }
213 |
214 | private void createCChestConfig() {
215 | cChestConfigFile = new File(plugin.getDataFolder(), "condensation_chests.yml");
216 | if (!cChestConfigFile.exists()) {
217 | cChestConfigFile.getParentFile().mkdirs();
218 | plugin.saveResource("condensation_chests.yml", false);
219 | }
220 | cChestConfig = new YamlConfiguration();
221 | try {
222 | cChestConfig.load(cChestConfigFile);
223 | } catch (IOException | InvalidConfigurationException e) {
224 | e.printStackTrace();
225 | }
226 | }
227 |
228 | private void saveCChestConfig() {
229 | try {
230 | cChestConfig.save(cChestConfigFile);
231 | } catch (IOException e) {
232 | plugin.getLogger().warning("Unable to save " + cChestConfigFile.getName());
233 | }
234 | }
235 |
236 | public static void addLearnedItem(EquivalencyTech plugin, String uuid, String itemName) {
237 | FileConfiguration c = plugin.getConfigMainClass().getLearnedItemsConfig();
238 | c.set(uuid + "." + ChatColor.stripColor(itemName), true);
239 | }
240 |
241 | public static void removeLearnedItem(EquivalencyTech plugin, Player player, String itemName) {
242 | FileConfiguration c = plugin.getConfigMainClass().getLearnedItemsConfig();
243 | c.set(player.getUniqueId().toString() + "." + itemName, null);
244 | }
245 |
246 | public static List getLearnedItems(EquivalencyTech plugin, String uuid) {
247 | FileConfiguration c = plugin.getConfigMainClass().getLearnedItemsConfig();
248 | List list = new ArrayList<>();
249 | if (c.contains(uuid)) {
250 | list.addAll(c.getConfigurationSection(uuid).getKeys(false));
251 | java.util.Collections.sort(list);
252 | }
253 | return list;
254 | }
255 |
256 | public static int getLearnedItemAmount(EquivalencyTech plugin, Player player) {
257 | return getLearnedItems(plugin, player.getUniqueId().toString()).size();
258 | }
259 |
260 | public static void addPlayerEmc(EquivalencyTech plugin, Player player, Double emcValue, Double totalEmc, int stackAmount) {
261 | double playerEmc = getPlayerEmc(plugin, player);
262 | int burnRate = plugin.getConfigMainClass().getEmc().getBurnRate();
263 | if (burnRate > 0) {
264 | totalEmc -= ((totalEmc / 100) * burnRate);
265 | }
266 | totalEmc = Utils.roundDown(totalEmc, 2);
267 | Double sum = playerEmc + totalEmc;
268 | if (sum.equals(Double.POSITIVE_INFINITY)) {
269 | sum = Double.MAX_VALUE;
270 | }
271 | setPlayerEmc(plugin, player, sum);
272 | player.sendMessage(Messages.messageGuiEmcGiven(plugin, player, emcValue, totalEmc, stackAmount, burnRate));
273 | }
274 |
275 | public static void addPlayerEmc(EquivalencyTech plugin, String uuid, Double totalEmc) {
276 | double playerEmc = getPlayerEmc(plugin, uuid);
277 | int burnRate = plugin.getConfigMainClass().getEmc().getBurnRate();
278 | if (burnRate > 0) {
279 | totalEmc -= ((totalEmc / 100) * burnRate);
280 | }
281 | totalEmc = Utils.roundDown(totalEmc, 2);
282 | Double sum = playerEmc + totalEmc;
283 | if (sum.equals(Double.POSITIVE_INFINITY)) {
284 | sum = Double.MAX_VALUE;
285 | }
286 | setPlayerEmc(plugin, uuid, sum);
287 | }
288 |
289 | public static void removePlayerEmc(EquivalencyTech plugin, Player player, Double emcValue) {
290 | setPlayerEmc(plugin, player, getPlayerEmc(plugin, player) - emcValue);
291 | }
292 |
293 | public static void removePlayerEmc(EquivalencyTech plugin, String uuid, Double emcValue) {
294 | setPlayerEmc(plugin, uuid, getPlayerEmc(plugin, uuid) - emcValue);
295 | }
296 |
297 | public static void setPlayerEmc(EquivalencyTech plugin, Player player, Double emcValue) {
298 | FileConfiguration c = plugin.getConfigMainClass().getPlayerEMCConfig();
299 | c.set(player.getUniqueId().toString(), emcValue);
300 | }
301 |
302 | public static void setPlayerEmc(EquivalencyTech plugin, String uuid, Double emcValue) {
303 | FileConfiguration c = plugin.getConfigMainClass().getPlayerEMCConfig();
304 | c.set(uuid, emcValue);
305 | }
306 |
307 | public static double getPlayerEmc(EquivalencyTech plugin, Player player) {
308 | FileConfiguration c = plugin.getConfigMainClass().getPlayerEMCConfig();
309 | double amount = 0;
310 | if (c.contains(player.getUniqueId().toString())) {
311 | amount = Utils.roundDown(c.getDouble(player.getUniqueId().toString()),2);
312 | }
313 | return amount;
314 | }
315 |
316 | public static double getPlayerEmc(EquivalencyTech plugin, String uuid) {
317 | FileConfiguration c = plugin.getConfigMainClass().getPlayerEMCConfig();
318 | double amount = 0;
319 | if (c.contains(uuid)) {
320 | amount = c.getDouble(uuid);
321 | }
322 | return amount;
323 | }
324 |
325 |
326 | public static Integer getNextDChestID(EquivalencyTech plugin) {
327 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
328 | ConfigurationSection section = c.getConfigurationSection(DIS_CHEST_CFG);
329 | int nextValue = 1;
330 | if (section != null) {
331 | for (String key : section.getKeys(false)) {
332 | int value = Integer.parseInt(key);
333 | if (value > nextValue) {
334 | nextValue = value;
335 | }
336 | }
337 | nextValue++;
338 | }
339 | return nextValue;
340 | }
341 |
342 | public static void addDChestStore(EquivalencyTech plugin, Location location) {
343 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
344 | c.set(DIS_CHEST_CFG + "." + getNextDChestID(plugin).toString(), location);
345 | }
346 |
347 | @Nullable
348 | public static Integer getDChestIdStore(EquivalencyTech plugin, Location location) {
349 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
350 | ConfigurationSection section = c.getConfigurationSection(DIS_CHEST_CFG);
351 | if (section != null) {
352 | for (String key : section.getKeys(false)) {
353 | Location l = section.getLocation(key);
354 | if (l.equals(location)) {
355 | return Integer.parseInt(key);
356 | }
357 | }
358 | }
359 | return null;
360 | }
361 |
362 | public static void removeDChestStore(EquivalencyTech plugin, Integer id) {
363 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
364 | ConfigurationSection section = c.getConfigurationSection(DIS_CHEST_CFG);
365 | section.set(id.toString(), null);
366 | }
367 |
368 | public static void setupDChest(EquivalencyTech plugin, Integer id, Player player) {
369 | FileConfiguration c = plugin.getConfigMainClass().dChestConfig;
370 | c.set(id + ".OWNING_PLAYER", player.getUniqueId().toString());
371 | c.set(id + ".LEVEL", 1);
372 | }
373 |
374 | public static void removeDChest(EquivalencyTech plugin, Integer id) {
375 | FileConfiguration c = plugin.getConfigMainClass().dChestConfig;
376 | c.set(String.valueOf(id), null);
377 | }
378 |
379 | public static boolean isOwnerDChest(EquivalencyTech plugin, Player player, Integer id) {
380 | FileConfiguration c = plugin.getConfigMainClass().dChestConfig;
381 | return c.getString(id + ".OWNING_PLAYER").equals(player.getUniqueId().toString());
382 | }
383 |
384 | public static String getOwnerDChest(EquivalencyTech plugin, Integer id) {
385 | FileConfiguration c = plugin.getConfigMainClass().dChestConfig;
386 | return c.getString(id + ".OWNING_PLAYER");
387 | }
388 |
389 | public static Location getDChestLocation(EquivalencyTech plugin, Integer id) {
390 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
391 | ConfigurationSection section = c.getConfigurationSection(DIS_CHEST_CFG);
392 | return section.getLocation(id.toString());
393 | }
394 |
395 | public static List getAllDChestLocations(EquivalencyTech plugin) {
396 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
397 | ConfigurationSection section = c.getConfigurationSection(DIS_CHEST_CFG);
398 | List ids = new ArrayList<>();
399 | if (section != null) {
400 | for (String s : section.getKeys(false)) {
401 | ids.add(section.getLocation(s));
402 | }
403 | }
404 | return ids;
405 | }
406 |
407 | public static Integer getNextCChestID(EquivalencyTech plugin) {
408 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
409 | ConfigurationSection section = c.getConfigurationSection(CON_CHEST_CFG);
410 | int nextValue = 1;
411 | if (section != null) {
412 | for (String key : section.getKeys(false)) {
413 | int value = Integer.parseInt(key);
414 | if (value > nextValue) {
415 | nextValue = value;
416 | }
417 | }
418 | nextValue++;
419 | }
420 | return nextValue;
421 | }
422 |
423 | public static void addCChestStore(EquivalencyTech plugin, Location location) {
424 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
425 | c.set(CON_CHEST_CFG + "." + getNextCChestID(plugin).toString(), location);
426 | }
427 |
428 | @Nullable
429 | public static Integer getCChestIdStore(EquivalencyTech plugin, Location location) {
430 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
431 | ConfigurationSection section = c.getConfigurationSection(CON_CHEST_CFG);
432 | if (section != null) {
433 | for (String key : section.getKeys(false)) {
434 | Location l = section.getLocation(key);
435 | if (l.equals(location)) {
436 | return Integer.parseInt(key);
437 | }
438 | }
439 | }
440 | return null;
441 | }
442 |
443 | public static void removeCChestStore(EquivalencyTech plugin, Integer id) {
444 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
445 | ConfigurationSection section = c.getConfigurationSection(CON_CHEST_CFG);
446 | section.set(id.toString(), null);
447 | }
448 |
449 | public static void setupCChest(EquivalencyTech plugin, Integer id, Player player) {
450 | FileConfiguration c = plugin.getConfigMainClass().cChestConfig;
451 | c.set(id + ".OWNING_PLAYER", player.getUniqueId().toString());
452 | c.set(id + ".LEVEL", 1);
453 | }
454 |
455 | public static void removeCChest(EquivalencyTech plugin, Integer id) {
456 | FileConfiguration c = plugin.getConfigMainClass().cChestConfig;
457 | c.set(String.valueOf(id), null);
458 | }
459 |
460 | public static boolean isOwnerCChest(EquivalencyTech plugin, Player player, Integer id) {
461 | FileConfiguration c = plugin.getConfigMainClass().cChestConfig;
462 | return c.getString(id + ".OWNING_PLAYER").equals(player.getUniqueId().toString());
463 | }
464 |
465 | public static String getOwnerCChest(EquivalencyTech plugin, Integer id) {
466 | FileConfiguration c = plugin.getConfigMainClass().cChestConfig;
467 | return c.getString(id + ".OWNING_PLAYER");
468 | }
469 |
470 | public static Location getCChestLocation(EquivalencyTech plugin, Integer id) {
471 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
472 | ConfigurationSection section = c.getConfigurationSection(CON_CHEST_CFG);
473 | return section.getLocation(id.toString());
474 | }
475 |
476 | public static List getAllCChestLocations(EquivalencyTech plugin) {
477 | FileConfiguration c = plugin.getConfigMainClass().blockStoreConfig;
478 | ConfigurationSection section = c.getConfigurationSection(CON_CHEST_CFG);
479 | List ids = new ArrayList<>();
480 | if (section != null) {
481 | for (String s : section.getKeys(false)) {
482 | ids.add(section.getLocation(s));
483 | }
484 | }
485 | return ids;
486 | }
487 |
488 | @Nullable
489 | public static ItemStack getCChestItem(EquivalencyTech plugin, Integer id) {
490 | FileConfiguration c = plugin.getConfigMainClass().cChestConfig;
491 | return c.getItemStack(id + ".ITEM");
492 | }
493 |
494 | public static void setCChestItem(EquivalencyTech plugin, Integer id, ItemStack itemStack) {
495 | FileConfiguration c = plugin.getConfigMainClass().cChestConfig;
496 | c.set(id + ".ITEM", itemStack);
497 | }
498 |
499 | }
500 |
--------------------------------------------------------------------------------