oldInventories) {
44 | this.oldInventories = oldInventories;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/font/FontImage.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.font;
2 |
3 | /**
4 | *
5 | * The {@code FontImage} interface provides the ability to replace color codes
6 | * in a string with a character that represents the color.
7 | *
8 | *
9 | * For example, the string "&4Hello" will be replaced with the character
10 | * representing the color red, followed by the string "Hello".
11 | *
12 | *
13 | * This interface is used to provide a way to replace color codes in a string
14 | * with a character that represents the color, when the string is displayed to
15 | * the user in a GUI.
16 | *
17 | *
18 | * @author Maxlego08
19 | */
20 | public interface FontImage {
21 |
22 | /**
23 | *
24 | * Replaces the color codes in the given string with the corresponding
25 | * characters.
26 | *
27 | *
28 | * For example, the string "&4Hello" will be replaced with the character
29 | * representing the color red, followed by the string "Hello".
30 | *
31 | *
32 | * @param string The string in which the color codes are to be replaced.
33 | * @return The string with the color codes replaced.
34 | */
35 | String replace(String string);
36 |
37 | }
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/itemstack/ItemStackSimilar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.itemstack;
2 |
3 | import org.bukkit.inventory.ItemStack;
4 |
5 | /**
6 | * The ItemStackSimilar interface defines methods for comparing ItemStacks in Minecraft.
7 | * It is used to determine if two ItemStacks are similar based on a specific implementation.
8 | */
9 | public interface ItemStackSimilar {
10 |
11 | /**
12 | * Retrieves the name of the ItemStack comparison implementation.
13 | * This name can be used to identify different comparison strategies.
14 | *
15 | * @return The name of this ItemStack comparison strategy.
16 | */
17 | String getName();
18 |
19 | /**
20 | * Compares two ItemStacks to determine if they are similar according to a defined rule.
21 | * This method is used to compare items in specific contexts, such as menus or inventories.
22 | *
23 | * @param itemStackA The first ItemStack to be compared.
24 | * @param itemStackB The second ItemStack to be compared.
25 | * @return true if the two ItemStacks are considered similar, false otherwise.
26 | */
27 | boolean isSimilar(ItemStack itemStackA, ItemStack itemStackB);
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/itemstack/TrimConfiguration.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.itemstack;
2 |
3 | import org.bukkit.inventory.meta.trim.TrimMaterial;
4 | import org.bukkit.inventory.meta.trim.TrimPattern;
5 |
6 | public class TrimConfiguration {
7 | private boolean enable;
8 | private TrimMaterial material;
9 | private TrimPattern pattern;
10 |
11 | // Constructeur
12 | public TrimConfiguration(boolean enable, TrimMaterial material, TrimPattern pattern) {
13 | this.enable = enable;
14 | this.material = material;
15 | this.pattern = pattern;
16 | }
17 |
18 | // Getters
19 | public boolean isEnable() {
20 | return enable;
21 | }
22 |
23 | public TrimMaterial getMaterial() {
24 | return material;
25 | }
26 |
27 | public TrimPattern getPattern() {
28 | return pattern;
29 | }
30 |
31 | // Setters
32 | public void setEnable(boolean enable) {
33 | this.enable = enable;
34 | }
35 |
36 | public void setMaterial(TrimMaterial material) {
37 | this.material = material;
38 | }
39 |
40 | public void setPattern(TrimPattern pattern) {
41 | this.pattern = pattern;
42 | }
43 |
44 | // toString method
45 | @Override
46 | public String toString() {
47 | return "TrimConfiguration{" +
48 | "enable=" + enable +
49 | ", material=" + material +
50 | ", pattern=" + pattern +
51 | '}';
52 | }
53 | }
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/loader/ActionLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.loader;
2 |
3 | import fr.maxlego08.menu.api.requirement.Action;
4 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
5 |
6 | import java.io.File;
7 |
8 | /**
9 | * A loader for creating instances of {@link Action} based on configuration.
10 | */
11 | public interface ActionLoader {
12 |
13 | /**
14 | * Gets the key that defines the type of action.
15 | *
16 | * @return The key.
17 | */
18 | String getKey();
19 |
20 | /**
21 | * Creates an instance of {@link Action} based on the provided configuration.
22 | *
23 | * @param path The path in the configuration file.
24 | * @param accessor The map accessor containing the configuration elements.
25 | * @param file The file where the configuration is located.
26 | * @return The created {@link Action}.
27 | */
28 | Action load(String path, TypedMapAccessor accessor, File file);
29 | }
30 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/loader/MaterialLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.loader;
2 |
3 | import org.bukkit.configuration.file.YamlConfiguration;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.inventory.ItemStack;
6 |
7 | /**
8 | * Documentation: here
9 | * The MaterialLoader interface defines methods for loading an {@link ItemStack} from a configuration.
10 | */
11 | public interface MaterialLoader {
12 |
13 | /**
14 | * Returns the key used to load the ItemStack.
15 | *
16 | * @return The key.
17 | */
18 | String getKey();
19 |
20 | /**
21 | * Loads an ItemStack based on the provided configuration.
22 | *
23 | * @param player The player.
24 | * @param configuration The current configuration.
25 | * @param path The current path.
26 | * @param materialString The material as a String.
27 | * @return The loaded ItemStack.
28 | */
29 | ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/loader/PermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.loader;
2 |
3 | import fr.maxlego08.menu.api.requirement.Permissible;
4 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
5 |
6 | import java.io.File;
7 |
8 | /**
9 | * The PermissibleLoader interface defines methods for loading a {@link Permissible} from a configuration.
10 | */
11 | public interface PermissibleLoader {
12 |
13 | /**
14 | * Returns the key used to define the type of permissible.
15 | *
16 | * @return The key.
17 | */
18 | String getKey();
19 |
20 | /**
21 | * Creates a {@link Permissible} based on the provided configuration.
22 | *
23 | * @param path The path in the configuration file.
24 | * @param accessor The map accessor that contains the configuration elements.
25 | * @param file The file where the configuration is located.
26 | * @return The loaded {@link Permissible}.
27 | */
28 | Permissible load(String path, TypedMapAccessor accessor, File file);
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/players/Data.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.players;
2 |
3 | /**
4 | * A data is composed of a key, a string, and a value, an object
5 | */
6 | public interface Data {
7 |
8 | /**
9 | * The key
10 | *
11 | * @return key
12 | */
13 | String getKey();
14 |
15 | /**
16 | * The value that is stored
17 | *
18 | * @return value
19 | */
20 | Object getValue();
21 |
22 | /**
23 | * Permet de savoir quand la valeur doit expirer. If the value is 0 then it never exits
24 | *
25 | * @return expired at
26 | */
27 | long getExpiredAt();
28 |
29 | /**
30 | * Allows to know if a data is expired
31 | *
32 | * @return boolean
33 | */
34 | boolean isExpired();
35 |
36 | void add(int amount);
37 |
38 | void remove(int amount);
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/players/DataManager.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.players;
2 |
3 | import fr.maxlego08.menu.zcore.utils.storage.Savable;
4 |
5 | import java.util.Optional;
6 | import java.util.UUID;
7 |
8 | /**
9 | * Player Data Management
10 | */
11 | public interface DataManager extends Savable {
12 |
13 | /**
14 | * @param uniqueId Player {@link UUID}
15 | * @return optional
16 | */
17 | Optional getPlayer(UUID uniqueId);
18 |
19 | /**
20 | * @param uniqueId Player {@link UUID}
21 | * @return PlayerData
22 | */
23 | PlayerData getOrCreate(UUID uniqueId);
24 |
25 | /**
26 | * @param uniqueId Player {@link UUID}
27 | * @param data New data
28 | */
29 | void addData(UUID uniqueId, Data data);
30 |
31 | /**
32 | * @param uniqueId Player {@link UUID}
33 | * @param key Data key
34 | * @return Optional
35 | */
36 | Optional getData(UUID uniqueId, String key);
37 |
38 | /**
39 | * Clear all player's data
40 | */
41 | void clearAll();
42 |
43 | /**
44 | * Save auto
45 | */
46 | void autoSave();
47 |
48 | /**
49 | * Clear player's data
50 | *
51 | * @param uniqueId Player {@link UUID}
52 | */
53 | void clearPlayer(UUID uniqueId);
54 |
55 | void loadDefaultValues();
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/players/PlayerData.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.players;
2 |
3 | import java.util.Collection;
4 | import java.util.Optional;
5 | import java.util.UUID;
6 |
7 | /**
8 | * Player's {@link Data}
9 | */
10 | public interface PlayerData {
11 |
12 | /**
13 | * Return uuid of player
14 | *
15 | * @return uniqueId
16 | */
17 | UUID getUniqueId();
18 |
19 | /**
20 | * Allows to return list of player {@link Data}. Attention you cannot modify the values directly from this collection.
21 | *
22 | * @return collections
23 | */
24 | Collection getDatas();
25 |
26 | /**
27 | * Allows you to add a data
28 | *
29 | * @param data New {@link Data}
30 | */
31 | void addData(Data data);
32 |
33 | /**
34 | * Allows you to delete a data
35 | *
36 | * @param data Old {@link Data}
37 | */
38 | void removeData(Data data);
39 |
40 | /**
41 | * Allows you to delete a {@link Data}
42 | *
43 | * @param key Data key
44 | */
45 | void removeData(String key);
46 |
47 | /**
48 | * Check if data exist
49 | *
50 | * @param key Data key
51 | * @return boolean
52 | */
53 | boolean containsKey(String key);
54 |
55 | /**
56 | * Get data
57 | *
58 | * @param key Data key
59 | * @return optional
60 | */
61 | Optional getData(String key);
62 |
63 | }
64 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/players/inventory/InventoriesPlayer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.players.inventory;
2 |
3 | import fr.maxlego08.menu.zcore.utils.storage.Savable;
4 | import org.bukkit.entity.Player;
5 | import org.bukkit.event.Listener;
6 |
7 | import java.util.Optional;
8 | import java.util.UUID;
9 |
10 | /**
11 | * Management of player inventories
12 | */
13 | public interface InventoriesPlayer extends Listener, Savable {
14 |
15 | /**
16 | * Saves the player's inventory to be stored
17 | *
18 | * @param player Player
19 | */
20 | void storeInventory(Player player);
21 |
22 | /**
23 | * Allows giving the inventory back to the player
24 | *
25 | * @param player Player
26 | */
27 | void giveInventory(Player player);
28 |
29 | /**
30 | * Check if the player has an inventory saved
31 | *
32 | * @param uniqueId Player {@link UUID}
33 | * @return boolean
34 | */
35 | boolean hasSavedInventory(UUID uniqueId);
36 |
37 | /**
38 | * Retrieve the player's inventory if it exists
39 | *
40 | * @param uniqueId Player {@link UUID}
41 | * @return optional
42 | */
43 | Optional getPlayerInventory(UUID uniqueId);
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/players/inventory/InventoryPlayer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.players.inventory;
2 |
3 | import org.bukkit.entity.Player;
4 |
5 | /**
6 | * Player's {@link org.bukkit.inventory.Inventory}
7 | */
8 | public interface InventoryPlayer {
9 |
10 | /**
11 | * Saves the player's inventory to be stored
12 | *
13 | * @param player The player
14 | */
15 | void storeInventory(Player player);
16 |
17 | /**
18 | * Allows to give the inventory back to the player
19 | *
20 | * @param player The player
21 | */
22 | void giveInventory(Player player);
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/data/ActionPlayerData.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.data;
2 |
3 | import fr.maxlego08.menu.api.players.Data;
4 | import fr.maxlego08.menu.api.players.DataManager;
5 | import org.bukkit.OfflinePlayer;
6 | import org.bukkit.entity.Player;
7 |
8 | /**
9 | * Represents an action associated with player data.
10 | */
11 | public interface ActionPlayerData {
12 |
13 | /**
14 | * Gets the unique key for the action. Ensure keys are unique.
15 | *
16 | * @return The key.
17 | */
18 | String getKey();
19 |
20 | /**
21 | * Gets the type of action.
22 | *
23 | * @return The {@link ActionPlayerDataType}.
24 | */
25 | ActionPlayerDataType getType();
26 |
27 | /**
28 | * Gets the value associated with the action.
29 | *
30 | * @return The value.
31 | */
32 | Object getValue();
33 |
34 | /**
35 | * Gets the number of seconds until the data expires. Use 0 for no expiration.
36 | *
37 | * @return The expiration time in seconds.
38 | */
39 | long getSeconds();
40 |
41 | /**
42 | * Converts the action into player data.
43 | *
44 | * @return The {@link Data}.
45 | */
46 | Data toData(OfflinePlayer player);
47 |
48 | /**
49 | * Executes the action when the player clicks.
50 | *
51 | * @param player The player who executes the action.
52 | * @param dataManager The {@link DataManager}.
53 | */
54 | void execute(Player player, DataManager dataManager);
55 | }
56 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/data/ActionPlayerDataType.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.data;
2 |
3 | public enum ActionPlayerDataType {
4 |
5 | SET,
6 | REMOVE,
7 |
8 | ADD,
9 |
10 | SUBTRACT,
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/CurrencyPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.requirement.Permissible;
4 | import fr.traqueur.currencies.Currencies;
5 |
6 | import java.math.BigDecimal;
7 |
8 | public interface CurrencyPermissible extends Permissible {
9 |
10 | String getAmount();
11 |
12 | Currencies getCurrency();
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/ItemPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.MenuItemStack;
4 | import fr.maxlego08.menu.api.requirement.Permissible;
5 | import org.bukkit.Material;
6 |
7 | /**
8 | * Represents a condition where a player is required to have a specific item.
9 | */
10 | public interface ItemPermissible extends Permissible {
11 |
12 | /**
13 | * Gets the MenuItemStack that the player must have.
14 | *
15 | * @return The required MenuItemStack.
16 | */
17 | MenuItemStack getMenuItemStack();
18 |
19 | /**
20 | * Gets the number of items that the player must have at least. Put 0 to not check the amount.
21 | *
22 | * @return The required amount.
23 | */
24 | int getAmount();
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/JobPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.requirement.Permissible;
4 |
5 | public interface JobPermissible extends Permissible {
6 |
7 | String getJobName();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/LuckpermPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.requirement.Permissible;
4 |
5 | public interface LuckpermPermissible extends Permissible {
6 |
7 | String getGroupName();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/PermissionPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.requirement.Permissible;
4 |
5 | /**
6 | * Represents a condition where a player is required to have a specific permission.
7 | */
8 | public interface PermissionPermissible extends Permissible {
9 |
10 | /**
11 | * Gets the permission that the player must have.
12 | *
13 | * @return The required permission.
14 | */
15 | String getPermission();
16 |
17 | /**
18 | * Checks if the condition is reversed, meaning the player should not have the specified permission.
19 | *
20 | * @return True if the condition is reversed; otherwise, false.
21 | */
22 | boolean isReverse();
23 | }
24 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/PlaceholderPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.enums.PlaceholderAction;
4 | import fr.maxlego08.menu.api.requirement.Permissible;
5 |
6 | /**
7 | * Represents a condition based on placeholders for permissions.
8 | */
9 | public interface PlaceholderPermissible extends Permissible {
10 |
11 | /**
12 | * Gets the action to be performed for the placeholder.
13 | *
14 | * @return The {@link PlaceholderAction}.
15 | */
16 | PlaceholderAction getPlaceholderAction();
17 |
18 | /**
19 | * Gets the placeholder that will be used for the condition.
20 | *
21 | * @return The placeholder string.
22 | */
23 | String getPlaceholder();
24 |
25 | /**
26 | * Gets the value that will be used for the specified action.
27 | *
28 | * @return The value string.
29 | */
30 | String getValue();
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/requirement/permissible/PlayerNamePermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.requirement.Permissible;
4 |
5 | public interface PlayerNamePermissible extends Permissible {
6 |
7 | String getPlayerName();
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/sound/SoundOption.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.sound;
2 |
3 | import com.cryptomorin.xseries.XSound;
4 | import org.bukkit.entity.Entity;
5 |
6 | /**
7 | * Allows you to manage a sound
8 | */
9 | public interface SoundOption {
10 |
11 | /**
12 | * @return sound
13 | */
14 | XSound getSound();
15 |
16 | /**
17 | * @return pitch
18 | */
19 | float getPitch();
20 |
21 | /**
22 | * @return volume
23 | */
24 | float getVolume();
25 |
26 | /**
27 | * @param entity to play the sound
28 | */
29 | void play(Entity entity);
30 |
31 | boolean isCustom();
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/utils/IMessage.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.utils;
2 |
3 | import fr.maxlego08.menu.api.enums.MessageType;
4 |
5 | import java.util.List;
6 |
7 | public interface IMessage {
8 |
9 | String getMessage();
10 |
11 | List getMessages();
12 |
13 | MessageType getType();
14 |
15 | }
16 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/utils/LoreType.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.utils;
2 |
3 | public enum LoreType {
4 |
5 | REPLACE,
6 | APPEND,
7 | PREPEND
8 |
9 | }
10 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/utils/OpenLink.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.utils;
2 |
3 | import net.md_5.bungee.api.chat.ClickEvent.Action;
4 | import org.bukkit.entity.Player;
5 |
6 | import java.util.List;
7 |
8 | /**
9 | * Sends a message and opens a link.
10 | * For servers that are in 1.17+ it is advisable to use the MiniMessage format
11 | */
12 | public interface OpenLink {
13 |
14 | /**
15 | * Returns the action that will be performed on the click
16 | *
17 | * @return action
18 | */
19 | Action getAction();
20 |
21 | /**
22 | * Returns the message that will be displayed
23 | *
24 | * @return message
25 | */
26 | String getMessage();
27 |
28 | /**
29 | * Returns the value to be used for the click
30 | *
31 | * @return string
32 | */
33 | String getLink();
34 |
35 | /**
36 | * Returns the value that will be replaced
37 | *
38 | * @return replace
39 | */
40 | String getReplace();
41 |
42 | /**
43 | * @return list of string
44 | */
45 | List getHover();
46 |
47 | /**
48 | * Allows you to send messages to a player
49 | *
50 | * @param player The players
51 | * @param strings list of messages
52 | */
53 | void send(Player player, List strings);
54 |
55 | /**
56 | * Allows to know if the object is valid
57 | *
58 | * @return boolean
59 | */
60 | boolean isValid();
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/utils/OpenWithItem.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.utils;
2 |
3 | import fr.maxlego08.menu.MenuItemStack;
4 | import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
5 | import org.bukkit.event.block.Action;
6 | import org.bukkit.event.player.PlayerInteractEvent;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | import java.util.List;
10 |
11 |
12 | /**
13 | * Represents the item that can be interacted with to open a menu.
14 | */
15 | public class OpenWithItem {
16 | private final MenuItemStack menuItemStack;
17 | private final List actions;
18 | private final ItemStackSimilar itemStackSimilar;
19 |
20 | public OpenWithItem(MenuItemStack menuItemStack, List actions, ItemStackSimilar itemStackSimilar) {
21 | this.menuItemStack = menuItemStack;
22 | this.actions = actions;
23 | this.itemStackSimilar = itemStackSimilar;
24 | }
25 |
26 | public MenuItemStack getItemStack() {
27 | return menuItemStack;
28 | }
29 |
30 | public List getActions() {
31 | return actions;
32 | }
33 |
34 | public boolean shouldTrigger(PlayerInteractEvent event) {
35 | if (event.getItem() == null) {
36 | return false;
37 | }
38 |
39 | if (!this.actions.contains(event.getAction())) {
40 | return false;
41 | }
42 |
43 | ItemStack itemStack = this.menuItemStack.build(event.getPlayer());
44 | return this.itemStackSimilar.isSimilar(itemStack, event.getItem());
45 | }
46 | }
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/api/website/WebsiteManager.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.api.website;
2 |
3 | import org.bukkit.command.CommandSender;
4 | import org.bukkit.entity.Player;
5 |
6 | /**
7 | * ToDO
8 | * In dev, dont use that
9 | */
10 | public interface WebsiteManager {
11 |
12 | /**
13 | * Allows you to connect to the site
14 | *
15 | * @param sender Command sender
16 | * @param token unique token
17 | */
18 | void login(CommandSender sender, String token);
19 |
20 | /**
21 | * Disconnect to the site
22 | *
23 | * @param sender Command sender
24 | */
25 | void disconnect(CommandSender sender);
26 |
27 | void openMarketplace(Player player);
28 |
29 | void downloadFromUrl(CommandSender sender, String url, boolean force);
30 | }
31 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/ZSlotButton.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button;
2 |
3 | import fr.maxlego08.menu.api.button.SlotButton;
4 | import fr.maxlego08.menu.zcore.utils.ZUtils;
5 |
6 | import java.util.Collection;
7 | import java.util.List;
8 |
9 | public abstract class ZSlotButton extends ZUtils implements SlotButton {
10 |
11 | protected List slots;
12 | protected int page;
13 |
14 | @Override
15 | public Collection getSlots() {
16 | return this.slots;
17 | }
18 |
19 | public void setSlots(List slots) {
20 | this.slots = slots;
21 | }
22 |
23 | public void setPage(int page) {
24 | this.page = page;
25 | }
26 |
27 | @Override
28 | public int getPage() {
29 | return page;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/buttons/ZHomeButton.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.buttons;
2 |
3 | import fr.maxlego08.menu.api.Inventory;
4 | import fr.maxlego08.menu.api.InventoryManager;
5 | import fr.maxlego08.menu.api.button.buttons.HomeButton;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.event.inventory.InventoryClickEvent;
10 |
11 | import java.util.ArrayList;
12 | import java.util.List;
13 |
14 | public class ZHomeButton extends ZBackButton implements HomeButton {
15 |
16 | public ZHomeButton(InventoryManager inventoryManager) {
17 | super(inventoryManager);
18 | }
19 |
20 | @Override
21 | public void onClick(Player player, InventoryClickEvent event, InventoryDefault inventory, int slot, Placeholders placeholders) {
22 | super.onClick(player, event, inventory, slot, placeholders);
23 |
24 | if (this.inventory == null) {
25 | return;
26 | }
27 |
28 | Inventory toInventory = this.inventory;
29 | this.inventoryManager.openInventory(player, toInventory, 1, new ArrayList<>());
30 | }
31 |
32 | @Override
33 | public void onInventoryOpen(Player player, InventoryDefault inventory, Placeholders placeholders) {
34 |
35 | List oldInventories = inventory.getOldInventories();
36 | if (!oldInventories.isEmpty()) {
37 | this.inventory = oldInventories.get(0);
38 | }
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/buttons/ZJumpButton.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.buttons;
2 |
3 | import fr.maxlego08.menu.api.Inventory;
4 | import fr.maxlego08.menu.api.InventoryManager;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.inventory.InventoryClickEvent;
9 |
10 | import java.util.ArrayList;
11 |
12 | public class ZJumpButton extends ZNextButton {
13 | private final int page;
14 | private final InventoryManager inventoryManager;
15 |
16 | /**
17 | * @param page the real page(start from 0)
18 | * @param inventoryManager the inventory manager
19 | */
20 | public ZJumpButton(InventoryManager inventoryManager, int page) {
21 | super(inventoryManager);
22 | this.inventoryManager = inventoryManager;
23 | this.page = page;
24 | }
25 |
26 | @Override
27 | public void onClick(Player player, InventoryClickEvent event, InventoryDefault inventory, int slot, Placeholders placeholders) {
28 | super.onClick(player, event, inventory, slot, placeholders);
29 |
30 | Inventory toInventory = inventory.getMenuInventory();
31 | this.inventoryManager.openInventory(player, toInventory, page, new ArrayList<>());
32 | }
33 |
34 | @Override
35 | public boolean checkPermission(Player player, InventoryDefault inventory, Placeholders placeholders) {
36 | return this.page != inventory.getPage();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/buttons/ZMainMenuButton.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.buttons;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.utils.Placeholders;
5 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
6 | import fr.maxlego08.menu.save.Config;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.event.inventory.InventoryClickEvent;
9 |
10 | public class ZMainMenuButton extends ZHomeButton {
11 | private final InventoryManager inventoryManager;
12 |
13 | /**
14 | * @param inventoryManager
15 | */
16 | public ZMainMenuButton(InventoryManager inventoryManager) {
17 | super(inventoryManager);
18 | this.inventoryManager = inventoryManager;
19 | }
20 |
21 |
22 | @Override
23 | public void onClick(Player player, InventoryClickEvent event, InventoryDefault inventory, int slot, Placeholders placeholders) {
24 | super.onClick(player, event, inventory, slot, placeholders);
25 | inventoryManager.openInventory(player, Config.mainMenu);
26 | }
27 |
28 | @Override
29 | public boolean checkPermission(Player player, InventoryDefault inventory, Placeholders placeholders) {
30 | return true;
31 | }
32 |
33 | @Override
34 | public boolean hasPermission() {
35 | return true;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/buttons/ZNoneButton.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.buttons;
2 |
3 | import fr.maxlego08.menu.button.ZButton;
4 |
5 | public class ZNoneButton extends ZButton {
6 |
7 | }
8 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/loader/BackLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.loader;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.button.DefaultButtonValue;
6 | import fr.maxlego08.menu.api.button.buttons.BackButton;
7 | import fr.maxlego08.menu.api.loader.ButtonLoader;
8 | import fr.maxlego08.menu.button.buttons.ZBackButton;
9 | import org.bukkit.configuration.file.YamlConfiguration;
10 | import org.bukkit.plugin.Plugin;
11 |
12 | public class BackLoader implements ButtonLoader {
13 |
14 | private final Plugin plugin;
15 | private final InventoryManager manager;
16 |
17 | /**
18 | * @param plugin
19 | * @param manager
20 | */
21 | public BackLoader(Plugin plugin, InventoryManager manager) {
22 | super();
23 | this.plugin = plugin;
24 | this.manager = manager;
25 | }
26 |
27 | @Override
28 | public Class extends Button> getButton() {
29 | return BackButton.class;
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return "back";
35 | }
36 |
37 | @Override
38 | public Plugin getPlugin() {
39 | return this.plugin;
40 | }
41 |
42 | @Override
43 | public Button load(YamlConfiguration configuration, String path, DefaultButtonValue defaultButtonValue) {
44 | return new ZBackButton(this.manager);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/loader/HomeLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.loader;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.button.DefaultButtonValue;
6 | import fr.maxlego08.menu.api.button.buttons.HomeButton;
7 | import fr.maxlego08.menu.api.loader.ButtonLoader;
8 | import fr.maxlego08.menu.button.buttons.ZHomeButton;
9 | import org.bukkit.configuration.file.YamlConfiguration;
10 | import org.bukkit.plugin.Plugin;
11 |
12 | public class HomeLoader implements ButtonLoader {
13 |
14 | private final Plugin plugin;
15 | private final InventoryManager manager;
16 |
17 | /**
18 | * @param plugin
19 | * @param manager
20 | */
21 | public HomeLoader(Plugin plugin, InventoryManager manager) {
22 | super();
23 | this.plugin = plugin;
24 | this.manager = manager;
25 | }
26 |
27 | @Override
28 | public Class extends Button> getButton() {
29 | return HomeButton.class;
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return "home";
35 | }
36 |
37 | @Override
38 | public Plugin getPlugin() {
39 | return this.plugin;
40 | }
41 |
42 | @Override
43 | public Button load(YamlConfiguration configuration, String path, DefaultButtonValue defaultButtonValue) {
44 | return new ZHomeButton(this.manager);
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/loader/JumpLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.loader;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.button.DefaultButtonValue;
6 | import fr.maxlego08.menu.api.loader.ButtonLoader;
7 | import fr.maxlego08.menu.button.buttons.ZJumpButton;
8 | import org.bukkit.configuration.file.YamlConfiguration;
9 | import org.bukkit.plugin.Plugin;
10 |
11 | public class JumpLoader implements ButtonLoader {
12 | private final Plugin plugin;
13 | private final InventoryManager inventoryManager;
14 |
15 | public JumpLoader(Plugin plugin, InventoryManager inventoryManager) {
16 | this.plugin = plugin;
17 | this.inventoryManager = inventoryManager;
18 | }
19 |
20 | @Override
21 | public Class extends Button> getButton() {
22 | return ZJumpButton.class;
23 | }
24 |
25 | @Override
26 | public String getName() {
27 | return "jump";
28 | }
29 |
30 | @Override
31 | public Plugin getPlugin() {
32 | return this.plugin;
33 | }
34 |
35 | @Override
36 | public Button load(YamlConfiguration configuration, String path, DefaultButtonValue defaultButtonValue) {
37 | int page = configuration.getInt(path + "toPage", configuration.getInt(path + "to-page"));
38 | return new ZJumpButton(this.inventoryManager, page);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/loader/MainMenuLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.loader;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.button.DefaultButtonValue;
6 | import fr.maxlego08.menu.api.loader.ButtonLoader;
7 | import fr.maxlego08.menu.button.buttons.ZMainMenuButton;
8 | import org.bukkit.configuration.file.YamlConfiguration;
9 | import org.bukkit.plugin.Plugin;
10 |
11 | public class MainMenuLoader implements ButtonLoader {
12 | private final Plugin plugin;
13 | private final InventoryManager manager;
14 |
15 | public MainMenuLoader(Plugin plugin, InventoryManager manager) {
16 | super();
17 | this.plugin = plugin;
18 | this.manager = manager;
19 | }
20 |
21 | @Override
22 | public Class extends Button> getButton() {
23 | return ZMainMenuButton.class;
24 | }
25 |
26 | @Override
27 | public String getName() {
28 | return "mainmenu";
29 | }
30 |
31 | @Override
32 | public Plugin getPlugin() {
33 | return this.plugin;
34 | }
35 |
36 | @Override
37 | public Button load(YamlConfiguration configuration, String path, DefaultButtonValue defaultButtonValue) {
38 | return new ZMainMenuButton(manager);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/loader/NextLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.loader;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.button.DefaultButtonValue;
6 | import fr.maxlego08.menu.api.button.buttons.NextButton;
7 | import fr.maxlego08.menu.api.loader.ButtonLoader;
8 | import fr.maxlego08.menu.button.buttons.ZNextButton;
9 | import org.bukkit.configuration.file.YamlConfiguration;
10 | import org.bukkit.plugin.Plugin;
11 |
12 | public class NextLoader implements ButtonLoader {
13 |
14 | private final Plugin plugin;
15 | private final InventoryManager manager;
16 |
17 | /**
18 | * @param plugin
19 | * @param manager
20 | */
21 | public NextLoader(Plugin plugin, InventoryManager manager) {
22 | super();
23 | this.plugin = plugin;
24 | this.manager = manager;
25 | }
26 |
27 | @Override
28 | public Class extends Button> getButton() {
29 | return NextButton.class;
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return "next";
35 | }
36 |
37 | @Override
38 | public Plugin getPlugin() {
39 | return this.plugin;
40 | }
41 |
42 | @Override
43 | public Button load(YamlConfiguration configuration, String path, DefaultButtonValue defaultButtonValue) {
44 | defaultButtonValue.setPermanent(true);
45 | return new ZNextButton(this.manager);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/button/loader/PreviousLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.button.loader;
2 |
3 | import fr.maxlego08.menu.api.InventoryManager;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.button.DefaultButtonValue;
6 | import fr.maxlego08.menu.api.button.buttons.PreviousButton;
7 | import fr.maxlego08.menu.api.loader.ButtonLoader;
8 | import fr.maxlego08.menu.button.buttons.ZPreviousButton;
9 | import org.bukkit.configuration.file.YamlConfiguration;
10 | import org.bukkit.plugin.Plugin;
11 |
12 | public class PreviousLoader implements ButtonLoader {
13 |
14 | private final Plugin plugin;
15 | private final InventoryManager manager;
16 |
17 | /**
18 | * @param plugin
19 | * @param manager
20 | */
21 | public PreviousLoader(Plugin plugin, InventoryManager manager) {
22 | super();
23 | this.plugin = plugin;
24 | this.manager = manager;
25 | }
26 |
27 | @Override
28 | public Class extends Button> getButton() {
29 | return PreviousButton.class;
30 | }
31 |
32 | @Override
33 | public String getName() {
34 | return "previous";
35 | }
36 |
37 | @Override
38 | public Plugin getPlugin() {
39 | return this.plugin;
40 | }
41 |
42 | @Override
43 | public Button load(YamlConfiguration configuration, String path, DefaultButtonValue defaultButtonValue) {
44 | defaultButtonValue.setPermanent(true);
45 | return new ZPreviousButton(this.manager);
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/CommandMenuDocumentation.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 |
9 | public class CommandMenuDocumentation extends VCommand {
10 |
11 | public CommandMenuDocumentation(MenuPlugin plugin) {
12 | super(plugin);
13 | this.addSubCommand("documentation");
14 | this.setPermission(Permission.ZMENU_DOCUMENTATION);
15 | this.setDescription(Message.DESCRIPTION_DOCUMENTATION);
16 | this.addOptionalArg("word");
17 | }
18 |
19 | @Override
20 | protected CommandType perform(MenuPlugin plugin) {
21 |
22 | String word = this.argAsString(0, null);
23 | if (word == null) {
24 | message(sender, Message.DOCUMENTATION_INFORMATION_LINK, "%link%", "https://docs.zmenu.dev/");
25 | } else {
26 | message(sender, Message.DOCUMENTATION_INFORMATION_LINK, "%link%", "https://docs.zmenu.dev/?q=" + word);
27 | }
28 |
29 | return CommandType.SUCCESS;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/CommandMenuEditor.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 |
9 | public class CommandMenuEditor extends VCommand {
10 |
11 | public CommandMenuEditor(MenuPlugin plugin) {
12 | super(plugin);
13 | this.addSubCommand("editor");
14 | this.setDescription(Message.DESCRIPTION_EDITOR);
15 | }
16 |
17 | @Override
18 | protected CommandType perform(MenuPlugin plugin) {
19 |
20 | message(this.sender, "§fhttps://minecraft-inventory-builder.com/builder/");
21 |
22 | return CommandType.SUCCESS;
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/CommandMenuList.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 |
9 | public class CommandMenuList extends VCommand {
10 |
11 | public CommandMenuList(MenuPlugin plugin) {
12 | super(plugin);
13 | this.setPermission(Permission.ZMENU_LIST);
14 | this.setDescription(Message.DESCRIPTION_LIST);
15 | this.addSubCommand("list", "l");
16 | }
17 |
18 | @Override
19 | protected CommandType perform(MenuPlugin plugin) {
20 | plugin.getInventoryManager().sendInventories(this.sender);
21 | return CommandType.SUCCESS;
22 | }
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/CommandMenuTestDupe.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 | import org.bukkit.Material;
9 | import org.bukkit.inventory.ItemStack;
10 |
11 | import java.util.Arrays;
12 |
13 | public class CommandMenuTestDupe extends VCommand {
14 |
15 | public CommandMenuTestDupe(MenuPlugin plugin) {
16 | super(plugin);
17 | this.setPermission(Permission.ZMENU_TEST_DUPE);
18 | this.setDescription(Message.DESCRIPTION_TEST_DUPE);
19 | this.addSubCommand("testdupe");
20 | this.addRequireArg("type", (a, b) -> Arrays.asList("inventory", "item"));
21 | }
22 |
23 | @Override
24 | protected CommandType perform(MenuPlugin plugin) {
25 |
26 | String arg = this.argAsString(0);
27 |
28 | ItemStack itemStack = new ItemStack(Material.STONE);
29 | itemStack = plugin.getDupeManager().protectItem(itemStack);
30 |
31 | if (arg.equalsIgnoreCase("inventory")) {
32 | player.getInventory().addItem(itemStack.clone());
33 | } else if (arg.equalsIgnoreCase("item")) {
34 | player.getWorld().dropItem(player.getLocation(), itemStack.clone());
35 | } else return CommandType.SYNTAX_ERROR;
36 |
37 | return CommandType.SUCCESS;
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/CommandMenuVersion.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
7 |
8 | public class CommandMenuVersion extends VCommand {
9 |
10 | public CommandMenuVersion(MenuPlugin plugin) {
11 | super(plugin);
12 | this.setDescription(Message.DESCRIPTION_VERSION);
13 | this.addSubCommand("version", "v", "ver");
14 | }
15 |
16 | @Override
17 | protected CommandType perform(MenuPlugin plugin) {
18 |
19 | message(sender, "§aVersion du plugin§7: §2" + plugin.getDescription().getVersion());
20 | message(sender, "§aAuteur§7: §2Maxlego08");
21 | message(sender, "§aMarketplace/Inventory builder§7: §2https://minecraft-inventory-builder.com/");
22 | message(sender, "§aDiscord§7: §2http://discord.groupez.dev/");
23 | message(sender, "§aDownload here§7: §2https://groupez.dev/resources/253");
24 | message(sender, "§aSponsor§7: §chttps://serveur-minecraft-vote.fr/?ref=345");
25 |
26 | return CommandType.SUCCESS;
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/players/CommandMenuPlayers.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.players;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 |
9 | public class CommandMenuPlayers extends VCommand {
10 |
11 | public CommandMenuPlayers(MenuPlugin plugin) {
12 | super(plugin);
13 | this.setPermission(Permission.ZMENU_PLAYERS);
14 | this.setDescription(Message.DESCRIPTION_PLAYERS);
15 | this.addSubCommand("players");
16 | this.addSubCommand(new CommandMenuPlayersSet(plugin));
17 | this.addSubCommand(new CommandMenuPlayersGet(plugin));
18 | this.addSubCommand(new CommandMenuPlayersRemove(plugin));
19 | this.addSubCommand(new CommandMenuPlayersKeys(plugin));
20 | this.addSubCommand(new CommandMenuPlayersClearAll(plugin));
21 | this.addSubCommand(new CommandMenuPlayersClearPlayer(plugin));
22 | this.addSubCommand(new CommandMenuPlayersSubtract(plugin));
23 | this.addSubCommand(new CommandMenuPlayersAdd(plugin));
24 | }
25 |
26 | @Override
27 | protected CommandType perform(MenuPlugin plugin) {
28 | sendSyntax();
29 | return CommandType.SUCCESS;
30 | }
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/players/CommandMenuPlayersClearAll.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.players;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.players.DataManager;
5 | import fr.maxlego08.menu.command.VCommand;
6 | import fr.maxlego08.menu.zcore.enums.Message;
7 | import fr.maxlego08.menu.zcore.enums.Permission;
8 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
9 |
10 | public class CommandMenuPlayersClearAll extends VCommand {
11 |
12 | public CommandMenuPlayersClearAll(MenuPlugin plugin) {
13 | super(plugin);
14 | this.setPermission(Permission.ZMENU_PLAYERS);
15 | this.setDescription(Message.DESCRIPTION_PLAYERS_CLEAR_ALL);
16 | this.addSubCommand("clearall");
17 | }
18 |
19 | @Override
20 | protected CommandType perform(MenuPlugin plugin) {
21 |
22 | DataManager dataManager = plugin.getDataManager();
23 | dataManager.clearAll();
24 |
25 | message(this.sender, Message.PLAYERS_DATA_CLEAR_ALL);
26 |
27 | return CommandType.SUCCESS;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/players/CommandMenuPlayersClearPlayer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.players;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.players.DataManager;
5 | import fr.maxlego08.menu.command.VCommand;
6 | import fr.maxlego08.menu.zcore.enums.Message;
7 | import fr.maxlego08.menu.zcore.enums.Permission;
8 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
9 | import org.bukkit.OfflinePlayer;
10 |
11 | public class CommandMenuPlayersClearPlayer extends VCommand {
12 |
13 | public CommandMenuPlayersClearPlayer(MenuPlugin plugin) {
14 | super(plugin);
15 | this.setPermission(Permission.ZMENU_PLAYERS);
16 | this.setDescription(Message.DESCRIPTION_PLAYERS_CLEAR_PLAYER);
17 | this.addSubCommand("clear");
18 | this.addRequireArg("player");
19 | }
20 |
21 | @Override
22 | protected CommandType perform(MenuPlugin plugin) {
23 |
24 | DataManager dataManager = plugin.getDataManager();
25 | OfflinePlayer offlinePlayer = this.argAsOfflinePlayer(0);
26 |
27 | dataManager.clearPlayer(offlinePlayer.getUniqueId());
28 |
29 | message(this.sender, Message.PLAYERS_DATA_CLEAR_PLAYER, "%player%", offlinePlayer.getName());
30 |
31 | return CommandType.SUCCESS;
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/reload/CommandMenuReloadConfig.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.reload;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.save.Config;
6 | import fr.maxlego08.menu.zcore.enums.Message;
7 | import fr.maxlego08.menu.zcore.enums.Permission;
8 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
9 |
10 | public class CommandMenuReloadConfig extends VCommand {
11 |
12 | public CommandMenuReloadConfig(MenuPlugin plugin) {
13 | super(plugin);
14 | this.addSubCommand("config");
15 | this.setPermission(Permission.ZMENU_RELOAD);
16 | }
17 |
18 | @Override
19 | protected CommandType perform(MenuPlugin plugin) {
20 |
21 | plugin.getMessageLoader().load();
22 | Config.getInstance().load(plugin.getPersist());
23 |
24 | plugin.getPatternManager().loadPatterns();
25 |
26 | message(this.sender, Message.RELOAD_FILES);
27 |
28 | return CommandType.SUCCESS;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/website/CommandMenuDisconnect.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.website;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.website.WebsiteManager;
5 | import fr.maxlego08.menu.command.VCommand;
6 | import fr.maxlego08.menu.zcore.enums.Message;
7 | import fr.maxlego08.menu.zcore.enums.Permission;
8 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
9 |
10 | public class CommandMenuDisconnect extends VCommand {
11 |
12 | public CommandMenuDisconnect(MenuPlugin plugin) {
13 | super(plugin);
14 | this.setDescription(Message.DESCRIPTION_DISCONNECT);
15 | this.addSubCommand("disconnect", "logout");
16 | this.setPermission(Permission.ZMENU_DESCRIPTION);
17 | }
18 |
19 | @Override
20 | protected CommandType perform(MenuPlugin plugin) {
21 |
22 | WebsiteManager manager = plugin.getWebsiteManager();
23 | manager.disconnect(this.sender);
24 |
25 | return CommandType.SUCCESS;
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/website/CommandMenuInventories.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.website;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 |
9 | public class CommandMenuInventories extends VCommand {
10 |
11 | public CommandMenuInventories(MenuPlugin plugin) {
12 | super(plugin);
13 | this.setDescription(Message.DESCRIPTION_INVENTORIES);
14 | this.addSubCommand("inventories");
15 | this.setPermission(Permission.ZMENU_INVENTORIES);
16 | this.setConsoleCanUse(false);
17 | }
18 |
19 | @Override
20 | protected CommandType perform(MenuPlugin plugin) {
21 |
22 | plugin.getWebsiteManager().fetchInventories(this.player);
23 | return CommandType.SUCCESS;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/website/CommandMenuLogin.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.website;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.website.WebsiteManager;
5 | import fr.maxlego08.menu.command.VCommand;
6 | import fr.maxlego08.menu.zcore.enums.Message;
7 | import fr.maxlego08.menu.zcore.enums.Permission;
8 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
9 |
10 | public class CommandMenuLogin extends VCommand {
11 |
12 | public CommandMenuLogin(MenuPlugin plugin) {
13 | super(plugin);
14 | this.setDescription(Message.DESCRIPTION_LOGIN);
15 | this.addSubCommand("login");
16 | this.setPermission(Permission.ZMENU_LOGIN);
17 | this.addRequireArg("token");
18 | }
19 |
20 | @Override
21 | protected CommandType perform(MenuPlugin plugin) {
22 |
23 | String token = this.argAsString(0);
24 |
25 | WebsiteManager manager = plugin.getWebsiteManager();
26 | manager.login(this.sender, token);
27 |
28 | return CommandType.SUCCESS;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/command/commands/website/CommandMenuMarketplace.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.command.commands.website;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.command.VCommand;
5 | import fr.maxlego08.menu.zcore.enums.Message;
6 | import fr.maxlego08.menu.zcore.enums.Permission;
7 | import fr.maxlego08.menu.zcore.utils.commands.CommandType;
8 |
9 | public class CommandMenuMarketplace extends VCommand {
10 |
11 | public CommandMenuMarketplace(MenuPlugin plugin) {
12 | super(plugin);
13 | this.setDescription(Message.DESCRIPTION_MARKETPLACE);
14 | this.addSubCommand("marketplace", "market", "shop");
15 | this.setPermission(Permission.ZMENU_MARKETPLACE);
16 | this.setConsoleCanUse(false);
17 | }
18 |
19 | @Override
20 | protected CommandType perform(MenuPlugin plugin) {
21 |
22 | plugin.getWebsiteManager().openMarketplace(this.player);
23 | return CommandType.SUCCESS;
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/dupe/NMSDupeManager.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.dupe;
2 |
3 | import fr.maxlego08.menu.api.dupe.DupeManager;
4 | import fr.maxlego08.menu.zcore.utils.nms.ItemStackCompound;
5 | import org.bukkit.inventory.ItemStack;
6 |
7 | public class NMSDupeManager implements DupeManager {
8 |
9 | @Override
10 | public ItemStack protectItem(ItemStack itemStack) {
11 | return ItemStackCompound.itemStackCompound.setBoolean(itemStack, DupeManager.KEY, true);
12 | }
13 |
14 | @Override
15 | public boolean isDupeItem(ItemStack itemStack) {
16 | return ItemStackCompound.itemStackCompound.isKey(itemStack, DupeManager.KEY);
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/enchantment/ZMenuEnchantment.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.enchantment;
2 |
3 | import fr.maxlego08.menu.api.enchantment.MenuEnchantment;
4 | import org.bukkit.enchantments.Enchantment;
5 |
6 | import java.util.List;
7 |
8 | public class ZMenuEnchantment implements MenuEnchantment {
9 |
10 | private final Enchantment enchantment;
11 | private final List aliases;
12 |
13 | public ZMenuEnchantment(Enchantment enchantment, List aliases) {
14 | this.enchantment = enchantment;
15 | this.aliases = aliases;
16 | }
17 |
18 | public Enchantment getEnchantment() {
19 | return enchantment;
20 | }
21 |
22 | public List getAliases() {
23 | return aliases;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/ButtonAlreadyRegisterException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class ButtonAlreadyRegisterException extends Error {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = -2426306444018640211L;
9 |
10 | /**
11 | *
12 | */
13 | public ButtonAlreadyRegisterException() {
14 | super();
15 | // TODO Auto-generated constructor stub
16 | }
17 |
18 | /**
19 | * @param message
20 | * @param cause
21 | * @param enableSuppression
22 | * @param writableStackTrace
23 | */
24 | public ButtonAlreadyRegisterException(String message, Throwable cause, boolean enableSuppression,
25 | boolean writableStackTrace) {
26 | super(message, cause, enableSuppression, writableStackTrace);
27 | // TODO Auto-generated constructor stub
28 | }
29 |
30 | /**
31 | * @param message
32 | * @param cause
33 | */
34 | public ButtonAlreadyRegisterException(String message, Throwable cause) {
35 | super(message, cause);
36 | // TODO Auto-generated constructor stub
37 | }
38 |
39 | /**
40 | * @param message
41 | */
42 | public ButtonAlreadyRegisterException(String message) {
43 | super(message);
44 | // TODO Auto-generated constructor stub
45 | }
46 |
47 | /**
48 | * @param cause
49 | */
50 | public ButtonAlreadyRegisterException(Throwable cause) {
51 | super(cause);
52 | // TODO Auto-generated constructor stub
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventoryAlreadyExistException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventoryAlreadyExistException extends Error {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = -5611455794293458580L;
9 |
10 | public InventoryAlreadyExistException() {
11 | super();
12 | // TODO Auto-generated constructor stub
13 | }
14 |
15 | public InventoryAlreadyExistException(String message, Throwable cause, boolean enableSuppression,
16 | boolean writableStackTrace) {
17 | super(message, cause, enableSuppression, writableStackTrace);
18 | // TODO Auto-generated constructor stub
19 | }
20 |
21 | public InventoryAlreadyExistException(String message, Throwable cause) {
22 | super(message, cause);
23 | // TODO Auto-generated constructor stub
24 | }
25 |
26 | public InventoryAlreadyExistException(String message) {
27 | super(message);
28 | // TODO Auto-generated constructor stub
29 | }
30 |
31 | public InventoryAlreadyExistException(Throwable cause) {
32 | super(cause);
33 | // TODO Auto-generated constructor stub
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventoryButtonException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventoryButtonException extends InventoryException {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = -8733148642557198564L;
9 |
10 | /**
11 | *
12 | */
13 | public InventoryButtonException() {
14 | super();
15 | // TODO Auto-generated constructor stub
16 | }
17 |
18 | /**
19 | * @param message
20 | * @param cause
21 | * @param enableSuppression
22 | * @param writableStackTrace
23 | */
24 | public InventoryButtonException(String message, Throwable cause, boolean enableSuppression,
25 | boolean writableStackTrace) {
26 | super(message, cause, enableSuppression, writableStackTrace);
27 | // TODO Auto-generated constructor stub
28 | }
29 |
30 | /**
31 | * @param message
32 | * @param cause
33 | */
34 | public InventoryButtonException(String message, Throwable cause) {
35 | super(message, cause);
36 | // TODO Auto-generated constructor stub
37 | }
38 |
39 | /**
40 | * @param message
41 | */
42 | public InventoryButtonException(String message) {
43 | super(message);
44 | // TODO Auto-generated constructor stub
45 | }
46 |
47 | /**
48 | * @param cause
49 | */
50 | public InventoryButtonException(Throwable cause) {
51 | super(cause);
52 | // TODO Auto-generated constructor stub
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventoryException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventoryException extends Exception {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 2498115281127927055L;
9 |
10 | public InventoryException() {
11 | // TODO Auto-generated constructor stub
12 | }
13 |
14 | public InventoryException(String message) {
15 | super(message);
16 | // TODO Auto-generated constructor stub
17 | }
18 |
19 | public InventoryException(Throwable cause) {
20 | super(cause);
21 | // TODO Auto-generated constructor stub
22 | }
23 |
24 | public InventoryException(String message, Throwable cause) {
25 | super(message, cause);
26 | // TODO Auto-generated constructor stub
27 | }
28 |
29 | public InventoryException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
30 | super(message, cause, enableSuppression, writableStackTrace);
31 | // TODO Auto-generated constructor stub
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventoryFileNotFound.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventoryFileNotFound extends InventoryException {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 5794114572465101305L;
9 |
10 | /**
11 | *
12 | */
13 | public InventoryFileNotFound() {
14 | super();
15 | // TODO Auto-generated constructor stub
16 | }
17 |
18 | /**
19 | * @param message
20 | * @param cause
21 | * @param enableSuppression
22 | * @param writableStackTrace
23 | */
24 | public InventoryFileNotFound(String message, Throwable cause, boolean enableSuppression,
25 | boolean writableStackTrace) {
26 | super(message, cause, enableSuppression, writableStackTrace);
27 | // TODO Auto-generated constructor stub
28 | }
29 |
30 | /**
31 | * @param message
32 | * @param cause
33 | */
34 | public InventoryFileNotFound(String message, Throwable cause) {
35 | super(message, cause);
36 | // TODO Auto-generated constructor stub
37 | }
38 |
39 | /**
40 | * @param message
41 | */
42 | public InventoryFileNotFound(String message) {
43 | super(message);
44 | // TODO Auto-generated constructor stub
45 | }
46 |
47 | /**
48 | * @param cause
49 | */
50 | public InventoryFileNotFound(Throwable cause) {
51 | super(cause);
52 | // TODO Auto-generated constructor stub
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventoryOpenException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventoryOpenException extends Exception {
4 |
5 |
6 | private static final long serialVersionUID = 1L;
7 |
8 | public InventoryOpenException() {
9 | super();
10 | // TODO Auto-generated constructor stub
11 | }
12 |
13 | public InventoryOpenException(String message, Throwable cause, boolean enableSuppression,
14 | boolean writableStackTrace) {
15 | super(message, cause, enableSuppression, writableStackTrace);
16 | // TODO Auto-generated constructor stub
17 | }
18 |
19 | public InventoryOpenException(String message, Throwable cause) {
20 | super(message, cause);
21 | // TODO Auto-generated constructor stub
22 | }
23 |
24 | public InventoryOpenException(String message) {
25 | super(message);
26 | // TODO Auto-generated constructor stub
27 | }
28 |
29 | public InventoryOpenException(Throwable cause) {
30 | super(cause);
31 | // TODO Auto-generated constructor stub
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventorySizeException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventorySizeException extends InventoryException {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 8685275095501686794L;
9 |
10 | /**
11 | *
12 | */
13 | public InventorySizeException() {
14 | super();
15 | // TODO Auto-generated constructor stub
16 | }
17 |
18 | /**
19 | * @param message
20 | * @param cause
21 | * @param enableSuppression
22 | * @param writableStackTrace
23 | */
24 | public InventorySizeException(String message, Throwable cause, boolean enableSuppression,
25 | boolean writableStackTrace) {
26 | super(message, cause, enableSuppression, writableStackTrace);
27 | // TODO Auto-generated constructor stub
28 | }
29 |
30 | /**
31 | * @param message
32 | * @param cause
33 | */
34 | public InventorySizeException(String message, Throwable cause) {
35 | super(message, cause);
36 | // TODO Auto-generated constructor stub
37 | }
38 |
39 | /**
40 | * @param message
41 | */
42 | public InventorySizeException(String message) {
43 | super(message);
44 | // TODO Auto-generated constructor stub
45 | }
46 |
47 | /**
48 | * @param cause
49 | */
50 | public InventorySizeException(Throwable cause) {
51 | super(cause);
52 | // TODO Auto-generated constructor stub
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/InventoryTypeException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class InventoryTypeException extends InventoryException {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | /**
11 | *
12 | */
13 | public InventoryTypeException() {
14 | super();
15 | // TODO Auto-generated constructor stub
16 | }
17 |
18 | /**
19 | * @param message
20 | * @param cause
21 | * @param enableSuppression
22 | * @param writableStackTrace
23 | */
24 | public InventoryTypeException(String message, Throwable cause, boolean enableSuppression,
25 | boolean writableStackTrace) {
26 | super(message, cause, enableSuppression, writableStackTrace);
27 | // TODO Auto-generated constructor stub
28 | }
29 |
30 | /**
31 | * @param message
32 | * @param cause
33 | */
34 | public InventoryTypeException(String message, Throwable cause) {
35 | super(message, cause);
36 | // TODO Auto-generated constructor stub
37 | }
38 |
39 | /**
40 | * @param message
41 | */
42 | public InventoryTypeException(String message) {
43 | super(message);
44 | // TODO Auto-generated constructor stub
45 | }
46 |
47 | /**
48 | * @param cause
49 | */
50 | public InventoryTypeException(Throwable cause) {
51 | super(cause);
52 | // TODO Auto-generated constructor stub
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/ItemCreateException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class ItemCreateException extends Error {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public ItemCreateException() {
11 | super();
12 | // TODO Auto-generated constructor stub
13 | }
14 |
15 | public ItemCreateException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
16 | super(message, cause, enableSuppression, writableStackTrace);
17 | // TODO Auto-generated constructor stub
18 | }
19 |
20 | public ItemCreateException(String message, Throwable cause) {
21 | super(message, cause);
22 | // TODO Auto-generated constructor stub
23 | }
24 |
25 | public ItemCreateException(String message) {
26 | super(message);
27 | // TODO Auto-generated constructor stub
28 | }
29 |
30 | public ItemCreateException(Throwable cause) {
31 | super(cause);
32 | // TODO Auto-generated constructor stub
33 | }
34 |
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/ItemEnchantException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | */
4 | package fr.maxlego08.menu.exceptions;
5 |
6 | /**
7 | * @author Maxlego08
8 | *
9 | */
10 | public class ItemEnchantException extends Exception {
11 |
12 | /**
13 | *
14 | */
15 | private static final long serialVersionUID = 1L;
16 |
17 | /**
18 | *
19 | */
20 | public ItemEnchantException() {
21 | // TODO Auto-generated constructor stub
22 | }
23 |
24 | /**
25 | * @param message
26 | */
27 | public ItemEnchantException(String message) {
28 | super(message);
29 | // TODO Auto-generated constructor stub
30 | }
31 |
32 | /**
33 | * @param cause
34 | */
35 | public ItemEnchantException(Throwable cause) {
36 | super(cause);
37 | // TODO Auto-generated constructor stub
38 | }
39 |
40 | /**
41 | * @param message
42 | * @param cause
43 | */
44 | public ItemEnchantException(String message, Throwable cause) {
45 | super(message, cause);
46 | // TODO Auto-generated constructor stub
47 | }
48 |
49 | /**
50 | * @param message
51 | * @param cause
52 | * @param enableSuppression
53 | * @param writableStackTrace
54 | */
55 | public ItemEnchantException(String message, Throwable cause, boolean enableSuppression,
56 | boolean writableStackTrace) {
57 | super(message, cause, enableSuppression, writableStackTrace);
58 | // TODO Auto-generated constructor stub
59 | }
60 |
61 | }
62 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/ItemFlagException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class ItemFlagException extends Exception {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public ItemFlagException() {
11 | // TODO Auto-generated constructor stub
12 | }
13 |
14 | public ItemFlagException(String message) {
15 | super(message);
16 | // TODO Auto-generated constructor stub
17 | }
18 |
19 | public ItemFlagException(Throwable cause) {
20 | super(cause);
21 | // TODO Auto-generated constructor stub
22 | }
23 |
24 | public ItemFlagException(String message, Throwable cause) {
25 | super(message, cause);
26 | // TODO Auto-generated constructor stub
27 | }
28 |
29 | public ItemFlagException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
30 | super(message, cause, enableSuppression, writableStackTrace);
31 | // TODO Auto-generated constructor stub
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/exceptions/ListenerNullException.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.exceptions;
2 |
3 | public class ListenerNullException extends Error {
4 |
5 | /**
6 | *
7 | */
8 | private static final long serialVersionUID = 1L;
9 |
10 | public ListenerNullException() {
11 | // TODO Auto-generated constructor stub
12 | }
13 |
14 | public ListenerNullException(String message) {
15 | super(message);
16 | // TODO Auto-generated constructor stub
17 | }
18 |
19 | public ListenerNullException(Throwable cause) {
20 | super(cause);
21 | // TODO Auto-generated constructor stub
22 | }
23 |
24 | public ListenerNullException(String message, Throwable cause) {
25 | super(message, cause);
26 | // TODO Auto-generated constructor stub
27 | }
28 |
29 | public ListenerNullException(String message, Throwable cause, boolean enableSuppression,
30 | boolean writableStackTrace) {
31 | super(message, cause, enableSuppression, writableStackTrace);
32 | // TODO Auto-generated constructor stub
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/font/EmptyFont.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.font;
2 |
3 | import fr.maxlego08.menu.api.font.FontImage;
4 |
5 | public class EmptyFont implements FontImage {
6 |
7 | @Override
8 | public String replace(String string) {
9 | return string;
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/font/ItemsAdderFont.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.font;
2 |
3 | import dev.lone.itemsadder.api.FontImages.FontImageWrapper;
4 | import fr.maxlego08.menu.api.font.FontImage;
5 |
6 | import java.util.regex.Matcher;
7 | import java.util.regex.Pattern;
8 |
9 | public class ItemsAdderFont implements FontImage {
10 |
11 | private final Pattern pattern = Pattern.compile(":(\\w+):");
12 |
13 | @Override
14 | public String replace(String string) {
15 | Matcher matcher = pattern.matcher(string);
16 | StringBuffer result = new StringBuffer();
17 | while (matcher.find()) {
18 | String replacement = FontImageWrapper.replaceFontImages(matcher.group(0));
19 | matcher.appendReplacement(result, replacement);
20 | }
21 | matcher.appendTail(result);
22 | return result.toString();
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/itemstack/FullSimilar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.itemstack;
2 |
3 | import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
4 | import org.bukkit.inventory.ItemStack;
5 |
6 | public class FullSimilar implements ItemStackSimilar {
7 | @Override
8 | public String getName() {
9 | return "full";
10 | }
11 |
12 | @Override
13 | public boolean isSimilar(ItemStack itemStackA, ItemStack itemStackB) {
14 | if (itemStackA == null || itemStackB == null) return false;
15 | return itemStackA.isSimilar(itemStackB);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/itemstack/LoreSimilar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.itemstack;
2 |
3 | import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
4 | import org.bukkit.inventory.ItemStack;
5 | import org.bukkit.inventory.meta.ItemMeta;
6 |
7 | import java.util.Objects;
8 |
9 | public class LoreSimilar implements ItemStackSimilar {
10 | @Override
11 | public String getName() {
12 | return "lore";
13 | }
14 |
15 | @Override
16 | public boolean isSimilar(ItemStack itemStackA, ItemStack itemStackB) {
17 | if (itemStackA == null || itemStackB == null) return false;
18 | ItemMeta metaA = itemStackA.getItemMeta();
19 | ItemMeta metaB = itemStackB.getItemMeta();
20 | if (metaA == null || metaB == null) return false;
21 | return metaA.hasLore() && metaB.hasLore() && Objects.equals(metaA.getLore(), metaB.getLore());
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/itemstack/MaterialSimilar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.itemstack;
2 |
3 | import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
4 | import org.bukkit.inventory.ItemStack;
5 |
6 | public class MaterialSimilar implements ItemStackSimilar {
7 | @Override
8 | public String getName() {
9 | return "material";
10 | }
11 |
12 | @Override
13 | public boolean isSimilar(ItemStack itemStackA, ItemStack itemStackB) {
14 | return itemStackA.getType() == itemStackB.getType();
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/itemstack/ModelIdSimilar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.itemstack;
2 |
3 | import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
4 | import org.bukkit.inventory.ItemStack;
5 | import org.bukkit.inventory.meta.ItemMeta;
6 |
7 | public class ModelIdSimilar implements ItemStackSimilar {
8 | @Override
9 | public String getName() {
10 | return "modelId";
11 | }
12 |
13 | @Override
14 | public boolean isSimilar(ItemStack itemStackA, ItemStack itemStackB) {
15 | if (itemStackA == null || itemStackB == null) return false;
16 | ItemMeta metaA = itemStackA.getItemMeta();
17 | ItemMeta metaB = itemStackB.getItemMeta();
18 | if (metaA == null || metaB == null) return false;
19 | return metaA.hasCustomModelData() && metaB.hasCustomModelData() && metaA.getCustomModelData() == metaB.getCustomModelData();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/itemstack/NameSimilar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.itemstack;
2 |
3 | import fr.maxlego08.menu.api.itemstack.ItemStackSimilar;
4 | import org.bukkit.inventory.ItemStack;
5 | import org.bukkit.inventory.meta.ItemMeta;
6 |
7 | public class NameSimilar implements ItemStackSimilar {
8 | @Override
9 | public String getName() {
10 | return "name";
11 | }
12 |
13 | @Override
14 | public boolean isSimilar(ItemStack itemStackA, ItemStack itemStackB) {
15 | if (itemStackA == null || itemStackB == null) return false;
16 | ItemMeta metaA = itemStackA.getItemMeta();
17 | ItemMeta metaB = itemStackB.getItemMeta();
18 | if (metaA == null || metaB == null) return false;
19 | return metaA.hasDisplayName() && metaB.hasDisplayName() && metaA.getDisplayName().equals(metaB.getDisplayName());
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/listener/HeadDatabaseListener.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.listener;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import me.arcaniax.hdb.api.DatabaseLoadEvent;
5 | import org.bukkit.event.EventHandler;
6 | import org.bukkit.event.Listener;
7 |
8 | public class HeadDatabaseListener implements Listener {
9 |
10 | private final MenuPlugin plugin;
11 |
12 | /**
13 | * @param plugin
14 | */
15 | public HeadDatabaseListener(MenuPlugin plugin) {
16 | super();
17 | this.plugin = plugin;
18 | }
19 |
20 | @EventHandler
21 | public void onRead(DatabaseLoadEvent event) {
22 | this.plugin.getSavers().forEach(saver -> saver.load(this.plugin.getPersist()));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/listener/SwapKeyListener.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.listener;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.InventoryManager;
5 | import fr.maxlego08.menu.save.Config;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.event.EventHandler;
8 | import org.bukkit.event.Listener;
9 | import org.bukkit.event.player.PlayerSwapHandItemsEvent;
10 |
11 | /**
12 | * Allows to use the key to change item in his second hand, by default the key will be F
13 | */
14 | public class SwapKeyListener implements Listener {
15 | @EventHandler
16 | public void onPressKey(PlayerSwapHandItemsEvent event) {
17 | if (Config.useSwapItemOffHandKeyToOpenMainMenu) {
18 | InventoryManager inventoryManager = MenuPlugin.getInstance().getInventoryManager();
19 | Player player = event.getPlayer();
20 |
21 | if (Config.useSwapItemOffHandKeyToOpenMainMenuNeedsShift) {
22 | if (player.isSneaking()) {
23 | inventoryManager.openInventory(player, Config.mainMenu);
24 | event.setCancelled(true);
25 | }
26 | } else {
27 | inventoryManager.openInventory(player, Config.mainMenu);
28 | event.setCancelled(true);
29 | }
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/ActionBarLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.ActionBarAction;
7 |
8 | import java.io.File;
9 |
10 | public class ActionBarLoader implements ActionLoader {
11 |
12 | @Override
13 | public String getKey() {
14 | return "action,actionbar";
15 | }
16 |
17 | @Override
18 | public Action load(String path, TypedMapAccessor accessor, File file) {
19 | boolean miniMessage = accessor.getBoolean("minimessage", true);
20 | String message = accessor.getString("message");
21 | return new ActionBarAction(message, miniMessage);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/BackLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.requirement.actions.BackAction;
8 | import fr.maxlego08.menu.requirement.actions.InventoryAction;
9 |
10 | import java.io.File;
11 |
12 | public class BackLoader implements ActionLoader {
13 |
14 | private final MenuPlugin plugin;
15 |
16 | public BackLoader(MenuPlugin plugin) {
17 | this.plugin = plugin;
18 | }
19 |
20 | @Override
21 | public String getKey() {
22 | return "back";
23 | }
24 |
25 | @Override
26 | public Action load(String path, TypedMapAccessor accessor, File file) {
27 | return new BackAction(this.plugin.getInventoryManager());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/BookLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.OpenBookAction;
7 |
8 | import java.io.File;
9 | import java.util.ArrayList;
10 | import java.util.HashMap;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | public class BookLoader implements ActionLoader {
15 |
16 | @Override
17 | public String getKey() {
18 | return "book";
19 | }
20 |
21 | @Override
22 | public Action load(String path, TypedMapAccessor accessor, File file) {
23 |
24 | String title = accessor.getString("title");
25 | String author = accessor.getString("subtitle");
26 | List lines = new ArrayList<>();
27 |
28 | Map, List> maps = (Map, List>) accessor.getObject("lines", new HashMap<>());
29 | maps.forEach((page, currentLine) -> lines.add(String.join("", currentLine)));
30 |
31 | return new OpenBookAction(title, author, lines);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/BroadcastLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.requirement.Permissible;
7 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
8 | import fr.maxlego08.menu.requirement.actions.BroadcastAction;
9 |
10 | import java.io.File;
11 | import java.util.ArrayList;
12 | import java.util.List;
13 | import java.util.Map;
14 |
15 | public class BroadcastLoader implements ActionLoader {
16 |
17 |
18 | private final MenuPlugin plugin;
19 |
20 | public BroadcastLoader(MenuPlugin plugin) {
21 | this.plugin = plugin;
22 | }
23 |
24 | @Override
25 | public String getKey() {
26 | return "broadcast";
27 | }
28 |
29 | @Override
30 | public Action load(String path, TypedMapAccessor accessor, File file) {
31 | boolean miniMessage = accessor.getBoolean("minimessage", accessor.getBoolean("mini-message", true));
32 | List messages = accessor.getStringList("messages");
33 | List requirements = new ArrayList<>();
34 | if (accessor.contains("requirements")) {
35 | requirements = this.plugin.getButtonManager().loadPermissible((List>) accessor.getObject("requirements"), path, file);
36 | }
37 | return new BroadcastAction(messages, miniMessage, requirements);
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/BroadcastSoundLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.requirement.Action;
4 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
5 | import fr.maxlego08.menu.requirement.actions.BroadcastSoundAction;
6 |
7 | import java.io.File;
8 |
9 | public class BroadcastSoundLoader extends SoundLoader {
10 |
11 | @Override
12 | public String getKey() {
13 | return "broadcast_sound,broadcast sound";
14 | }
15 |
16 | @Override
17 | public Action load(String path, TypedMapAccessor accessor, File file) {
18 | return new BroadcastSoundAction(loadSound(path, accessor, file));
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/ChatLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.MessageAction;
7 | import fr.maxlego08.menu.requirement.actions.PlayerChatAction;
8 |
9 | import java.io.File;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | public class ChatLoader implements ActionLoader {
15 |
16 | @Override
17 | public String getKey() {
18 | return "chat";
19 | }
20 |
21 | @Override
22 | public Action load(String path, TypedMapAccessor accessor, File file) {
23 | List commands = accessor.getStringList("messages");
24 | return new PlayerChatAction(commands);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/CloseLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.CloseAction;
7 | import fr.maxlego08.menu.requirement.actions.MessageAction;
8 |
9 | import java.io.File;
10 | import java.util.ArrayList;
11 | import java.util.List;
12 | import java.util.Map;
13 |
14 | public class CloseLoader implements ActionLoader {
15 |
16 | @Override
17 | public String getKey() {
18 | return "close";
19 | }
20 |
21 | @Override
22 | public Action load(String path, TypedMapAccessor accessor, File file) {
23 | return new CloseAction();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/ConnectLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.requirement.actions.ConnectAction;
8 |
9 | import java.io.File;
10 | import java.util.Map;
11 |
12 | public class ConnectLoader implements ActionLoader {
13 |
14 | private final MenuPlugin plugin;
15 |
16 | public ConnectLoader(MenuPlugin plugin) {
17 | this.plugin = plugin;
18 | }
19 |
20 | @Override
21 | public String getKey() {
22 | return "connect";
23 | }
24 |
25 | @Override
26 | public Action load(String path, TypedMapAccessor accessor, File file) {
27 | String server = accessor.getString("server", "hub");
28 | return new ConnectAction(server, plugin);
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/ConsoleCommandLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.ConsoleCommandAction;
7 |
8 | import java.io.File;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | public class ConsoleCommandLoader implements ActionLoader {
14 |
15 | @Override
16 | public String getKey() {
17 | return "console_command,console_commands,console commands,console command,command,commands,console-commands,console-command";
18 | }
19 |
20 | @Override
21 | public Action load(String path, TypedMapAccessor accessor, File file) {
22 | List commands = accessor.getStringList("commands");
23 | return new ConsoleCommandAction(commands);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/CurrencyDepositLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.CurrencyDepositAction;
7 | import fr.traqueur.currencies.Currencies;
8 |
9 | import java.io.File;
10 | import java.math.BigDecimal;
11 |
12 | public class CurrencyDepositLoader implements ActionLoader {
13 |
14 | @Override
15 | public String getKey() {
16 | return "deposit,money add";
17 | }
18 |
19 | @Override
20 | public Action load(String path, TypedMapAccessor accessor, File file) {
21 | String bigDecimal = accessor.getString("amount");
22 | Currencies currencies = Currencies.valueOf(accessor.getString("currency", Currencies.VAULT.name()).toUpperCase());
23 | String economyName = accessor.getString("economy", null);
24 | return new CurrencyDepositAction(bigDecimal, currencies, economyName);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/CurrencyWithdrawLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.CurrencyWithdrawAction;
7 | import fr.traqueur.currencies.Currencies;
8 |
9 | import java.io.File;
10 | import java.math.BigDecimal;
11 |
12 | public class CurrencyWithdrawLoader implements ActionLoader {
13 |
14 | @Override
15 | public String getKey() {
16 | return "withdraw,money remove";
17 | }
18 |
19 | @Override
20 | public Action load(String path, TypedMapAccessor accessor, File file) {
21 | String bigDecimal = accessor.getString("amount");
22 | Currencies currencies = Currencies.valueOf(accessor.getString("currency", Currencies.VAULT.name()).toUpperCase());
23 | String economyName = accessor.getString("economy", null);
24 | return new CurrencyWithdrawAction(bigDecimal, currencies, economyName);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/DataLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.requirement.data.ActionPlayerDataType;
7 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
8 | import fr.maxlego08.menu.requirement.ZActionPlayerData;
9 | import fr.maxlego08.menu.requirement.actions.DataAction;
10 |
11 | import java.io.File;
12 |
13 | public class DataLoader implements ActionLoader {
14 |
15 | private final MenuPlugin plugin;
16 |
17 | public DataLoader(MenuPlugin plugin) {
18 | this.plugin = plugin;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "data";
24 | }
25 |
26 | @Override
27 | public Action load(String path, TypedMapAccessor accessor, File file) {
28 | ActionPlayerDataType type = ActionPlayerDataType.valueOf(accessor.getString("action", "SET").toUpperCase());
29 | String key = accessor.getString("key");
30 | Object object = accessor.getObject("value", true);
31 | long seconds = accessor.getLong("seconds", 0L);
32 | return new DataAction(new ZActionPlayerData(key, type, object, seconds), plugin);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/InventoryLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.requirement.actions.InventoryAction;
8 |
9 | import java.io.File;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | public class InventoryLoader implements ActionLoader {
14 |
15 | private final MenuPlugin plugin;
16 |
17 | public InventoryLoader(MenuPlugin plugin) {
18 | this.plugin = plugin;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "inventory";
24 | }
25 |
26 | @Override
27 | public Action load(String path, TypedMapAccessor accessor, File file) {
28 | String inventory = accessor.getString("inventory");
29 | String plugin = accessor.getString("plugin");
30 | String page = accessor.getString("page");
31 | List arguments = accessor.getStringList("arguments");
32 | return new InventoryAction(this.plugin.getInventoryManager(), this.plugin.getCommandManager(), inventory, plugin, page, arguments);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/LuckPermissionSetLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.LuckPermissionSet;
7 |
8 | import java.io.File;
9 |
10 | public class LuckPermissionSetLoader implements ActionLoader {
11 |
12 | @Override
13 | public String getKey() {
14 | return "permission-set,permission set,set permission,set-permission";
15 | }
16 |
17 | @Override
18 | public Action load(String path, TypedMapAccessor accessor, File file) {
19 | String permission = accessor.getString("permission");
20 | return new LuckPermissionSet(permission);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/MessageLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.MessageAction;
7 |
8 | import java.io.File;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 |
12 | public class MessageLoader implements ActionLoader {
13 |
14 | @Override
15 | public String getKey() {
16 | return "message,messages";
17 | }
18 |
19 | @Override
20 | public Action load(String path, TypedMapAccessor accessor, File file) {
21 | boolean miniMessage = accessor.getBoolean("minimessage", accessor.getBoolean("mini-message", true));
22 | List messages = new ArrayList<>();
23 | if (accessor.contains("message")) {
24 | messages.add(accessor.getString("message"));
25 | } else if (accessor.contains("messages")) {
26 | Object element = accessor.getObject("messages", new ArrayList<>());
27 | if (element instanceof String) {
28 | messages.add((String) element);
29 | } else {
30 | messages = accessor.getStringList("messages");
31 | }
32 | }
33 | return new MessageAction(messages, miniMessage);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/PlayerCommandLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.PlayerCommandAction;
7 |
8 | import java.io.File;
9 | import java.util.ArrayList;
10 | import java.util.List;
11 | import java.util.Map;
12 |
13 | public class PlayerCommandLoader implements ActionLoader {
14 |
15 | @Override
16 | public String getKey() {
17 | return "player_command,player_commands,player command,player commands,player-command,player-commands";
18 | }
19 |
20 | @Override
21 | public Action load(String path, TypedMapAccessor accessor, File file) {
22 | boolean inChat = accessor.getBoolean("commandInChat", accessor.getBoolean("command-in-chat", false));
23 | List commands = accessor.getStringList("commands");
24 | return new PlayerCommandAction(commands, inChat);
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/RefreshLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.RefreshAction;
7 |
8 | import java.io.File;
9 |
10 | public class RefreshLoader implements ActionLoader {
11 |
12 | @Override
13 | public String getKey() {
14 | return "refresh";
15 | }
16 |
17 | @Override
18 | public Action load(String path, TypedMapAccessor accessor, File file) {
19 | return new RefreshAction();
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/ShopkeeperLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.ShopkeeperAction;
7 |
8 | import java.io.File;
9 |
10 | public class ShopkeeperLoader implements ActionLoader {
11 | @Override
12 | public String getKey() {
13 | return "shopkeeper";
14 | }
15 |
16 | @Override
17 | public Action load(String path, TypedMapAccessor accessor, File file) {
18 | String name = accessor.getString("name", "error_name");
19 | return new ShopkeeperAction(name);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/SoundLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import com.cryptomorin.xseries.XSound;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.sound.SoundOption;
7 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
8 | import fr.maxlego08.menu.requirement.actions.SoundAction;
9 | import fr.maxlego08.menu.sound.ZSoundOption;
10 |
11 | import java.io.File;
12 |
13 | public class SoundLoader implements ActionLoader {
14 |
15 | @Override
16 | public String getKey() {
17 | return "sound";
18 | }
19 |
20 | @Override
21 | public Action load(String path, TypedMapAccessor accessor, File file) {
22 | return new SoundAction(loadSound(path, accessor, file));
23 | }
24 |
25 | protected SoundOption loadSound(String path, TypedMapAccessor accessor, File file) {
26 | String sound = accessor.getString("sound");
27 | float pitch = accessor.getFloat("pitch", 1f);
28 | float volume = accessor.getFloat("volume", 1f);
29 | String category = accessor.getString("sound-category", accessor.getString("category", XSound.Category.MASTER.name()));
30 | XSound xSound = sound == null || sound.isEmpty() ? null : XSound.of(sound).orElse(null);
31 | return new ZSoundOption(xSound, category, sound, pitch, volume, xSound == null);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/TeleportLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.loader.ActionLoader;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.requirement.actions.ActionBarAction;
8 | import fr.maxlego08.menu.requirement.actions.TeleportAction;
9 | import org.bukkit.Bukkit;
10 | import org.bukkit.Location;
11 |
12 | import java.io.File;
13 |
14 | public class TeleportLoader implements ActionLoader {
15 |
16 | private final MenuPlugin plugin;
17 |
18 | public TeleportLoader(MenuPlugin plugin) {
19 | this.plugin = plugin;
20 | }
21 |
22 | @Override
23 | public String getKey() {
24 | return "teleport,tp";
25 | }
26 |
27 | @Override
28 | public Action load(String path, TypedMapAccessor accessor, File file) {
29 | String world = accessor.getString("world", "world");
30 | double x = Double.parseDouble(accessor.getString("x", "0.0"));
31 | double y = Double.parseDouble(accessor.getString("y", "0.0"));
32 | double z = Double.parseDouble(accessor.getString("z", "0.0"));
33 | float yaw = Float.parseFloat(accessor.getString("yaw", "0.0"));
34 | float pitch = Float.parseFloat(accessor.getString("pitch", "0.0"));
35 | return new TeleportAction(this.plugin, new Location(Bukkit.getWorld(world), x, y, z, yaw, pitch));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/actions/TitleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.actions;
2 |
3 | import fr.maxlego08.menu.api.loader.ActionLoader;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
6 | import fr.maxlego08.menu.requirement.actions.TitleAction;
7 |
8 | import java.io.File;
9 |
10 | public class TitleLoader implements ActionLoader {
11 |
12 | @Override
13 | public String getKey() {
14 | return "title";
15 | }
16 |
17 | @Override
18 | public Action load(String path, TypedMapAccessor accessor, File file) {
19 |
20 | String title = accessor.getString("title");
21 | String subtitle = accessor.getString("subtitle");
22 | long start = accessor.getLong("start");
23 | long duration = accessor.getLong("duration");
24 | long end = accessor.getLong("end");
25 |
26 | return new TitleAction(title, subtitle, start, duration, end);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/ArmorLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import org.bukkit.configuration.file.YamlConfiguration;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.inventory.EquipmentSlot;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | public class ArmorLoader implements MaterialLoader {
10 | @Override
11 | public String getKey() {
12 | return "armor";
13 | }
14 |
15 | @Override
16 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
17 | return player.getEquipment().getItem(EquipmentSlot.valueOf(materialString));
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/Base64Loader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import fr.maxlego08.menu.zcore.utils.nms.ItemStackUtils;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | public class Base64Loader implements MaterialLoader {
10 | @Override
11 | public String getKey() {
12 | return "base64";
13 | }
14 |
15 | @Override
16 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
17 | return ItemStackUtils.deserializeItemStack(materialString);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/EcoLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import com.willfp.eco.core.items.Items;
4 | import fr.maxlego08.menu.api.loader.MaterialLoader;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | public class EcoLoader implements MaterialLoader {
10 | @Override
11 | public String getKey() {
12 | return "eco";
13 | }
14 |
15 | @Override
16 | public ItemStack load(Player player, YamlConfiguration yamlConfiguration, String path, String materialString) {
17 | try {
18 | //eco item lookup system:
19 | // https://plugins.auxilor.io/all-plugins/the-item-lookup-system
20 | return Items.lookup(materialString).getItem();
21 | } catch (Exception ignored) {
22 | return null;
23 | }
24 | }
25 | }
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/HeadDatabaseLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import me.arcaniax.hdb.api.HeadDatabaseAPI;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | public class HeadDatabaseLoader implements MaterialLoader {
10 |
11 | @Override
12 | public String getKey() {
13 | return "hdb";
14 | }
15 |
16 | @Override
17 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
18 |
19 | try {
20 |
21 | HeadDatabaseAPI api = new HeadDatabaseAPI();
22 | return api.getItemHead(materialString);
23 |
24 | } catch (Exception exception) {
25 | exception.printStackTrace();
26 | }
27 |
28 | return null;
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/ItemsAdderLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import dev.lone.itemsadder.api.CustomStack;
4 | import fr.maxlego08.menu.api.loader.MaterialLoader;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 | import org.bukkit.plugin.Plugin;
9 |
10 | public class ItemsAdderLoader implements MaterialLoader {
11 |
12 | private final Plugin plugin;
13 |
14 | public ItemsAdderLoader(Plugin plugin) {
15 | this.plugin = plugin;
16 | }
17 |
18 | @Override
19 | public String getKey() {
20 | return "itemsadder";
21 | }
22 |
23 | @Override
24 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
25 | CustomStack customStack = CustomStack.getInstance(materialString);
26 | if (customStack == null) {
27 | plugin.getLogger().severe("Impossible to find the item " + materialString);
28 | return null;
29 | }
30 | return customStack.getItemStack().clone();
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/MagicCosmeticsLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import org.bukkit.Material;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 | import com.francobm.magicosmetics.api.MagicAPI;
9 |
10 | public class MagicCosmeticsLoader implements MaterialLoader {
11 |
12 | @Override
13 | public String getKey() {
14 | return "magic_cosmetics";
15 | }
16 |
17 | @Override
18 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
19 | ItemStack itemStack = MagicAPI.getEquipped(player.getName(), materialString);
20 | if (itemStack == null){
21 | return new ItemStack(Material.AIR);
22 | }
23 | return itemStack;
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/NexoLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import com.nexomc.nexo.api.NexoItems;
4 | import com.nexomc.nexo.items.ItemBuilder;
5 | import fr.maxlego08.menu.api.loader.MaterialLoader;
6 | import org.bukkit.configuration.file.YamlConfiguration;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.inventory.ItemStack;
9 |
10 | /*
11 | * If you have problems compiling this class, delete it there; At the moment, it is impossible to access the nexo API.
12 | * */
13 | public class NexoLoader implements MaterialLoader {
14 |
15 | @Override
16 | public String getKey() {
17 | return "nexo";
18 | }
19 |
20 | @Override
21 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
22 | ItemBuilder builder = NexoItems.itemFromId(materialString);
23 | return builder == null ? null : builder.build();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/NovaLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import org.bukkit.configuration.file.YamlConfiguration;
5 | import org.bukkit.entity.Player;
6 | import org.bukkit.inventory.ItemStack;
7 | import xyz.xenondevs.nova.api.Nova;
8 | import xyz.xenondevs.nova.api.block.NovaBlockRegistry;
9 | import xyz.xenondevs.nova.api.item.NovaItemRegistry;
10 |
11 | import java.util.Objects;
12 |
13 | public class NovaLoader implements MaterialLoader {
14 | @Override
15 | public String getKey() {
16 | return "nova";
17 | }
18 |
19 | @Override
20 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
21 | NovaBlockRegistry blockRegistry = Nova.getNova().getBlockRegistry();
22 | NovaItemRegistry itemRegistry = Nova.getNova().getItemRegistry();
23 | return blockRegistry.getOrNull(materialString) == null ? itemRegistry.get(materialString).createItemStack() : Objects.requireNonNull(blockRegistry.get(materialString).getItem()).createItemStack();
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/OraxenLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import io.th0rgal.oraxen.api.OraxenItems;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | public class OraxenLoader implements MaterialLoader {
10 |
11 | @Override
12 | public String getKey() {
13 | return "oraxen";
14 | }
15 |
16 | @Override
17 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
18 | return OraxenItems.getItemById(materialString).build();
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/SlimeFunLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.menu.api.loader.MaterialLoader;
4 | import io.github.thebusybiscuit.slimefun4.api.items.SlimefunItem;
5 | import org.bukkit.configuration.file.YamlConfiguration;
6 | import org.bukkit.entity.Player;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | public class SlimeFunLoader implements MaterialLoader {
10 | @Override
11 | public String getKey() {
12 | return "slimefun";
13 | }
14 |
15 | @Override
16 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
17 | return SlimefunItem.getById(materialString).getItem();
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/ZHeadLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.head.api.HeadManager;
4 | import fr.maxlego08.menu.MenuPlugin;
5 | import fr.maxlego08.menu.api.loader.MaterialLoader;
6 | import org.bukkit.configuration.file.YamlConfiguration;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.inventory.ItemStack;
9 |
10 | public class ZHeadLoader implements MaterialLoader {
11 |
12 | private final HeadManager headManager;
13 |
14 | public ZHeadLoader(MenuPlugin plugin) {
15 | this.headManager = plugin.getProvider(HeadManager.class);
16 | }
17 |
18 | @Override
19 | public String getKey() {
20 | return "zhd";
21 | }
22 |
23 | @Override
24 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
25 | return this.headManager.createItemStack(materialString);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/materials/ZItemsLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.materials;
2 |
3 | import fr.maxlego08.items.api.Item;
4 | import fr.maxlego08.items.api.ItemManager;
5 | import fr.maxlego08.menu.api.loader.MaterialLoader;
6 | import org.bukkit.configuration.file.YamlConfiguration;
7 | import org.bukkit.entity.Player;
8 | import org.bukkit.inventory.ItemStack;
9 | import org.bukkit.plugin.Plugin;
10 | import org.bukkit.plugin.RegisteredServiceProvider;
11 |
12 | import java.util.Optional;
13 |
14 | public class ZItemsLoader implements MaterialLoader {
15 |
16 | private final Plugin plugin;
17 |
18 | public ZItemsLoader(Plugin plugin) {
19 | this.plugin = plugin;
20 | }
21 |
22 | @Override
23 | public String getKey() {
24 | return "zitems";
25 | }
26 |
27 | @Override
28 | public ItemStack load(Player player, YamlConfiguration configuration, String path, String materialString) {
29 | RegisteredServiceProvider itemManagerRegisteredServiceProvider = plugin.getServer().getServicesManager().getRegistration(ItemManager.class);
30 | if (itemManagerRegisteredServiceProvider == null) return null;
31 | ItemManager itemManager = itemManagerRegisteredServiceProvider.getProvider();
32 | Optional- optional = itemManager.getItem(materialString);
33 | return optional.map(item -> item.build(player, 1)).orElse(null);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/permissible/CurrencyPermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.permissible;
2 |
3 | import fr.maxlego08.menu.api.ButtonManager;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.loader.ZPermissibleLoader;
8 | import fr.maxlego08.menu.requirement.permissible.ZCurrencyPermissible;
9 | import fr.traqueur.currencies.Currencies;
10 |
11 | import java.io.File;
12 | import java.math.BigDecimal;
13 | import java.util.List;
14 |
15 | public class CurrencyPermissibleLoader extends ZPermissibleLoader {
16 |
17 | private final ButtonManager buttonManager;
18 |
19 | public CurrencyPermissibleLoader(ButtonManager buttonManager) {
20 | this.buttonManager = buttonManager;
21 | }
22 |
23 | @Override
24 | public String getKey() {
25 | return "money";
26 | }
27 |
28 | @Override
29 | public Permissible load(String path, TypedMapAccessor accessor, File file) {
30 | List
denyActions = loadAction(buttonManager, accessor, "deny", path, file);
31 | List successActions = loadAction(buttonManager, accessor, "success", path, file);
32 | String amount = accessor.getString("amount");
33 | Currencies currencies = Currencies.valueOf(accessor.getString("currency", Currencies.VAULT.name()).toUpperCase());
34 | String economyName = accessor.getString("economy", null);
35 | return new ZCurrencyPermissible(denyActions, successActions, currencies, amount, economyName);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/permissible/JobPermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.permissible;
2 |
3 | import fr.maxlego08.menu.api.ButtonManager;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.loader.ZPermissibleLoader;
8 | import fr.maxlego08.menu.requirement.permissible.ZJobPermissible;
9 |
10 | import java.io.File;
11 | import java.util.List;
12 |
13 | public class JobPermissibleLoader extends ZPermissibleLoader {
14 |
15 | private final ButtonManager buttonManager;
16 |
17 | public JobPermissibleLoader(ButtonManager buttonManager) {
18 | this.buttonManager = buttonManager;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "job";
24 | }
25 |
26 | @Override
27 | public Permissible load(String path, TypedMapAccessor accessor, File file) {
28 | List denyActions = loadAction(buttonManager, accessor, "deny", path, file);
29 | List successActions = loadAction(buttonManager, accessor, "success", path, file);
30 | return new ZJobPermissible(denyActions, successActions, accessor.getString("job"));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/permissible/LuckPermPermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.permissible;
2 |
3 | import fr.maxlego08.menu.api.ButtonManager;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.loader.ZPermissibleLoader;
8 | import fr.maxlego08.menu.requirement.permissible.ZLuckPermPermissible;
9 |
10 | import java.io.File;
11 | import java.util.List;
12 |
13 | public class LuckPermPermissibleLoader extends ZPermissibleLoader {
14 |
15 | private final ButtonManager buttonManager;
16 |
17 | public LuckPermPermissibleLoader(ButtonManager buttonManager) {
18 | this.buttonManager = buttonManager;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "luckperm";
24 | }
25 |
26 | @Override
27 | public Permissible load(String path, TypedMapAccessor accessor, File file) {
28 | List denyActions = loadAction(buttonManager, accessor, "deny", path, file);
29 | List successActions = loadAction(buttonManager, accessor, "success", path, file);
30 | return new ZLuckPermPermissible(denyActions, successActions, accessor.getString("group"));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/permissible/PermissionPermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.permissible;
2 |
3 | import fr.maxlego08.menu.api.ButtonManager;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.loader.ZPermissibleLoader;
8 | import fr.maxlego08.menu.requirement.permissible.ZPermissionPermissible;
9 |
10 | import java.io.File;
11 | import java.util.List;
12 |
13 | public class PermissionPermissibleLoader extends ZPermissibleLoader {
14 |
15 | private final ButtonManager buttonManager;
16 |
17 | public PermissionPermissibleLoader(ButtonManager buttonManager) {
18 | this.buttonManager = buttonManager;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "permission";
24 | }
25 |
26 | @Override
27 | public Permissible load(String path, TypedMapAccessor accessor, File file) {
28 | List denyActions = loadAction(buttonManager, accessor, "deny", path, file);
29 | List successActions = loadAction(buttonManager, accessor, "success", path, file);
30 | return new ZPermissionPermissible(accessor.getString("permission"), denyActions, successActions);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/permissible/PlayerNamePermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.permissible;
2 |
3 | import fr.maxlego08.menu.api.ButtonManager;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.loader.ZPermissibleLoader;
8 | import fr.maxlego08.menu.requirement.permissible.ZPlayerNamePermissible;
9 |
10 | import java.io.File;
11 | import java.util.List;
12 |
13 | public class PlayerNamePermissibleLoader extends ZPermissibleLoader {
14 |
15 | private final ButtonManager buttonManager;
16 |
17 | public PlayerNamePermissibleLoader(ButtonManager buttonManager) {
18 | this.buttonManager = buttonManager;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "playername";
24 | }
25 |
26 | @Override
27 | public Permissible load(String path, TypedMapAccessor accessor, File file) {
28 | List denyActions = loadAction(buttonManager, accessor, "deny", path, file);
29 | List successActions = loadAction(buttonManager, accessor, "success", path, file);
30 | return new ZPlayerNamePermissible(accessor.getString("playerName", accessor.getString("playername", accessor.getString("player-name"))), denyActions, successActions);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/loader/permissible/RegexPermissibleLoader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.loader.permissible;
2 |
3 | import fr.maxlego08.menu.api.ButtonManager;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.TypedMapAccessor;
7 | import fr.maxlego08.menu.loader.ZPermissibleLoader;
8 | import fr.maxlego08.menu.requirement.permissible.ZRegexPermissible;
9 |
10 | import java.io.File;
11 | import java.util.List;
12 |
13 | public class RegexPermissibleLoader extends ZPermissibleLoader {
14 |
15 | private final ButtonManager buttonManager;
16 |
17 | public RegexPermissibleLoader(ButtonManager buttonManager) {
18 | this.buttonManager = buttonManager;
19 | }
20 |
21 | @Override
22 | public String getKey() {
23 | return "regex";
24 | }
25 |
26 | @Override
27 | public Permissible load(String path, TypedMapAccessor accessor, File file) {
28 | String placeholder = accessor.getString("input");
29 | String regex = accessor.getString("regex");
30 |
31 | List denyActions = loadAction(buttonManager, accessor, "deny", path, file);
32 | List successActions = loadAction(buttonManager, accessor, "success", path, file);
33 |
34 | return new ZRegexPermissible(regex, placeholder, denyActions, successActions);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/pattern/ZPattern.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.pattern;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.pattern.Pattern;
5 |
6 | import java.util.List;
7 |
8 | public class ZPattern implements Pattern {
9 |
10 | private final String name;
11 | private final List buttons;
12 | private final int inventorySize;
13 | private final boolean enableMultiPage;
14 |
15 | public ZPattern(String name, List buttons, int inventorySize, boolean enableMultiPage) {
16 | this.name = name;
17 | this.buttons = buttons;
18 | this.inventorySize = inventorySize;
19 | this.enableMultiPage = enableMultiPage;
20 | }
21 |
22 | @Override
23 | public int getInventorySize() {
24 | return inventorySize;
25 | }
26 |
27 | @Override
28 | public String getName() {
29 | return name;
30 | }
31 |
32 | @Override
33 | public List getButtons() {
34 | return buttons;
35 | }
36 |
37 | @Override
38 | public boolean enableMultiPage() {
39 | return this.enableMultiPage;
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/placeholder/AutoPlaceholder.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.placeholder;
2 |
3 | import fr.maxlego08.menu.zcore.utils.interfaces.ReturnBiConsumer;
4 | import org.bukkit.OfflinePlayer;
5 |
6 | import java.util.UUID;
7 |
8 | public class AutoPlaceholder {
9 |
10 | private final String startWith;
11 | private final ReturnBiConsumer biConsumer;
12 |
13 | /**
14 | * @param startWith
15 | * @param biConsumer
16 | */
17 | public AutoPlaceholder(String startWith, ReturnBiConsumer biConsumer) {
18 | super();
19 | this.startWith = startWith;
20 | this.biConsumer = biConsumer;
21 | }
22 |
23 | /**
24 | * @return the startWith
25 | */
26 | public String getStartWith() {
27 | return startWith;
28 | }
29 |
30 | /**
31 | * @return the biConsumer
32 | */
33 | public ReturnBiConsumer getBiConsumer() {
34 | return biConsumer;
35 | }
36 |
37 | public String accept(OfflinePlayer offlinePlayer, String value) {
38 | return this.biConsumer.accept(offlinePlayer, value);
39 | }
40 |
41 | }
42 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/placeholder/DistantPlaceholder.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.placeholder;
2 |
3 | import me.clip.placeholderapi.expansion.PlaceholderExpansion;
4 | import org.bukkit.OfflinePlayer;
5 | import org.bukkit.entity.Player;
6 |
7 | public class DistantPlaceholder extends PlaceholderExpansion {
8 |
9 | private final LocalPlaceholder placeholder;
10 |
11 | /**
12 | * @param placeholder
13 | */
14 | public DistantPlaceholder(LocalPlaceholder placeholder) {
15 | super();
16 | this.placeholder = placeholder;
17 | }
18 |
19 | @Override
20 | public String getAuthor() {
21 | return this.placeholder.getPlugin().getDescription().getAuthors().get(0);
22 | }
23 |
24 | @Override
25 | public String getIdentifier() {
26 | return this.placeholder.getPrefix();
27 | }
28 |
29 | @Override
30 | public String getVersion() {
31 | return this.placeholder.getPlugin().getDescription().getVersion();
32 | }
33 |
34 | @Override
35 | public boolean persist() {
36 | return true;
37 | }
38 |
39 | @Override
40 | public String onRequest(OfflinePlayer offlinePlayer, String params) {
41 | return this.placeholder.onRequest(offlinePlayer, params);
42 | }
43 |
44 | @Override
45 | public String onPlaceholderRequest(Player player, String params) {
46 | return this.placeholder.onRequest(player, params);
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/players/ZData.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.players;
2 |
3 | import fr.maxlego08.menu.api.players.Data;
4 |
5 | public class ZData implements Data {
6 |
7 | private final String key;
8 | private Object value;
9 | private final long expiredAt;
10 |
11 | public ZData(String key, Object value, long expiredAt) {
12 | super();
13 | this.key = key;
14 | this.value = value;
15 | this.expiredAt = expiredAt;
16 | }
17 |
18 | @Override
19 | public String getKey() {
20 | return this.key;
21 | }
22 |
23 | @Override
24 | public Object getValue() {
25 | return this.value;
26 | }
27 |
28 | @Override
29 | public long getExpiredAt() {
30 | return this.expiredAt;
31 | }
32 |
33 | @Override
34 | public boolean isExpired() {
35 | return this.expiredAt != 0 && System.currentTimeMillis() > this.expiredAt;
36 | }
37 |
38 | @Override
39 | public void add(int amount) {
40 | int value = safeStringToInt(this.value.toString());
41 | this.value = value + amount;
42 | }
43 |
44 | @Override
45 | public void remove(int amount) {
46 | int value = safeStringToInt(this.value.toString());
47 | this.value = value - amount;
48 |
49 | }
50 |
51 | private int safeStringToInt(String str) {
52 | if (str.contains(".")) {
53 | double doubleValue = Double.parseDouble(str);
54 | return (int) doubleValue;
55 | } else {
56 | return Integer.parseInt(str);
57 | }
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/ZConditionalName.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.ConditionalName;
5 | import fr.maxlego08.menu.api.requirement.Permissible;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.entity.Player;
9 |
10 | import java.util.List;
11 |
12 | public class ZConditionalName implements ConditionalName {
13 |
14 | private final String name;
15 | private final List permissibles;
16 | private final int priority;
17 |
18 | public ZConditionalName(String name, List permissibles, int priority) {
19 | this.name = name;
20 | this.permissibles = permissibles;
21 | this.priority = priority;
22 | }
23 |
24 | @Override
25 | public String getName() {
26 | return this.name;
27 | }
28 |
29 | @Override
30 | public List getPermissibles() {
31 | return this.permissibles;
32 | }
33 |
34 | @Override
35 | public int getPriority() {
36 | return this.priority;
37 | }
38 |
39 | @Override
40 | public boolean hasPermission(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
41 | return this.permissibles.stream().allMatch(permissible -> permissible.hasPermission(player, button, inventory, placeholders));
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/ZPermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement;
2 |
3 | import fr.maxlego08.menu.api.requirement.Action;
4 | import fr.maxlego08.menu.api.requirement.Permissible;
5 | import fr.maxlego08.menu.zcore.utils.ZUtils;
6 |
7 | import java.util.List;
8 |
9 | public abstract class ZPermissible extends ZUtils implements Permissible {
10 |
11 | private final List denyActions;
12 | private final List successActions;
13 |
14 | public ZPermissible(List denyActions, List successActions) {
15 | this.denyActions = denyActions;
16 | this.successActions = successActions;
17 | }
18 |
19 | @Override
20 | public List getSuccessActions() {
21 | return this.successActions;
22 | }
23 |
24 | @Override
25 | public List getDenyActions() {
26 | return this.denyActions;
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/ActionBarAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.zcore.utils.meta.Meta;
8 | import fr.maxlego08.menu.zcore.utils.players.ActionBar;
9 | import org.bukkit.entity.Player;
10 |
11 | public class ActionBarAction extends Action {
12 |
13 | private final String message;
14 | private final boolean miniMessage;
15 |
16 | public ActionBarAction(String message, boolean miniMessage) {
17 | this.message = message;
18 | this.miniMessage = miniMessage;
19 | }
20 |
21 | @Override
22 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
23 | String finalMessage = papi(placeholders.parse(this.message), player, true);
24 | if (miniMessage) {
25 | Meta.meta.sendAction(player, finalMessage);
26 | } else {
27 | ActionBar.sendActionBar(player, finalMessage);
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/BackAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.Inventory;
4 | import fr.maxlego08.menu.api.InventoryManager;
5 | import fr.maxlego08.menu.api.button.Button;
6 | import fr.maxlego08.menu.api.requirement.Action;
7 | import fr.maxlego08.menu.api.utils.Placeholders;
8 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
9 | import org.bukkit.entity.Player;
10 |
11 | import java.util.List;
12 |
13 | public class BackAction extends Action {
14 |
15 | private final InventoryManager inventoryManager;
16 |
17 | public BackAction(InventoryManager inventoryManager) {
18 | this.inventoryManager = inventoryManager;
19 | }
20 |
21 | @Override
22 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
23 | List oldInventories = inventory.getOldInventories();
24 |
25 | if (!oldInventories.isEmpty()) {
26 | Inventory currentInventory = oldInventories.get(oldInventories.size() - 1);
27 | oldInventories.remove(currentInventory);
28 |
29 | inventory.getButtons().forEach(btn -> btn.onBackClick(player, null, inventory, oldInventories, currentInventory, 0));
30 | this.inventoryManager.openInventory(player, currentInventory, 1, oldInventories);
31 | }
32 | }
33 |
34 | }
35 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/BroadcastSoundAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.sound.SoundOption;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.entity.Player;
10 |
11 | public class BroadcastSoundAction extends Action {
12 |
13 | private final SoundOption soundOption;
14 |
15 | public BroadcastSoundAction(SoundOption soundOption) {
16 | this.soundOption = soundOption;
17 | }
18 |
19 | @Override
20 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
21 | Bukkit.getOnlinePlayers().forEach(this.soundOption::play);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/CloseAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import org.bukkit.entity.Player;
8 |
9 | public class CloseAction extends Action {
10 |
11 | @Override
12 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
13 | player.closeInventory();
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/ConnectAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import com.google.common.io.ByteArrayDataOutput;
4 | import com.google.common.io.ByteStreams;
5 | import fr.maxlego08.menu.api.button.Button;
6 | import fr.maxlego08.menu.api.requirement.Action;
7 | import fr.maxlego08.menu.api.utils.Placeholders;
8 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.plugin.Plugin;
11 |
12 | public class ConnectAction extends Action {
13 |
14 | private final String server;
15 | private final Plugin plugin;
16 |
17 | public ConnectAction(String server, Plugin plugin) {
18 | this.server = server;
19 | this.plugin = plugin;
20 | }
21 |
22 | @Override
23 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
24 | ByteArrayDataOutput out = ByteStreams.newDataOutput();
25 | out.writeUTF("Connect");
26 | out.writeUTF(server);
27 | player.sendPluginMessage(this.plugin, "BungeeCord", out.toByteArray());
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/ConsoleCommandAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.scheduler.ZScheduler;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.entity.Player;
10 |
11 | import java.util.List;
12 | import java.util.stream.Collectors;
13 | import java.util.stream.Stream;
14 |
15 | public class ConsoleCommandAction extends Action {
16 |
17 | private final List commands;
18 |
19 | public ConsoleCommandAction(List commands) {
20 | this.commands = commands;
21 | }
22 |
23 | @Override
24 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
25 | ZScheduler scheduler = inventory.getPlugin().getScheduler();
26 | List parsedCommands = papi(placeholders.parse(parseAndFlattenCommands(commands, player)), player, true);
27 |
28 | Runnable runnable = () -> parsedCommands.forEach(command -> Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command));
29 |
30 | if (scheduler.isFolia()) {
31 | scheduler.runTask(null, runnable);
32 | } else {
33 | runnable.run();
34 | }
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/CurrencyDepositAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.traqueur.currencies.Currencies;
8 | import org.bukkit.entity.Player;
9 |
10 | import java.math.BigDecimal;
11 |
12 | public class CurrencyDepositAction extends Action {
13 |
14 | private final String amount;
15 | private final Currencies currencies;
16 | private final String economyName;
17 |
18 | public CurrencyDepositAction(String amount, Currencies currencies, String economyName) {
19 | this.amount = amount;
20 | this.currencies = currencies;
21 | this.economyName = economyName;
22 | }
23 |
24 | @Override
25 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
26 | this.currencies.deposit(player, new BigDecimal(papi(placeholders.parse(this.amount), player, false)), this.economyName == null ? "default" : this.economyName);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/CurrencyWithdrawAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.traqueur.currencies.Currencies;
8 | import org.bukkit.entity.Player;
9 |
10 | import java.math.BigDecimal;
11 |
12 | public class CurrencyWithdrawAction extends Action {
13 |
14 | private final String amount;
15 | private final Currencies currencies;
16 | private final String economyName;
17 |
18 | public CurrencyWithdrawAction(String amount, Currencies currencies, String economyName) {
19 | this.amount = amount;
20 | this.currencies = currencies;
21 | this.economyName = economyName;
22 | }
23 |
24 | @Override
25 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
26 | this.currencies.withdraw(player, new BigDecimal(papi(placeholders.parse(this.amount), player, false)), this.economyName == null ? "default" : this.economyName);
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/DataAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.requirement.data.ActionPlayerData;
7 | import fr.maxlego08.menu.api.utils.Placeholders;
8 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
9 | import org.bukkit.entity.Player;
10 |
11 | public class DataAction extends Action {
12 |
13 | private final ActionPlayerData playerData;
14 | private final MenuPlugin plugin;
15 |
16 | public DataAction(ActionPlayerData playerData, MenuPlugin plugin) {
17 | this.playerData = playerData;
18 | this.plugin = plugin;
19 | }
20 |
21 | @Override
22 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
23 | this.playerData.execute(player, this.plugin.getDataManager());
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/DiscordAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.scheduler.ZScheduler;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import fr.maxlego08.menu.save.Config;
9 | import fr.maxlego08.menu.zcore.utils.discord.DiscordConfiguration;
10 | import fr.maxlego08.menu.zcore.utils.discord.DiscordWebhook;
11 | import org.bukkit.entity.Player;
12 |
13 | public class DiscordAction extends Action {
14 |
15 | private final DiscordConfiguration configuration;
16 |
17 | public DiscordAction(DiscordConfiguration configuration) {
18 | this.configuration = configuration;
19 | }
20 |
21 | @Override
22 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
23 |
24 | ZScheduler scheduler = inventory.getPlugin().getScheduler();
25 | DiscordWebhook discordWebhook = new DiscordWebhook(configuration.getWebhookUrl());
26 | configuration.apply(text -> text == null ? null : player == null ? text : papi(placeholders.parse(text), player, false), discordWebhook);
27 |
28 | scheduler.runTaskAsynchronously(() -> {
29 | try {
30 | discordWebhook.execute();
31 | } catch (Exception exception) {
32 | if (Config.enableDebug) {
33 | exception.printStackTrace();
34 | }
35 | }
36 | });
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/MessageAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.zcore.utils.meta.Meta;
8 | import org.bukkit.entity.Player;
9 |
10 | import java.util.List;
11 |
12 | public class MessageAction extends Action {
13 |
14 | private final List messages;
15 | private final boolean miniMessage;
16 |
17 | public MessageAction(List messages, boolean miniMessage) {
18 | this.messages = messages;
19 | this.miniMessage = miniMessage;
20 | }
21 |
22 | @Override
23 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
24 | papi(placeholders.parse(this.parseAndFlattenCommands(this.messages, player)), player, true).forEach(message -> {
25 | if (miniMessage) {
26 | Meta.meta.sendMessage(player, message);
27 | } else {
28 | player.sendMessage(message);
29 | }
30 | });
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/OpenBookAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.zcore.utils.meta.Meta;
8 | import org.bukkit.entity.Player;
9 |
10 | import java.util.List;
11 |
12 | public class OpenBookAction extends Action {
13 |
14 | private final String title;
15 | private final String author;
16 | private final List lines;
17 |
18 | public OpenBookAction(String title, String author, List lines) {
19 | this.title = title;
20 | this.author = author;
21 | this.lines = lines;
22 | }
23 |
24 | @Override
25 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
26 | Meta.meta.openBook(player, papi(title, player, true), papi(author, player, true), papi(lines, player, true));
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/PlayerChatAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import org.bukkit.entity.Player;
8 |
9 | import java.util.List;
10 |
11 | public class PlayerChatAction extends Action {
12 |
13 | private final List commands;
14 |
15 | public PlayerChatAction(List commands) {
16 | this.commands = commands;
17 | }
18 |
19 | @Override
20 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
21 | papi(placeholders.parse(this.parseAndFlattenCommands(this.commands, player)), player, true).forEach(command -> player.chat(command.replace("%player%", player.getName())));
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/PlayerCommandAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.scheduler.ZScheduler;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.Bukkit;
9 | import org.bukkit.entity.Player;
10 |
11 | import java.util.List;
12 |
13 | public class PlayerCommandAction extends Action {
14 |
15 | private final List commands;
16 | private final boolean inChat;
17 |
18 | public PlayerCommandAction(List commands, boolean inChat) {
19 | this.commands = commands;
20 | this.inChat = inChat;
21 | }
22 |
23 | @Override
24 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
25 | ZScheduler scheduler = inventory.getPlugin().getScheduler();
26 | scheduler.runTask(player.getLocation(), () -> papi(placeholders.parse(this.parseAndFlattenCommands(this.commands, player)), player, true).forEach(command -> {
27 | command = command.replace("%player%", player.getName());
28 | if (this.inChat) {
29 | player.chat("/" + command);
30 | } else {
31 | Bukkit.dispatchCommand(player, command);
32 | }
33 | }));
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/RefreshAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import org.bukkit.entity.Player;
8 |
9 | public class RefreshAction extends Action {
10 |
11 | @Override
12 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
13 | if (button != null) {
14 | inventory.buildButton(button.getMasterParentButton());
15 | inventory.cancel(button.getSlot());
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/ShopkeeperAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import com.nisovin.shopkeepers.api.ShopkeepersAPI;
4 | import com.nisovin.shopkeepers.api.shopkeeper.Shopkeeper;
5 | import fr.maxlego08.menu.api.button.Button;
6 | import fr.maxlego08.menu.api.requirement.Action;
7 | import fr.maxlego08.menu.api.utils.Placeholders;
8 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
9 | import fr.maxlego08.menu.zcore.logger.Logger;
10 | import org.bukkit.entity.Player;
11 |
12 | import java.util.Optional;
13 |
14 | public class ShopkeeperAction extends Action {
15 |
16 | private final String shopName;
17 |
18 | public ShopkeeperAction(String shopName) {
19 | this.shopName = shopName;
20 | }
21 |
22 | @Override
23 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
24 | Optional extends Shopkeeper> optional = ShopkeepersAPI.getShopkeeperRegistry().getShopkeepersByName(this.papi(placeholders.parse(this.shopName), player, false)).findFirst();
25 | if (optional.isPresent()) {
26 | optional.get().openTradingWindow(player);
27 | } else {
28 | Logger.info("ShopKeeper " + shopName + " was not found !", Logger.LogType.ERROR);
29 | player.sendMessage("§cShopKeeper " + shopName + " was not found !");
30 | }
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/SoundAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.sound.SoundOption;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.entity.Player;
9 |
10 | public class SoundAction extends Action {
11 |
12 | private final SoundOption soundOption;
13 |
14 | public SoundAction(SoundOption soundOption) {
15 | this.soundOption = soundOption;
16 | }
17 |
18 | @Override
19 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
20 | this.soundOption.play(player);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/TeleportAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.button.Button;
5 | import fr.maxlego08.menu.api.requirement.Action;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import org.bukkit.Location;
9 | import org.bukkit.entity.Player;
10 |
11 | public class TeleportAction extends Action {
12 |
13 | private final MenuPlugin plugin;
14 | private final Location location;
15 |
16 | public TeleportAction(MenuPlugin plugin, Location location) {
17 | this.plugin = plugin;
18 | this.location = location;
19 | }
20 |
21 | @Override
22 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
23 | this.plugin.getScheduler().runTask(player.getLocation(), () -> player.teleport(location));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/actions/TitleAction.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.actions;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.utils.Placeholders;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.zcore.utils.meta.Meta;
8 | import org.bukkit.entity.Player;
9 |
10 | public class TitleAction extends Action {
11 |
12 | private final String title;
13 | private final String subtitle;
14 | private final long start;
15 | private final long duration;
16 | private final long end;
17 |
18 | public TitleAction(String title, String subtitle, long start, long duration, long end) {
19 | this.title = title;
20 | this.subtitle = subtitle;
21 | this.start = start;
22 | this.duration = duration;
23 | this.end = end;
24 | }
25 |
26 | @Override
27 | protected void execute(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
28 | Meta.meta.sendTitle(player, this.papi(placeholders.parse(title), player, true), this.papi(placeholders.parse(subtitle), player, true), start, duration, end);
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/requirement/permissible/ZPlayerNamePermissible.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.requirement.permissible;
2 |
3 | import fr.maxlego08.menu.api.button.Button;
4 | import fr.maxlego08.menu.api.requirement.Action;
5 | import fr.maxlego08.menu.api.requirement.permissible.PlayerNamePermissible;
6 | import fr.maxlego08.menu.api.utils.Placeholders;
7 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
8 | import fr.maxlego08.menu.requirement.ZPermissible;
9 | import org.bukkit.entity.Player;
10 |
11 | import java.util.List;
12 |
13 | public class ZPlayerNamePermissible extends ZPermissible implements PlayerNamePermissible {
14 |
15 | private final String playerName;
16 |
17 | public ZPlayerNamePermissible(String playerName, List denyActions, List successActions) {
18 | super(denyActions, successActions);
19 | this.playerName = playerName;
20 | }
21 |
22 | @Override
23 | public boolean hasPermission(Player player, Button button, InventoryDefault inventory, Placeholders placeholders) {
24 | String name = this.papi(this.playerName.replace("%player%", player.getName()), player, false);
25 | return isMinecraftName(name);
26 | }
27 |
28 | @Override
29 | public boolean isValid() {
30 | return this.playerName != null;
31 | }
32 |
33 | @Override
34 | public String getPlayerName() {
35 | return this.playerName;
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/website/Token.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.website;
2 |
3 | import fr.maxlego08.menu.zcore.utils.storage.Persist;
4 | import fr.maxlego08.menu.zcore.utils.storage.Savable;
5 |
6 | public class Token implements Savable {
7 |
8 | public static String token;
9 |
10 | /**
11 | * static Singleton instance.
12 | */
13 | private static volatile Token instance;
14 |
15 | /**
16 | * Private constructor for singleton.
17 | */
18 | private Token() {
19 | }
20 |
21 | /**
22 | * Return a singleton instance of Token.
23 | */
24 | public static Token getInstance() {
25 | // Double lock for thread safety.
26 | if (instance == null) {
27 | synchronized (Token.class) {
28 | if (instance == null) {
29 | instance = new Token();
30 | }
31 | }
32 | }
33 | return instance;
34 | }
35 |
36 | @Override
37 | public void save(Persist persist) {
38 | persist.save(this, "token");
39 | }
40 |
41 | @Override
42 | public void load(Persist persist) {
43 | persist.loadOrSaveDefault(this, Token.class, "token");
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/website/buttons/ButtonBuilderRefresh.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.website.buttons;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.utils.Placeholders;
5 | import fr.maxlego08.menu.button.ZButton;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.website.ZWebsiteManager;
8 | import fr.maxlego08.menu.zcore.utils.builder.ItemBuilder;
9 | import org.bukkit.Material;
10 | import org.bukkit.entity.Player;
11 | import org.bukkit.event.inventory.InventoryClickEvent;
12 | import org.bukkit.plugin.Plugin;
13 |
14 | public class ButtonBuilderRefresh extends ZButton {
15 |
16 | private final MenuPlugin plugin;
17 | private boolean canUse = true;
18 |
19 | public ButtonBuilderRefresh(Plugin plugin) {
20 | this.plugin = (MenuPlugin) plugin;
21 | }
22 |
23 | @Override
24 | public boolean isPermanent() {
25 | return true;
26 | }
27 |
28 | @Override
29 | public void onClick(Player player, InventoryClickEvent event, InventoryDefault inventory, int slot, Placeholders placeholders) {
30 |
31 | if (!this.canUse) return;
32 | this.canUse = false;
33 |
34 | ItemBuilder itemBuilder = new ItemBuilder(Material.BARRIER, "§cPlease wait");
35 | inventory.getSpigotInventory().setItem(slot, itemBuilder.build());
36 |
37 | ZWebsiteManager manager = this.plugin.getWebsiteManager();
38 | manager.refreshInventories(player);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/website/buttons/ButtonFolderBack.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.website.buttons;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.utils.Placeholders;
5 | import fr.maxlego08.menu.button.ZButton;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.website.Folder;
8 | import fr.maxlego08.menu.website.ZWebsiteManager;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.event.inventory.InventoryClickEvent;
11 | import org.bukkit.plugin.Plugin;
12 |
13 | import java.util.Optional;
14 |
15 | public class ButtonFolderBack extends ZButton {
16 |
17 | private final MenuPlugin plugin;
18 |
19 | public ButtonFolderBack(Plugin plugin) {
20 | this.plugin = (MenuPlugin) plugin;
21 | }
22 |
23 | @Override
24 | public boolean isPermanent() {
25 | return true;
26 | }
27 |
28 | @Override
29 | public void onClick(Player player, InventoryClickEvent event, InventoryDefault inventory, int slot, Placeholders placeholders) {
30 |
31 | ZWebsiteManager manager = this.plugin.getWebsiteManager();
32 | Optional optional = manager.getCurrentFolder();
33 | if (!optional.isPresent()) return;
34 |
35 | Folder folder = optional.get();
36 |
37 | if (folder.getParentId() != -1) {
38 | manager.openInventoriesInventory(player, manager.getInventoryPage(), 1, folder.getParentId());
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/website/buttons/ButtonFolderPrevious.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.website.buttons;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.api.utils.Placeholders;
5 | import fr.maxlego08.menu.button.ZButton;
6 | import fr.maxlego08.menu.inventory.inventories.InventoryDefault;
7 | import fr.maxlego08.menu.website.Folder;
8 | import fr.maxlego08.menu.website.ZWebsiteManager;
9 | import org.bukkit.entity.Player;
10 | import org.bukkit.event.inventory.InventoryClickEvent;
11 | import org.bukkit.plugin.Plugin;
12 |
13 | import java.util.List;
14 | import java.util.Optional;
15 |
16 | public class ButtonFolderPrevious extends ZButton {
17 |
18 | private final MenuPlugin plugin;
19 |
20 | public ButtonFolderPrevious(Plugin plugin) {
21 | this.plugin = (MenuPlugin) plugin;
22 | }
23 |
24 | @Override
25 | public boolean isPermanent() {
26 | return true;
27 | }
28 |
29 | @Override
30 | public void onClick(Player player, InventoryClickEvent event, InventoryDefault inventory, int slot, Placeholders placeholders) {
31 |
32 | ZWebsiteManager manager = this.plugin.getWebsiteManager();
33 | Optional optional = manager.getCurrentFolder();
34 | if (!optional.isPresent()) return;
35 |
36 | Folder folder = optional.get();
37 | List folders = manager.getFolders(folder);
38 |
39 | int folderPage = manager.getFolderPage();
40 |
41 | if (folderPage > 1) {
42 | manager.openInventoriesInventory(player, manager.getInventoryPage(), folderPage - 1, folder.getId());
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/website/inventories/InventoryMarketplace.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.website.inventories;
2 |
3 | import fr.maxlego08.menu.MenuPlugin;
4 | import fr.maxlego08.menu.ZInventory;
5 | import fr.maxlego08.menu.api.button.Button;
6 | import fr.maxlego08.menu.api.pattern.Pattern;
7 | import fr.maxlego08.menu.website.Resource;
8 | import org.bukkit.entity.Player;
9 | import org.bukkit.plugin.Plugin;
10 |
11 | import java.util.Collection;
12 | import java.util.List;
13 |
14 | public class InventoryMarketplace extends ZInventory {
15 |
16 | private final MenuPlugin plugin;
17 |
18 | /**
19 | * @param plugin The plugin where the inventory comes from
20 | * @param name Inventory name
21 | * @param fileName Inventory file name
22 | * @param size Inventory size
23 | * @param buttons List of {@link Button}
24 | */
25 | public InventoryMarketplace(Plugin plugin, String name, String fileName, int size, List buttons) {
26 | super(plugin, name, fileName, size, buttons);
27 | this.plugin = (MenuPlugin) plugin;
28 | }
29 |
30 | @Override
31 | public int getMaxPage(Collection patterns, Player player, Object... objects) {
32 | List resources = this.plugin.getWebsiteManager().getResources();
33 | return getMaxPage(resources, 45);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/website/request/Response.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.website.request;
2 |
3 | import java.util.Map;
4 |
5 | public class Response {
6 |
7 | private final int httpCode;
8 | private final Map datas;
9 |
10 | /**
11 | * @param httpCode
12 | * @param datas
13 | */
14 | public Response(int httpCode, Map datas) {
15 | super();
16 | this.httpCode = httpCode;
17 | this.datas = datas;
18 | }
19 |
20 | /**
21 | * @return the httpCode
22 | */
23 | public int getHttpCode() {
24 | return this.httpCode;
25 | }
26 |
27 | /**
28 | * @return the datas
29 | */
30 | public Map getDatas() {
31 | return this.datas;
32 | }
33 |
34 | public int getCode() {
35 | return this.httpCode;
36 | }
37 |
38 | public Object get(String key) {
39 | return this.datas.get(key);
40 | }
41 |
42 | public T getOrDefault(String key, T defaultValue) {
43 | return (T) this.datas.getOrDefault(key, defaultValue);
44 | }
45 |
46 | /*
47 | * (non-Javadoc)
48 | *
49 | * @see java.lang.Object#toString()
50 | */
51 | @Override
52 | public String toString() {
53 | return "Response [httpCode=" + httpCode + ", datas=" + datas + "]";
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/enums/EnumInventory.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.enums;
2 |
3 | public enum EnumInventory {
4 |
5 | INVENTORY_DEFAULT(1),
6 | INVENTORY_MARKETPLACE(2),
7 |
8 | ;
9 |
10 | private final int id;
11 |
12 | EnumInventory(int id) {
13 | this.id = id;
14 | }
15 |
16 | public int getId() {
17 | return id;
18 | }
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/enums/Folder.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.enums;
2 |
3 | public enum Folder {
4 |
5 | UTILS,
6 |
7 | ;
8 |
9 |
10 | public String toFolder(){
11 | return name().toLowerCase();
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/enums/Permission.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.enums;
2 |
3 | public enum Permission {
4 |
5 | ZMENU_RELOAD,
6 | ZMENU_OPEN,
7 | ZMENU_SAVE,
8 | ZMENU_USE,
9 | ZMENU_PLAYERS,
10 | ZMENU_CONVERT,
11 | ZMENU_LIST,
12 | ZMENU_TEST_DUPE,
13 | ZMENU_OPEN_ITEM,
14 | ZMENU_CREATE,
15 | ZMENU_DOWNLOAD,
16 | ZMENU_LOGIN,
17 | ZMENU_MARKETPLACE,
18 | ZMENU_INVENTORIES,
19 | ZMENU_DESCRIPTION,
20 |
21 | ZMENU_DOCUMENTATION;
22 |
23 | private String permission;
24 |
25 | Permission() {
26 | this.permission = this.name().toLowerCase().replace("_", ".");
27 | }
28 |
29 | public String getPermission() {
30 | return permission;
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/Banner.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils;
2 |
3 | import org.bukkit.DyeColor;
4 | import org.bukkit.Material;
5 | import org.bukkit.block.banner.Pattern;
6 | import org.bukkit.inventory.ItemStack;
7 | import org.bukkit.inventory.meta.BannerMeta;
8 |
9 | import java.util.List;
10 |
11 | public class Banner {
12 | private DyeColor baseColor;
13 |
14 | private List patterns;
15 |
16 | public Banner(DyeColor baseColor) {
17 | this.baseColor = baseColor;
18 | }
19 |
20 | public Banner(DyeColor baseColor, List patterns) {
21 | this.baseColor = baseColor;
22 | this.patterns = patterns;
23 | }
24 |
25 | public DyeColor getBaseColor() {
26 | return baseColor;
27 | }
28 |
29 | public List getPatterns() {
30 | return patterns;
31 | }
32 |
33 | public void setBaseColor(DyeColor baseColor) {
34 | this.baseColor = baseColor;
35 | }
36 |
37 | public void setPatterns(List patterns) {
38 | this.patterns = patterns;
39 | }
40 |
41 | public ItemStack toItemStack(int amount){
42 | Material material = Material.getMaterial(baseColor.toString()+"_BANNER");
43 | assert material != null;
44 | ItemStack itemStack = new ItemStack(material, amount);
45 | BannerMeta bannerMeta = (BannerMeta) itemStack.getItemMeta();
46 | bannerMeta.setPatterns(patterns);
47 | itemStack.setItemMeta(bannerMeta);
48 | return itemStack;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/ElapsedTime.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils;
2 |
3 | import fr.maxlego08.menu.save.Config;
4 |
5 | public class ElapsedTime extends ZUtils {
6 |
7 | private final String name;
8 | private long start;
9 | private long end;
10 |
11 | /**
12 | * @param name
13 | */
14 | public ElapsedTime(String name) {
15 | super();
16 | this.name = name;
17 | }
18 |
19 | /**
20 | * Start
21 | */
22 | public void start() {
23 | this.start = System.nanoTime();
24 | }
25 |
26 | /**
27 | * Stop
28 | */
29 | public void end() {
30 | this.end = System.nanoTime();
31 | }
32 |
33 | /**
34 | * @return the start
35 | */
36 | public long getStart() {
37 | return start;
38 | }
39 |
40 | /**
41 | * @return the end
42 | */
43 | public long getEnd() {
44 | return end;
45 | }
46 |
47 | public long getElapsedTime() {
48 | return this.end - this.start;
49 | }
50 |
51 | public void endDisplay() {
52 | endDisplay(false);
53 | }
54 |
55 | public void endDisplay(boolean b) {
56 | this.end();
57 | if (Config.enableDebugTime || b) {
58 | System.out.println("[ElapsedTime] " + name + " -> " + super.format(this.getElapsedTime(), ' '));
59 | }
60 | }
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/InventoryArgument.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils;
2 |
3 | import fr.maxlego08.menu.api.command.CommandManager;
4 | import org.bukkit.entity.Player;
5 |
6 | import java.util.List;
7 |
8 | public class InventoryArgument extends ZUtils {
9 |
10 | private final CommandManager commandManager;
11 | private final List arguments;
12 |
13 | public InventoryArgument(CommandManager commandManager, List arguments) {
14 | this.commandManager = commandManager;
15 | this.arguments = arguments;
16 | }
17 |
18 | public void process(Player player) {
19 | if (!this.arguments.isEmpty()) {
20 | for (int i = 0; i < this.arguments.size(); i++) {
21 | String name = String.valueOf(i - 4);
22 | String argument = this.arguments.get(i);
23 |
24 | if (argument.contains(":")) {
25 | String[] values = argument.split(":", 2);
26 | name = values[0];
27 | argument = values[1];
28 | }
29 |
30 | this.commandManager.setPlayerArgument(player, name, argument);
31 | }
32 | }
33 | }
34 |
35 | public List getArguments() {
36 | return arguments;
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/ProgressBar.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils;
2 |
3 | public class ProgressBar {
4 |
5 | private final int lenght;
6 | private final char symbol;
7 | private final String completedColor;
8 | private final String notCompletedColor;
9 |
10 | /**
11 | * @param lenght
12 | * @param symbol
13 | * @param completedColor
14 | * @param notCompletedColor
15 | */
16 | public ProgressBar(int lenght, char symbol, String completedColor, String notCompletedColor) {
17 | super();
18 | this.lenght = lenght;
19 | this.symbol = symbol;
20 | this.completedColor = completedColor;
21 | this.notCompletedColor = notCompletedColor;
22 | }
23 |
24 | /**
25 | * @return the lenght
26 | */
27 | public int getLenght() {
28 | return lenght;
29 | }
30 |
31 | /**
32 | * @return the symbol
33 | */
34 | public char getSymbol() {
35 | return symbol;
36 | }
37 |
38 | /**
39 | * @return the completedColor
40 | */
41 | public String getCompletedColor() {
42 | return completedColor;
43 | }
44 |
45 | /**
46 | * @return the notCompletedColor
47 | */
48 | public String getNotCompletedColor() {
49 | return notCompletedColor;
50 | }
51 |
52 | }
53 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/SimpleCache.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils;
2 |
3 | import java.util.concurrent.ConcurrentHashMap;
4 |
5 | public class SimpleCache {
6 | private final ConcurrentHashMap cache;
7 |
8 | public SimpleCache() {
9 | this.cache = new ConcurrentHashMap<>();
10 | }
11 |
12 | public V get(K key, Loader loader) {
13 | return cache.computeIfAbsent(key, k -> loader.load());
14 | }
15 |
16 | public interface Loader {
17 | V load();
18 | }
19 | }
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/TranslationHelper.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils;
2 |
3 | import fr.maxlego08.menu.zcore.utils.plugins.Plugins;
4 | import fr.maxlego08.ztranslator.api.Translator;
5 | import org.bukkit.Bukkit;
6 | import org.bukkit.inventory.ItemStack;
7 | import org.bukkit.plugin.RegisteredServiceProvider;
8 |
9 | public abstract class TranslationHelper {
10 |
11 | /**
12 | * Allows to translate the item name, if the zTranslator plugin is active, then the translated name will be retrieved
13 | *
14 | * @param itemStack
15 | * @return item name
16 | */
17 | protected String getItemName(ItemStack itemStack) {
18 |
19 | if (itemStack == null) {
20 | return "";
21 |
22 | }
23 | if (itemStack.hasItemMeta() && itemStack.getItemMeta().hasDisplayName()) {
24 | return itemStack.getItemMeta().getDisplayName();
25 | }
26 |
27 | if (Bukkit.getPluginManager().isPluginEnabled(Plugins.ZTRANSLATOR.getName())) {
28 |
29 | RegisteredServiceProvider provider = Bukkit.getServer().getServicesManager()
30 | .getRegistration(Translator.class);
31 | Translator translator = provider.getProvider();
32 | return translator.translate(itemStack);
33 | }
34 |
35 | String name = itemStack.serialize().get("type").toString().replace("_", " ").toLowerCase();
36 | return name.substring(0, 1).toUpperCase() + name.substring(1);
37 | }
38 |
39 | }
40 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/attribute/AttributeApplier.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.attribute;
2 |
3 | import de.tr7zw.changeme.nbtapi.NBT;
4 | import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBT;
5 | import de.tr7zw.changeme.nbtapi.iface.ReadWriteNBTCompoundList;
6 | import fr.maxlego08.menu.api.attribute.IAttribute;
7 | import org.bukkit.inventory.ItemStack;
8 |
9 | import java.util.List;
10 |
11 | public class AttributeApplier {
12 |
13 | private final List attributes;
14 |
15 | public AttributeApplier(List attributes) {
16 | this.attributes = attributes;
17 | }
18 |
19 | public void apply(ItemStack itemStack) {
20 | if (this.attributes.isEmpty()) return;
21 | NBT.modify(itemStack, nbt -> {
22 | ReadWriteNBTCompoundList attributeModifiers = nbt.getCompoundList("AttributeModifiers");
23 | for (IAttribute attribute : this.attributes) {
24 | ReadWriteNBT compound = attributeModifiers.addCompound();
25 | compound.setString("Name", attribute.getName());
26 | compound.setUUID("UUID", attribute.getUuid());
27 | compound.setString("AttributeName", "minecraft:" + attribute.getType().getKey());
28 | compound.setDouble("Amount", attribute.getAmount());
29 | if (attribute.getSlot() != null) {
30 | compound.setString("Slot", attribute.getSlot().name().toLowerCase());
31 | }
32 | }
33 | });
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/commands/CollectionBiConsumer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.commands;
2 |
3 | import org.bukkit.command.CommandSender;
4 |
5 | import java.util.List;
6 |
7 | /**
8 | * A functional interface that represents a {@link List} of {@link String} consumers.
9 | * It takes two parameters: a {@link CommandSender} and an array of {@link String}.
10 | * It is used to process the arguments of a command.
11 | */
12 | @FunctionalInterface
13 | public interface CollectionBiConsumer {
14 |
15 |
16 | /**
17 | * Process the arguments of a command.
18 | *
19 | * @param sender the {@link CommandSender} that sent the command
20 | * @param args the arguments of the command
21 | * @return a {@link List} of {@link String} that contains the result of the processing
22 | */
23 | List accept(CommandSender sender, String[] args);
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/commands/CommandType.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.commands;
2 |
3 | public enum CommandType {
4 |
5 | SUCCESS,
6 | SYNTAX_ERROR,
7 | EXCEPTION_ERROR,
8 | DEFAULT,
9 | CONTINUE,
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/commands/Tab.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.commands;
2 |
3 | public enum Tab {
4 |
5 | START,
6 | CONTAINS,
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/discord/DiscordConfigurationComponent.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.discord;
2 |
3 | import java.util.List;
4 |
5 | public class DiscordConfigurationComponent {
6 | private final String webhookUrl;
7 | private final String avatarUrl;
8 | private final String username;
9 | private final List> json;
10 |
11 | public DiscordConfigurationComponent(String webhookUrl, String avatarUrl, String username, List> json) {
12 | this.webhookUrl = webhookUrl;
13 | this.avatarUrl = avatarUrl;
14 | this.username = username;
15 | this.json = json;
16 | }
17 |
18 | public void apply(ReturnConsumer consumer, DiscordWebhookComponent discordWebhook) {
19 |
20 | if (this.username != null) {
21 | discordWebhook.setUsername(consumer.accept(this.username));
22 | }
23 |
24 | if (this.avatarUrl != null) {
25 | discordWebhook.setAvatarUrl(consumer.accept(this.avatarUrl));
26 | }
27 |
28 | if (this.json != null) {
29 | discordWebhook.setJson(this.json);
30 | }
31 | }
32 |
33 | public String getWebhookUrl() {
34 | return webhookUrl;
35 | }
36 |
37 | public String getAvatarUrl() {
38 | return avatarUrl;
39 | }
40 |
41 | public String getUsername() {
42 | return username;
43 | }
44 |
45 | public List> getJson() {
46 | return json;
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/discord/ReturnConsumer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.discord;
2 |
3 | @FunctionalInterface
4 | public interface ReturnConsumer {
5 |
6 | G accept(T t);
7 |
8 | }
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/interfaces/CollectionConsumer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.interfaces;
2 |
3 | import java.util.Collection;
4 |
5 | @FunctionalInterface
6 | public interface CollectionConsumer {
7 |
8 | Collection accept(T t);
9 |
10 | }
11 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/interfaces/ReturnBiConsumer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.interfaces;
2 |
3 | @FunctionalInterface
4 | public interface ReturnBiConsumer {
5 |
6 | C accept(T t, G g);
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/interfaces/ReturnConsumer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.interfaces;
2 |
3 | @FunctionalInterface
4 | public interface ReturnConsumer {
5 | G accept(T var1);
6 | }
7 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/interfaces/StringConsumer.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.interfaces;
2 |
3 | @FunctionalInterface
4 | public interface StringConsumer {
5 |
6 | String accept(T t);
7 |
8 | }
9 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/inventory/InventoryResult.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.inventory;
2 |
3 | public enum InventoryResult {
4 |
5 | SUCCESS,
6 | SUCCESS_ASYNC,
7 | ERROR,
8 | CLOSE,
9 | PERMISSION,
10 |
11 | }
12 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/loader/Loader.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.loader;
2 |
3 | import fr.maxlego08.menu.exceptions.InventoryException;
4 | import org.bukkit.configuration.file.YamlConfiguration;
5 |
6 | import java.io.File;
7 |
8 | public interface Loader {
9 |
10 | /**
11 | * Loads an object from a YAML configuration.
12 | *
13 | * @param configuration The YAML configuration to load the object from.
14 | * @param path The path within the configuration to locate the object.
15 | * @param objects Additional parameters that might be needed for loading.
16 | * @return The loaded object.
17 | * @throws InventoryException If there is an error while loading the object.
18 | */
19 | T load(YamlConfiguration configuration, String path, Object... objects) throws InventoryException;
20 |
21 | /**
22 | * Saves an object to a YAML configuration.
23 | *
24 | * @param object The object to be saved.
25 | * @param configuration The YAML configuration to save the object to.
26 | * @param path The path within the configuration where the object should be saved.
27 | * @param file The file where the configuration is stored.
28 | * @param objects Additional parameters that might be needed for saving.
29 | */
30 | void save(T object, YamlConfiguration configuration, String path, File file, Object... objects);
31 |
32 | }
33 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/map/OptionalHashMap.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.map;
2 |
3 | import java.util.HashMap;
4 | import java.util.Optional;
5 |
6 | public class OptionalHashMap extends HashMap implements OptionalMap {
7 |
8 | /**
9 | *
10 | */
11 | private static final long serialVersionUID = -1389669310403530512L;
12 |
13 | /**
14 | * @param key
15 | * @return {@link Optional}
16 | */
17 | public Optional getOptional(K key) {
18 | V value = super.getOrDefault(key, null);
19 | return value == null ? Optional.empty() : Optional.of(value);
20 | }
21 |
22 | /**
23 | * @param key
24 | * @return true if is present
25 | */
26 | public boolean isPresent(K key) {
27 | return getOptional(key).isPresent();
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/map/OptionalMap.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.map;
2 |
3 | import java.util.Map;
4 | import java.util.Optional;
5 |
6 | public interface OptionalMap extends Map {
7 |
8 | /**
9 | * @param key
10 | * @return
11 | */
12 | Optional getOptional(K key);
13 |
14 | /**
15 | * @param key
16 | * @return
17 | */
18 | boolean isPresent(K key);
19 |
20 | }
21 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/meta/Meta.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.meta;
2 |
3 | import fr.maxlego08.menu.api.utils.MetaUpdater;
4 | import fr.maxlego08.menu.save.Config;
5 | import fr.maxlego08.menu.zcore.logger.Logger;
6 | import fr.maxlego08.menu.zcore.utils.nms.NMSUtils;
7 |
8 | public class Meta {
9 |
10 | public static MetaUpdater meta;
11 |
12 | static {
13 |
14 | if (!Config.enableMiniMessageFormat || !NMSUtils.isComponentColor()) {
15 | meta = new ClassicMeta();
16 | } else {
17 | try {
18 | Class.forName("net.kyori.adventure.text.minimessage.MiniMessage");
19 | meta = new ComponentMeta();
20 | Logger.info("Use ComponentMeta");
21 | } catch (Exception ignored) {
22 | meta = new ClassicMeta();
23 | Logger.info("Use ClassicMeta");
24 | }
25 | }
26 |
27 | }
28 |
29 | }
30 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/plugins/Plugins.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.plugins;
2 |
3 | public enum Plugins {
4 |
5 | VAULT("Vault"),
6 | ESSENTIALS("Essentials"),
7 | HEADDATABASE("HeadDatabase"),
8 | ZHEAD("zHead"),
9 | PLACEHOLDER("PlaceholderAPI"),
10 | CITIZENS("Citizens"),
11 | TRANSLATIONAPI("TranslationAPI"),
12 | ZTRANSLATOR("zTranslator"),
13 | ORAXEN("Oraxen"),
14 | ITEMSADDER("ItemsAdder"),
15 | SLIMEFUN("Slimefun"),
16 | NOVA("Nova"),
17 | ECO("eco"),
18 | ZITEMS("zItems"),
19 | HMCCOSMETICS("HMCCosmetics"),
20 | JOBS("Jobs"),
21 | LUCKPERMS("LuckPerms"),
22 | NEXO("Nexo"),
23 | MAGICCOSMETICS("MagicCosmetics");
24 |
25 | private final String name;
26 |
27 | Plugins(String name) {
28 | this.name = name;
29 | }
30 |
31 | /**
32 | * @return the name
33 | */
34 | public String getName() {
35 | return name;
36 | }
37 |
38 | }
39 |
--------------------------------------------------------------------------------
/src/fr/maxlego08/menu/zcore/utils/storage/Savable.java:
--------------------------------------------------------------------------------
1 | package fr.maxlego08.menu.zcore.utils.storage;
2 |
3 | /**
4 | * The Savable interface represents objects that can be saved and loaded using a provided Persist object.
5 | * Implement this interface in classes that need to be serialized and deserialized.
6 | */
7 | public interface Savable {
8 |
9 | /**
10 | * Saves the state of the object using the provided Persist object.
11 | *
12 | * @param persist The Persist object used to save the state.
13 | */
14 | void save(Persist persist);
15 |
16 | /**
17 | * Loads the state of the object from the provided Persist object.
18 | *
19 | * @param persist The Persist object used to load the state.
20 | */
21 | void load(Persist persist);
22 | }
23 |
--------------------------------------------------------------------------------
/src/main/resources/default_values.yml:
--------------------------------------------------------------------------------
1 | # This file creates default values for placeholders for PlayerData
2 | values:
3 | # %zmenu_player_value_playtime_level% will return 0 even if the player_level key does not exist for the player.
4 | playtime_level: 0
--------------------------------------------------------------------------------
/src/main/resources/global-placeholders.yml:
--------------------------------------------------------------------------------
1 | example-a: "Hey im an example !"
2 |
3 | example-b:
4 | - "Dont forgot"
5 | - "To purchase zEssentials"
--------------------------------------------------------------------------------
/src/main/resources/plugin.yml:
--------------------------------------------------------------------------------
1 | name: zMenu
2 | authors: [ Maxlego08 ]
3 | main: fr.maxlego08.menu.MenuPlugin
4 | description: Inventory management plugin
5 | website: https://groupez.dev/resources/zmenu.253
6 | version: ${project.version}
7 | api-version: 1.13
8 | contributors: [ mani1232, lijinhong11, Adreez, EnzoShoes, Noltox, saildrag ]
9 | softdepend:
10 | - HeadDatabase
11 | - PlaceholderAPI
12 | - ItemsAdder
13 | - Slimefun
14 | - Jobs
15 | - LuckPerms
16 | - zHead
17 | - MagicCosmetics
18 | - packetevents
19 | folia-supported: true
20 | loadbefore:
21 | - SuperiorSkyblock2
--------------------------------------------------------------------------------
/src/main/resources/website/1_13/marketplace.yml:
--------------------------------------------------------------------------------
1 | name: "&8Marketplace"
2 | size: 54
3 | items:
4 | informations:
5 | slot: 49
6 | closeInventory: true
7 | messages:
8 | - '&7Open marketplace %link%'
9 | openLink:
10 | link: 'https://minecraft-inventory-builder.com/resources'
11 | message: 'https://m.zmenu.dev/'
12 | replace: '%link%'
13 | hover:
14 | - '&fClick here !'
15 | item:
16 | material: CHEST
17 | name: '&fInformations'
18 | lore:
19 | - '&7• &fResources&8: &a%zmenu_marketplace_resources%'
20 | - ''
21 | - '&7• &fClick to open the marketplace'
22 | resources:
23 | type: ZMENU_MARKETPLACE_RESOURCES
24 | item:
25 | material: BOOK
26 | name: '#94e6eb%resource_name%'
27 | lore:
28 | - ''
29 | - '&7• &fAuthor&8: #b6c7e3%resource_author%'
30 | - '&7• &fCategory&8: #b6c7e3%resource_category%'
31 | - '&7• &fDownload&8: #b6c7e3%resource_download%'
32 | - '&7• &fVersion&8: #b6c7e3%resource_version%'
33 | - ''
34 | - '&7• &fTag&8: #b6c7e3%resource_tag%'
35 | - ''
36 | - '&7• #e7aeebLeft click &fto access the resource'
37 | - '&7• #e7aeebRight click &fto download the resource'
--------------------------------------------------------------------------------
/src/main/resources/website/marketplace.yml:
--------------------------------------------------------------------------------
1 | name: "&8Marketplace"
2 | size: 54
3 | items:
4 | informations:
5 | slot: 49
6 | item:
7 | material: CHEST
8 | name: '&fInformations'
9 | lore:
10 | - '&f◾️ &fResources&8: &a%zmenu_marketplace_resources%'
11 | - ''
12 | - '&f◾️ &fClick to open the marketplace'
13 | resources:
14 | type: ZMENU_MARKETPLACE_RESOURCES
15 | item:
16 | material: BOOK
17 | name: '&f%resource_name%'
18 | lore:
19 | - '&7◾ &fAuthor&8: #b6c7e3%resource_author%'
20 | - ''
21 | - '&f◾️ &7Left click &fto access the resource'
22 | - '&f◾️ &7Right click &fto download the resource'
--------------------------------------------------------------------------------