Compare commits
No commits in common. "dev/text-items" and "main" have entirely different histories.
dev/text-i
...
main
17
pom.xml
17
pom.xml
@ -12,18 +12,6 @@
|
|||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>14</source>
|
|
||||||
<target>14</target>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -32,10 +20,5 @@
|
|||||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.json</groupId>
|
|
||||||
<artifactId>json</artifactId>
|
|
||||||
<version>20250107</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
@ -1,24 +0,0 @@
|
|||||||
package net.hexa.MythicItems;
|
|
||||||
|
|
||||||
import net.hexa.MythicItems.Mythics.MythicItem;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
public class CommandListMythics implements CommandExecutor {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
||||||
if (sender instanceof Player) {
|
|
||||||
Player player = (Player) sender;
|
|
||||||
|
|
||||||
ItemStack item = MythicItem.getMythicById(0).item;
|
|
||||||
|
|
||||||
player.getInventory().addItem(item);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
package net.hexa.MythicItems;
|
package net.hexa.MythicItems;
|
||||||
|
|
||||||
import net.hexa.MythicItems.Mythics.MythicEssence;
|
import net.hexa.MythicItems.Mythics.MythicEssence;
|
||||||
import net.hexa.MythicItems.Mythics.MythicItem;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -15,7 +14,7 @@ public class CommandMythicEssence implements CommandExecutor {
|
|||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
|
|
||||||
ItemStack item = MythicItem.getMythicById(0).item;
|
ItemStack item = new MythicEssence().item;
|
||||||
|
|
||||||
player.getInventory().addItem(item);
|
player.getInventory().addItem(item);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,18 +1,39 @@
|
|||||||
package net.hexa.MythicItems.Mythics;
|
package net.hexa.MythicItems.Mythics;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.Arrays;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
public class MythicEssence {
|
public class MythicEssence extends MythicItem {
|
||||||
|
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
private static final List<MythicItem> mythics = MythicItem.getMythics();
|
|
||||||
|
public MythicEssence() {
|
||||||
|
item = new ItemStack(Material.CLAY_BALL);
|
||||||
|
|
||||||
|
item.addUnsafeEnchantment(Enchantment.FORTUNE, 7);
|
||||||
|
|
||||||
|
ItemMeta itemData = item.getItemMeta();
|
||||||
|
itemData.setItemName("§4Mythic Essence");
|
||||||
|
itemData.setLore(Arrays.asList("§o§aMaybe this will give you something nice?"));
|
||||||
|
|
||||||
|
item.setItemMeta(itemData);
|
||||||
|
|
||||||
|
setMythicId(0);
|
||||||
|
}
|
||||||
|
|
||||||
public static ItemStack rollMythic() {
|
public static ItemStack rollMythic() {
|
||||||
int mythic_id = random.nextInt(mythics.size() + 1);
|
int mythic_id = random.nextInt(2) + 1;
|
||||||
return mythics.get(mythic_id).item;
|
switch (mythic_id) {
|
||||||
|
case 1:
|
||||||
|
return new Terra().item;
|
||||||
|
case 2:
|
||||||
|
return new RockCracker().item;
|
||||||
|
}
|
||||||
|
return new ItemStack(Material.GRAVEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,173 +1,15 @@
|
|||||||
package net.hexa.MythicItems.Mythics;
|
package net.hexa.MythicItems.Mythics;
|
||||||
|
|
||||||
import org.json.*;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.enchantments.Enchantment;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.persistence.PersistentDataContainer;
|
import org.bukkit.persistence.PersistentDataContainer;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
|
||||||
import java.io.File;
|
public abstract class MythicItem {
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Scanner;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
public class MythicItem {
|
|
||||||
private static final String MYTHIC_DIR = "resources/mythic-items";
|
|
||||||
|
|
||||||
|
|
||||||
public ItemStack item;
|
public ItemStack item;
|
||||||
private static final Logger logger = Bukkit.getServer().getPluginManager().getPlugin("MythicItems").getLogger();
|
|
||||||
|
|
||||||
public MythicItem() {}
|
public MythicItem() {}
|
||||||
|
|
||||||
// Parse a mythic item from a json file
|
|
||||||
public MythicItem(JSONObject json) {
|
|
||||||
if (json == null) {
|
|
||||||
item = new ItemStack(Material.GRAVEL);
|
|
||||||
logger.warning("Constructor was passed a NULL JSONObject.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
String item_id = json.getString("item_id");
|
|
||||||
|
|
||||||
this.item = new ItemStack(Material.getMaterial(item_id));
|
|
||||||
|
|
||||||
ItemMeta item_metadata = item.getItemMeta();
|
|
||||||
|
|
||||||
if (json.has("Unbreakable"))
|
|
||||||
item_metadata.setUnbreakable(json.getBoolean("Unbreakable"));
|
|
||||||
|
|
||||||
if (json.has("Name"))
|
|
||||||
item_metadata.setItemName(json.getString("Name"));
|
|
||||||
|
|
||||||
if (json.has("Lore")) {
|
|
||||||
List<Object> lines = json.getJSONArray("Lore").toList();
|
|
||||||
List<String> lore = new ArrayList<>();
|
|
||||||
|
|
||||||
for (Object line : lines) {
|
|
||||||
lore.add(line.toString());
|
|
||||||
}
|
|
||||||
|
|
||||||
item_metadata.setLore(lore);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add all enchantments
|
|
||||||
JSONObject enchantments = json.getJSONObject("Enchantments");
|
|
||||||
for (String enchantment_key : enchantments.keySet()) {
|
|
||||||
|
|
||||||
int enchantment_level = enchantments.getInt(enchantment_key);
|
|
||||||
|
|
||||||
switch (enchantment_key.toUpperCase()) {
|
|
||||||
case "UNBREAKING" -> this.item.addUnsafeEnchantment(Enchantment.UNBREAKING, enchantment_level);
|
|
||||||
case "EFFICIENCY" -> this.item.addUnsafeEnchantment(Enchantment.EFFICIENCY, enchantment_level);
|
|
||||||
case "PROTECTION" -> this.item.addUnsafeEnchantment(Enchantment.PROTECTION, enchantment_level);
|
|
||||||
case "FIRE_PROTECTION" -> this.item.addUnsafeEnchantment(Enchantment.FIRE_PROTECTION, enchantment_level);
|
|
||||||
case "FEATHER_FALLING" -> this.item.addUnsafeEnchantment(Enchantment.FEATHER_FALLING, enchantment_level);
|
|
||||||
case "BLAST_PROTECTION" -> this.item.addUnsafeEnchantment(Enchantment.BLAST_PROTECTION, enchantment_level);
|
|
||||||
case "PROJECTILE_PROTECTION" -> this.item.addUnsafeEnchantment(Enchantment.PROJECTILE_PROTECTION, enchantment_level);
|
|
||||||
case "RESPIRATION" -> this.item.addUnsafeEnchantment(Enchantment.RESPIRATION, enchantment_level);
|
|
||||||
case "AQUA_AFFINITY" -> this.item.addUnsafeEnchantment(Enchantment.AQUA_AFFINITY, enchantment_level);
|
|
||||||
case "THORNS" -> this.item.addUnsafeEnchantment(Enchantment.THORNS, enchantment_level);
|
|
||||||
case "DEPTH_STRIDER" -> this.item.addUnsafeEnchantment(Enchantment.DEPTH_STRIDER, enchantment_level);
|
|
||||||
case "FROST_WALKER" -> this.item.addUnsafeEnchantment(Enchantment.FROST_WALKER, enchantment_level);
|
|
||||||
case "BINDING_CURSE" -> this.item.addUnsafeEnchantment(Enchantment.BINDING_CURSE, enchantment_level); // if you want it for some reason
|
|
||||||
case "SHARPNESS" -> this.item.addUnsafeEnchantment(Enchantment.SHARPNESS, enchantment_level);
|
|
||||||
case "SMITE" -> this.item.addUnsafeEnchantment(Enchantment.SMITE, enchantment_level);
|
|
||||||
case "BANE_OF_ARTHROPODS" -> this.item.addUnsafeEnchantment(Enchantment.BANE_OF_ARTHROPODS, enchantment_level);
|
|
||||||
case "KNOCKBACK" -> this.item.addUnsafeEnchantment(Enchantment.KNOCKBACK, enchantment_level);
|
|
||||||
case "FIRE_ASPECT" -> this.item.addUnsafeEnchantment(Enchantment.FIRE_ASPECT, enchantment_level);
|
|
||||||
case "LOOTING" -> this.item.addUnsafeEnchantment(Enchantment.LOOTING, enchantment_level);
|
|
||||||
case "SWEEPING_EDGE" -> this.item.addUnsafeEnchantment(Enchantment.SWEEPING_EDGE, enchantment_level);
|
|
||||||
case "SILK_TOUCH" -> this.item.addUnsafeEnchantment(Enchantment.SILK_TOUCH, enchantment_level);
|
|
||||||
case "FORTUNE" -> this.item.addUnsafeEnchantment(Enchantment.FORTUNE, enchantment_level);
|
|
||||||
case "POWER" -> this.item.addUnsafeEnchantment(Enchantment.POWER, enchantment_level);
|
|
||||||
case "PUNCH" -> this.item.addUnsafeEnchantment(Enchantment.PUNCH, enchantment_level);
|
|
||||||
case "FLAME" -> this.item.addUnsafeEnchantment(Enchantment.FLAME, enchantment_level);
|
|
||||||
case "INFINITY" -> this.item.addUnsafeEnchantment(Enchantment.INFINITY, enchantment_level);
|
|
||||||
case "LUCK_OF_THE_SEA" -> this.item.addUnsafeEnchantment(Enchantment.LOOTING, enchantment_level);
|
|
||||||
case "LURE" -> this.item.addUnsafeEnchantment(Enchantment.LURE, enchantment_level);
|
|
||||||
case "LOYALTY" -> this.item.addUnsafeEnchantment(Enchantment.LOYALTY, enchantment_level);
|
|
||||||
case "IMPALING" -> this.item.addUnsafeEnchantment(Enchantment.IMPALING, enchantment_level);
|
|
||||||
case "RIPTIDE" -> this.item.addUnsafeEnchantment(Enchantment.RIPTIDE, enchantment_level);
|
|
||||||
case "CHANNELING" -> this.item.addUnsafeEnchantment(Enchantment.CHANNELING, enchantment_level);
|
|
||||||
case "MULTISHOT" -> this.item.addUnsafeEnchantment(Enchantment.MULTISHOT, enchantment_level);
|
|
||||||
case "QUICK_CHARGE" -> this.item.addUnsafeEnchantment(Enchantment.QUICK_CHARGE, enchantment_level);
|
|
||||||
case "PIERCING" -> this.item.addUnsafeEnchantment(Enchantment.PIERCING, enchantment_level);
|
|
||||||
case "DENSITY" -> this.item.addUnsafeEnchantment(Enchantment.DENSITY, enchantment_level);
|
|
||||||
case "WIND_BURST" -> this.item.addUnsafeEnchantment(Enchantment.WIND_BURST, enchantment_level);
|
|
||||||
case "MENDING" -> this.item.addUnsafeEnchantment(Enchantment.MENDING, enchantment_level);
|
|
||||||
case "VANISHING_CURSE" -> this.item.addUnsafeEnchantment(Enchantment.VANISHING_CURSE, enchantment_level);
|
|
||||||
case "SOUL_SPEED" -> this.item.addUnsafeEnchantment(Enchantment.SOUL_SPEED, enchantment_level);
|
|
||||||
case "SWIFT_SNEAK" -> this.item.addUnsafeEnchantment(Enchantment.SWIFT_SNEAK, enchantment_level);
|
|
||||||
default -> logger.warning("Enchantment " + enchantment_key + "does not exist.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save the metadata
|
|
||||||
item.setItemMeta(item_metadata);
|
|
||||||
|
|
||||||
// Write the mythic id to the PDC
|
|
||||||
if (json.has("mythic_id")) {
|
|
||||||
setMythicId(json.getInt("mythic_id"));
|
|
||||||
} else {
|
|
||||||
logger.warning("No Mythic ID was included!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Parse all mythic items in the resources/mythics-items/ directory
|
|
||||||
public static List<MythicItem> getMythics() {
|
|
||||||
ArrayList<MythicItem> mythic_items = new ArrayList<>();
|
|
||||||
|
|
||||||
File mythic_directory = new File(MYTHIC_DIR);
|
|
||||||
File[] mythic_jsons = mythic_directory.listFiles();
|
|
||||||
|
|
||||||
if (mythic_jsons != null) {
|
|
||||||
for (File mythic_json : mythic_jsons) {
|
|
||||||
String json_content = null;
|
|
||||||
try {
|
|
||||||
json_content = new Scanner(mythic_json).useDelimiter("\\Z").next();
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
mythic_items.add(new MythicItem(new JSONObject(json_content)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return mythic_items;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static MythicItem getMythicById(int id) {
|
|
||||||
File mythic_directory = new File(MYTHIC_DIR);
|
|
||||||
File[] mythic_jsons = mythic_directory.listFiles();
|
|
||||||
|
|
||||||
if (mythic_jsons != null) {
|
|
||||||
for (File mythic_json : mythic_jsons) {
|
|
||||||
String json_content = null;
|
|
||||||
try {
|
|
||||||
json_content = new Scanner(mythic_json).useDelimiter("\\Z").next();
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject json = new JSONObject(json_content);
|
|
||||||
|
|
||||||
if (json.has("mythic_id")) {
|
|
||||||
if (json.getInt("mythic_id") == id) {
|
|
||||||
return new MythicItem(json);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new MythicItem();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int getMythicId(ItemStack item) {
|
public static int getMythicId(ItemStack item) {
|
||||||
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
|
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
|
||||||
|
|
||||||
|
|||||||
27
src/main/java/net/hexa/MythicItems/Mythics/RockCracker.java
Normal file
27
src/main/java/net/hexa/MythicItems/Mythics/RockCracker.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package net.hexa.MythicItems.Mythics;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class RockCracker extends MythicItem {
|
||||||
|
public RockCracker() {
|
||||||
|
item = new ItemStack(Material.NETHERITE_PICKAXE);
|
||||||
|
|
||||||
|
item.addUnsafeEnchantment(Enchantment.EFFICIENCY, 9);
|
||||||
|
item.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);
|
||||||
|
|
||||||
|
ItemMeta itemData = item.getItemMeta();
|
||||||
|
|
||||||
|
itemData.setUnbreakable(true);
|
||||||
|
itemData.setItemName("Rock Cracker");
|
||||||
|
itemData.setLore(Arrays.asList("and the land thrashes in furious pain..."));
|
||||||
|
|
||||||
|
item.setItemMeta(itemData);
|
||||||
|
|
||||||
|
this.setMythicId(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
26
src/main/java/net/hexa/MythicItems/Mythics/Terra.java
Normal file
26
src/main/java/net/hexa/MythicItems/Mythics/Terra.java
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package net.hexa.MythicItems.Mythics;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class Terra extends MythicItem {
|
||||||
|
public Terra() {
|
||||||
|
item = new ItemStack(Material.NETHERITE_SHOVEL);
|
||||||
|
|
||||||
|
item.addUnsafeEnchantment(Enchantment.EFFICIENCY, 8);
|
||||||
|
item.addUnsafeEnchantment(Enchantment.UNBREAKING, 10);
|
||||||
|
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
|
||||||
|
meta.setUnbreakable(true);
|
||||||
|
meta.setItemName("Terra");
|
||||||
|
meta.setLore(Arrays.asList("All will eventually return to Terra."));
|
||||||
|
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
setMythicId(2);
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,11 +0,0 @@
|
|||||||
{
|
|
||||||
"item_id" : "minecraft:clay_ball",
|
|
||||||
"Enchantments" : {
|
|
||||||
"FORTUNE" : 7
|
|
||||||
},
|
|
||||||
"Name" : "§4Mythic Essence",
|
|
||||||
"Lore" : [
|
|
||||||
"§o§aMaybe this will give you something nice?"
|
|
||||||
],
|
|
||||||
"mythic_id" : 0
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"item_id" : "minecraft:netherite_pickaxe",
|
|
||||||
"Enchantments" : {
|
|
||||||
"UNBREAKING" : 9,
|
|
||||||
"EFFICIENCY" : 9
|
|
||||||
},
|
|
||||||
"Name" : "Terra Pickaxe",
|
|
||||||
"Lore" : [
|
|
||||||
"and the land thrashes in furious pain..."
|
|
||||||
],
|
|
||||||
"Unbreakable" : true,
|
|
||||||
"mythic_id" : 1
|
|
||||||
}
|
|
||||||
@ -1,13 +0,0 @@
|
|||||||
{
|
|
||||||
"item_id" : "minecraft:netherite_shovel",
|
|
||||||
"Enchantments" : {
|
|
||||||
"UNBREAKING" : 10,
|
|
||||||
"EFFICIENCY" : 9
|
|
||||||
},
|
|
||||||
"Name" : "Terra Shovel",
|
|
||||||
"Lore" : [
|
|
||||||
"All will eventually return to Terra."
|
|
||||||
],
|
|
||||||
"Unbreakable" : true,
|
|
||||||
"mythic_id" : 2
|
|
||||||
}
|
|
||||||
@ -7,6 +7,3 @@ commands:
|
|||||||
essence:
|
essence:
|
||||||
description: Gives a Mythic Item Essence
|
description: Gives a Mythic Item Essence
|
||||||
usage: /<command>
|
usage: /<command>
|
||||||
listMythics:
|
|
||||||
description: Lists Mythic Items
|
|
||||||
usage: /<command>
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user