Skip to content

Commit 24e7aeb

Browse files
author
Jan Kluka
committed
1.1-SNAPSHOT
Updated enchants api, added custom model data gui property and currency type for purchasing the enchant
1 parent 0772417 commit 24e7aeb

File tree

5 files changed

+47
-12
lines changed

5 files changed

+47
-12
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package dev.drawethree.xprison.api.currency;
2+
3+
public enum CurrencyType {
4+
GEMS,TOKENS,VAULT
5+
}

src/main/java/dev/drawethree/xprison/api/enchants/model/XPrisonEnchantment.java

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package dev.drawethree.xprison.api.enchants.model;
22

3+
import dev.drawethree.xprison.api.currency.CurrencyType;
34

45
/**
56
* Represents a custom enchantment in the XPrison system.
7+
* Each enchantment has a unique ID, name, configuration, and purchasing behavior.
68
*/
79
public interface XPrisonEnchantment {
810

@@ -34,51 +36,62 @@ public interface XPrisonEnchantment {
3436
*/
3537
String getNameWithoutColor();
3638

39+
/**
40+
* Gets the GUI properties of this enchantment, such as material, slot, and description.
41+
*
42+
* @return The GUI properties of the enchantment.
43+
*/
3744
XPrisonEnchantmentGuiProperties getGuiProperties();
3845

3946
/**
40-
* Gets the author of this enchantment.
47+
* Gets the name of the developer or plugin author who created this enchantment.
4148
*
4249
* @return The author name.
4350
*/
4451
String getAuthor();
4552

4653
/**
47-
* Checks whether this enchantment is currently enabled.
54+
* Checks whether this enchantment is currently enabled in the system.
4855
*
4956
* @return True if the enchantment is enabled, false otherwise.
5057
*/
5158
boolean isEnabled();
5259

5360
/**
54-
* Gets the maximum enchantment level that can be applied.
61+
* Gets the maximum level this enchantment can be upgraded to.
5562
*
56-
* @return The maximum allowed level.
63+
* @return The maximum allowed enchantment level.
5764
*/
5865
int getMaxLevel();
5966

6067
/**
61-
* Gets the base cost of applying this enchantment.
68+
* Gets the base cost of the enchantment, used as the starting cost for level 1.
6269
*
63-
* @return The base cost.
70+
* @return The base cost of applying the enchantment.
6471
*/
6572
long getBaseCost();
6673

6774
/**
68-
* Gets the incremental cost added per level of this enchantment.
75+
* Gets the amount by which the cost increases per level.
6976
*
70-
* @return The increase in cost per level.
77+
* @return The incremental cost per enchantment level.
7178
*/
7279
long getIncreaseCost();
7380

7481
/**
75-
* Loads or initializes the enchantment from its configuration or internal state.
76-
* Called when the enchantment is first created or reloaded.
82+
* Initializes or loads this enchantment. Called during plugin load or reload.
7783
*/
7884
void load();
7985

8086
/**
81-
* Unloads or disables the enchantment, freeing resources or unregistering listeners.
87+
* Cleans up or unloads this enchantment. Called during plugin shutdown or reload.
8288
*/
8389
void unload();
90+
91+
/**
92+
* Gets the type of currency used to purchase this enchantment.
93+
*
94+
* @return The currency type (e.g., TOKENS, GEMS, VAULT).
95+
*/
96+
CurrencyType getCurrencyType();
8497
}

src/main/java/dev/drawethree/xprison/api/enchants/model/XPrisonEnchantmentBase.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import com.google.gson.JsonObject;
55
import com.google.gson.JsonParser;
6+
import dev.drawethree.xprison.api.currency.CurrencyType;
67
import lombok.Getter;
78
import lombok.Setter;
89
import org.bukkit.ChatColor;
@@ -33,6 +34,7 @@ public abstract class XPrisonEnchantmentBase implements XPrisonEnchantment {
3334
protected long baseCost;
3435
protected long increaseCost;
3536
protected XPrisonEnchantmentGuiProperties guiProperties;
37+
protected CurrencyType currencyType;
3638

3739
/**
3840
* Constructs a new enchantment with the given config file.
@@ -72,6 +74,7 @@ private void loadBaseProperties(JsonObject config) {
7274
this.maxLevel = config.get("maxLevel").getAsInt();
7375
this.baseCost = config.get("initialCost").getAsLong();
7476
this.increaseCost = config.get("increaseCostBy").getAsLong();
77+
this.currencyType = CurrencyType.valueOf(config.get("currency").getAsString());
7578
}
7679

7780
/**
@@ -91,7 +94,9 @@ private void loadGuiProperties(JsonObject config) {
9194
.map(s -> ChatColor.translateAlternateColorCodes('&', s))
9295
.toList();
9396

94-
this.guiProperties = new XPrisonEnchantmentGuiPropertiesBase(slot, guiName, base64, mat, desc);
97+
int customModelData = gui.get("customModelData").getAsInt();
98+
99+
this.guiProperties = new XPrisonEnchantmentGuiPropertiesBase(slot, guiName, base64, mat, desc,customModelData);
95100
}
96101

97102
/**

src/main/java/dev/drawethree/xprison/api/enchants/model/XPrisonEnchantmentGuiProperties.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,11 @@ public interface XPrisonEnchantmentGuiProperties {
4242
* @return The Base64 string for the GUI item texture, or null/empty if not applicable.
4343
*/
4444
String getGuiBase64();
45+
46+
/**
47+
* Gets the custom model data for the GUI item
48+
*
49+
* @return Custom Model Data of GUI item
50+
*/
51+
int getCustomModelData();
4552
}

src/main/java/dev/drawethree/xprison/api/enchants/model/XPrisonEnchantmentGuiPropertiesBase.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,9 @@ class XPrisonEnchantmentGuiPropertiesBase implements XPrisonEnchantmentGuiProper
4141
*/
4242
private List<String> guiDescription;
4343

44+
/**
45+
* Custom model data of the item (MC 1.14 and above)
46+
*/
47+
private int customModelData;
48+
4449
}

0 commit comments

Comments
 (0)