Compare commits
11 Commits
main
...
dev/text-i
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c0e2dd3d59 | ||
|
|
642ad215e7 | ||
|
|
207423e987 | ||
|
|
97198e9e17 | ||
|
|
4c6180e8f1 | ||
|
|
3a9cc2dfe0 | ||
|
|
5659424a78 | ||
|
|
b617a39b40 | ||
|
|
f2345994ca | ||
| f39766a192 | |||
| 754d9c6420 |
67
items.md
Normal file
67
items.md
Normal file
@ -0,0 +1,67 @@
|
||||
# Brainstorming
|
||||
|
||||
## Sets
|
||||
|
||||
**Piglin set**
|
||||
|
||||
Some sort of gold focused set? maybe just a pickaxe & sword?
|
||||
extra gold drops from piglins
|
||||
extra gold drops in the nether?
|
||||
|
||||
Greed or midas related name? Hubris?
|
||||
|
||||
**Misc (not a set)**
|
||||
|
||||
- Lamenting Malice (crossbow OR bow that drops extra ghast tears)
|
||||
- Roman Candle (Sword with extra fortune when killing blazes)
|
||||
- Axe with wither skeleton head fortune
|
||||
> Cortex Rampage?
|
||||
> Chaotic Solutions?
|
||||
> Demon Days?
|
||||
|
||||
# Set Ideas
|
||||
|
||||
**Generic**
|
||||
|
||||
All tools / armor are unbreakable, high effiency, nothing special
|
||||
Armor should probably only be like prot 6
|
||||
|
||||
**Full set effect**: Maybe the full armor set could give you a particle effect?
|
||||
|
||||
|
||||
## Other Rarities
|
||||
|
||||
I'm thinking it should take 9~ dusts (scrapped items) to be able to go up a tier
|
||||
|
||||
So a Mythic would require:
|
||||
| Tier | Epic Dust | Rare Dust | Uncommmon Dust |
|
||||
|----------|-----------|-----------|----------------|
|
||||
| Mythic | 9 | 81 | 729 |
|
||||
| Epic | N/A | 9 | 81 |
|
||||
| Rare | N/A | N/A | 9 |
|
||||
| Uncommon | N/A | N/A | N/A |
|
||||
|
||||
If a mythic is 1/1000 drop from hostile mobs then an uncommon should drop like... 1/3 mobs...
|
||||
One spawner can produce like 500 mobs an hour. (Although I don't intend on including spawned mobs)
|
||||
|
||||
|
||||
Tiers:
|
||||
- (0) Mythics (name pending?)
|
||||
- (1) Epic
|
||||
- (2) Rare
|
||||
- (3) Uncommon
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
59
pom.xml
59
pom.xml
@ -1,10 +1,17 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>net.hexa</groupId>
|
||||
<artifactId>MythicItems</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<version>1.0-SNAPSHOT-1.21.11</version>
|
||||
|
||||
<properties>
|
||||
<minecraft.version>1.21.11</minecraft.version>
|
||||
<spigot.version>${minecraft.version}-R0.1-SNAPSHOT</spigot.version>
|
||||
<java.version>14</java.version>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
@ -13,12 +20,56 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.13.0</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-shade-plugin</artifactId>
|
||||
<version>3.5.0</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>shade</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.3.0</version>
|
||||
<configuration>
|
||||
<outputDirectory>${user.home}/Documents/vanilla+/plugins/</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.21.4-R0.1-SNAPSHOT</version>
|
||||
<version>${spigot.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20250107</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
</project>
|
||||
27
src/main/java/net/hexa/MythicItems/CommandListMythics.java
Normal file
27
src/main/java/net/hexa/MythicItems/CommandListMythics.java
Normal file
@ -0,0 +1,27 @@
|
||||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
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 = null;
|
||||
item = MythicItem.getMythicById(0).item;
|
||||
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -1,12 +1,14 @@
|
||||
package net.hexa.MythicItems;
|
||||
|
||||
import net.hexa.MythicItems.Mythics.MythicEssence;
|
||||
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;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class CommandMythicEssence implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
@ -14,7 +16,8 @@ public class CommandMythicEssence implements CommandExecutor {
|
||||
if (sender instanceof Player) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
ItemStack item = new MythicEssence().item;
|
||||
ItemStack item = null;
|
||||
item = MythicItem.getMythicById(0).item;
|
||||
|
||||
player.getInventory().addItem(item);
|
||||
}
|
||||
|
||||
5
src/main/java/net/hexa/MythicItems/Constants.java
Normal file
5
src/main/java/net/hexa/MythicItems/Constants.java
Normal file
@ -0,0 +1,5 @@
|
||||
package net.hexa.MythicItems;
|
||||
|
||||
public class Constants {
|
||||
public static Integer MYTHIC_DROP_CHANCE = 10; // 1 in n chances
|
||||
}
|
||||
@ -1,11 +1,21 @@
|
||||
package net.hexa.MythicItems;
|
||||
|
||||
import net.hexa.MythicItems.mythics.MythicItem;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class MythicItems extends JavaPlugin {
|
||||
@Override
|
||||
public void onEnable() {
|
||||
getLogger().info("onEnable is called!");
|
||||
MythicItem.init(this);
|
||||
|
||||
startupLog();
|
||||
|
||||
this.getCommand("essence").setExecutor(new CommandMythicEssence());
|
||||
getServer().getPluginManager().registerEvents(new MythicListener(), this);
|
||||
}
|
||||
@ -14,4 +24,24 @@ public class MythicItems extends JavaPlugin {
|
||||
public void onDisable() {
|
||||
getLogger().info("onDisable is called!");
|
||||
}
|
||||
|
||||
// Helpers
|
||||
private void startupLog() {
|
||||
// Log which directory we are scanning for mythic JSON files
|
||||
File mythicDir = new File(getDataFolder(), "mythic-items/");
|
||||
getLogger().info("Scanning for mythics in: " + mythicDir.getPath());
|
||||
|
||||
List<MythicItem> mythics = MythicItem.getMythics();
|
||||
getLogger().info("Found " + mythics.size() + " mythic item(s).");
|
||||
|
||||
for (MythicItem mythic : mythics) {
|
||||
ItemStack item = mythic.item;
|
||||
String typeName = item.getType().name();
|
||||
String displayName = item.getItemMeta() != null && item.getItemMeta().hasDisplayName()
|
||||
? item.getItemMeta().getDisplayName()
|
||||
: "<no custom name>";
|
||||
getLogger().info(" - Mythic: material=" + typeName + ", name=" + displayName);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,19 +1,27 @@
|
||||
package net.hexa.MythicItems;
|
||||
|
||||
import net.hexa.MythicItems.Mythics.MythicEssence;
|
||||
import net.hexa.MythicItems.Mythics.MythicItem;
|
||||
import net.hexa.MythicItems.mythics.MythicEssence;
|
||||
import net.hexa.MythicItems.mythics.MythicItem;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Enemy;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class MythicListener implements Listener {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
@EventHandler
|
||||
public void onBlockBreak(BlockBreakEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
@ -53,4 +61,29 @@ public class MythicListener implements Listener {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMobDeath(EntityDeathEvent event) {
|
||||
Entity killer = event.getDamageSource().getCausingEntity();
|
||||
Entity mob = event.getEntity();
|
||||
|
||||
if (killer instanceof Player && mob instanceof Enemy && !mob.hasMetadata("fromSpawner")) {
|
||||
int result = random.nextInt(1, Constants.MYTHIC_DROP_CHANCE + 1);
|
||||
if (result == 1) {
|
||||
ItemStack mythicReward = MythicEssence.rollMythic();
|
||||
mob.getWorld().dropItemNaturally(
|
||||
mob.getLocation(),
|
||||
mythicReward
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onMobSpawn(CreatureSpawnEvent event) {
|
||||
if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.SPAWNER) {
|
||||
event.getEntity().setMetadata("fromSpawner", new FixedMetadataValue(this, true));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,39 +0,0 @@
|
||||
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;
|
||||
import java.util.Random;
|
||||
|
||||
public class MythicEssence extends MythicItem {
|
||||
|
||||
private static final Random random = new Random();
|
||||
|
||||
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() {
|
||||
int mythic_id = random.nextInt(2) + 1;
|
||||
switch (mythic_id) {
|
||||
case 1:
|
||||
return new Terra().item;
|
||||
case 2:
|
||||
return new RockCracker().item;
|
||||
}
|
||||
return new ItemStack(Material.GRAVEL);
|
||||
}
|
||||
}
|
||||
@ -1,30 +0,0 @@
|
||||
package net.hexa.MythicItems.Mythics;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
public abstract class MythicItem {
|
||||
public ItemStack item;
|
||||
|
||||
public MythicItem() {}
|
||||
|
||||
public static int getMythicId(ItemStack item) {
|
||||
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
|
||||
|
||||
return itemData.get(Constants.mythic_key, PersistentDataType.INTEGER);
|
||||
}
|
||||
|
||||
public static boolean isMythic(ItemStack item) {
|
||||
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
|
||||
|
||||
return itemData.has(Constants.mythic_key);
|
||||
}
|
||||
|
||||
protected void setMythicId(int id) {
|
||||
ItemMeta itemData = item.getItemMeta();
|
||||
itemData.getPersistentDataContainer().set(Constants.mythic_key, PersistentDataType.INTEGER, id);
|
||||
this.item.setItemMeta(itemData);
|
||||
}
|
||||
}
|
||||
@ -1,27 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
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,4 +1,4 @@
|
||||
package net.hexa.MythicItems.Mythics;
|
||||
package net.hexa.MythicItems.mythics;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.NamespacedKey;
|
||||
@ -0,0 +1,20 @@
|
||||
package net.hexa.MythicItems.mythics;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class MythicEssence {
|
||||
|
||||
private static final Random random = new Random();
|
||||
private static final List<MythicItem> mythics = MythicItem.getMythics();
|
||||
|
||||
public static ItemStack rollMythic() {
|
||||
int mythic_id;
|
||||
do {
|
||||
mythic_id = random.nextInt(mythics.size());
|
||||
} while (mythic_id == 0);
|
||||
return mythics.get(mythic_id).item;
|
||||
}
|
||||
}
|
||||
228
src/main/java/net/hexa/MythicItems/mythics/MythicItem.java
Normal file
228
src/main/java/net/hexa/MythicItems/mythics/MythicItem.java
Normal file
@ -0,0 +1,228 @@
|
||||
package net.hexa.MythicItems.mythics;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.ItemMeta;
|
||||
import org.bukkit.persistence.PersistentDataContainer;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
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 = "mythic-items/";
|
||||
|
||||
private static JavaPlugin plugin;
|
||||
|
||||
public ItemStack item;
|
||||
private static final Logger logger = Bukkit.getServer().getPluginManager().getPlugin("MythicItems").getLogger();
|
||||
|
||||
public static void init(JavaPlugin pl) {
|
||||
plugin = pl;
|
||||
}
|
||||
|
||||
public MythicItem() {}
|
||||
|
||||
// Parse a mythic item from a json file
|
||||
public MythicItem(JSONObject json) {
|
||||
logger.info("Json: " + json.toString());
|
||||
if (json == null) {
|
||||
item = new ItemStack(Material.GRAVEL);
|
||||
logger.warning("Constructor was passed a NULL JSONObject.");
|
||||
return;
|
||||
}
|
||||
|
||||
String item_id = json.getString("item_id");
|
||||
|
||||
Material m = Material.matchMaterial(item_id);
|
||||
if (m == null) {
|
||||
m = Material.DIRT;
|
||||
}
|
||||
|
||||
this.item = new ItemStack(m);
|
||||
|
||||
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 onto the ItemMeta so they are not overwritten
|
||||
if (json.has("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" -> item_metadata.addEnchant(Enchantment.UNBREAKING, enchantment_level, true);
|
||||
case "EFFICIENCY" -> item_metadata.addEnchant(Enchantment.EFFICIENCY, enchantment_level, true);
|
||||
case "PROTECTION" -> item_metadata.addEnchant(Enchantment.PROTECTION, enchantment_level, true);
|
||||
case "FIRE_PROTECTION" -> item_metadata.addEnchant(Enchantment.FIRE_PROTECTION, enchantment_level, true);
|
||||
case "FEATHER_FALLING" -> item_metadata.addEnchant(Enchantment.FEATHER_FALLING, enchantment_level, true);
|
||||
case "BLAST_PROTECTION" -> item_metadata.addEnchant(Enchantment.BLAST_PROTECTION, enchantment_level, true);
|
||||
case "PROJECTILE_PROTECTION" -> item_metadata.addEnchant(Enchantment.PROJECTILE_PROTECTION, enchantment_level, true);
|
||||
case "RESPIRATION" -> item_metadata.addEnchant(Enchantment.RESPIRATION, enchantment_level, true);
|
||||
case "AQUA_AFFINITY" -> item_metadata.addEnchant(Enchantment.AQUA_AFFINITY, enchantment_level, true);
|
||||
case "THORNS" -> item_metadata.addEnchant(Enchantment.THORNS, enchantment_level, true);
|
||||
case "DEPTH_STRIDER" -> item_metadata.addEnchant(Enchantment.DEPTH_STRIDER, enchantment_level, true);
|
||||
case "FROST_WALKER" -> item_metadata.addEnchant(Enchantment.FROST_WALKER, enchantment_level, true);
|
||||
case "BINDING_CURSE" -> item_metadata.addEnchant(Enchantment.BINDING_CURSE, enchantment_level, true); // if you want it for some reason
|
||||
case "SHARPNESS" -> item_metadata.addEnchant(Enchantment.SHARPNESS, enchantment_level, true);
|
||||
case "SMITE" -> item_metadata.addEnchant(Enchantment.SMITE, enchantment_level, true);
|
||||
case "BANE_OF_ARTHROPODS" -> item_metadata.addEnchant(Enchantment.BANE_OF_ARTHROPODS, enchantment_level, true);
|
||||
case "KNOCKBACK" -> item_metadata.addEnchant(Enchantment.KNOCKBACK, enchantment_level, true);
|
||||
case "FIRE_ASPECT" -> item_metadata.addEnchant(Enchantment.FIRE_ASPECT, enchantment_level, true);
|
||||
case "LOOTING" -> item_metadata.addEnchant(Enchantment.LOOTING, enchantment_level, true);
|
||||
case "SWEEPING_EDGE" -> item_metadata.addEnchant(Enchantment.SWEEPING_EDGE, enchantment_level, true);
|
||||
case "SILK_TOUCH" -> item_metadata.addEnchant(Enchantment.SILK_TOUCH, enchantment_level, true);
|
||||
case "FORTUNE" -> item_metadata.addEnchant(Enchantment.FORTUNE, enchantment_level, true);
|
||||
case "POWER" -> item_metadata.addEnchant(Enchantment.POWER, enchantment_level, true);
|
||||
case "PUNCH" -> item_metadata.addEnchant(Enchantment.PUNCH, enchantment_level, true);
|
||||
case "FLAME" -> item_metadata.addEnchant(Enchantment.FLAME, enchantment_level, true);
|
||||
case "INFINITY" -> item_metadata.addEnchant(Enchantment.INFINITY, enchantment_level, true);
|
||||
case "LUCK_OF_THE_SEA" -> item_metadata.addEnchant(Enchantment.LUCK_OF_THE_SEA, enchantment_level, true);
|
||||
case "LURE" -> item_metadata.addEnchant(Enchantment.LURE, enchantment_level, true);
|
||||
case "LOYALTY" -> item_metadata.addEnchant(Enchantment.LOYALTY, enchantment_level, true);
|
||||
case "IMPALING" -> item_metadata.addEnchant(Enchantment.IMPALING, enchantment_level, true);
|
||||
case "RIPTIDE" -> item_metadata.addEnchant(Enchantment.RIPTIDE, enchantment_level, true);
|
||||
case "CHANNELING" -> item_metadata.addEnchant(Enchantment.CHANNELING, enchantment_level, true);
|
||||
case "MULTISHOT" -> item_metadata.addEnchant(Enchantment.MULTISHOT, enchantment_level, true);
|
||||
case "QUICK_CHARGE" -> item_metadata.addEnchant(Enchantment.QUICK_CHARGE, enchantment_level, true);
|
||||
case "PIERCING" -> item_metadata.addEnchant(Enchantment.PIERCING, enchantment_level, true);
|
||||
case "DENSITY" -> item_metadata.addEnchant(Enchantment.DENSITY, enchantment_level, true);
|
||||
case "WIND_BURST" -> item_metadata.addEnchant(Enchantment.WIND_BURST, enchantment_level, true);
|
||||
case "MENDING" -> item_metadata.addEnchant(Enchantment.MENDING, enchantment_level, true);
|
||||
case "VANISHING_CURSE" -> item_metadata.addEnchant(Enchantment.VANISHING_CURSE, enchantment_level, true);
|
||||
case "SOUL_SPEED" -> item_metadata.addEnchant(Enchantment.SOUL_SPEED, enchantment_level, true);
|
||||
case "SWIFT_SNEAK" -> item_metadata.addEnchant(Enchantment.SWIFT_SNEAK, enchantment_level, true);
|
||||
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 from the plugin's data folder mythic-items/ directory
|
||||
public static List<MythicItem> getMythics() {
|
||||
ArrayList<MythicItem> mythicItems = new ArrayList<>();
|
||||
|
||||
if (plugin == null) {
|
||||
logger.warning("MythicItem plugin reference is null; cannot load mythics.");
|
||||
return mythicItems;
|
||||
}
|
||||
|
||||
File mythicDirectory = new File(plugin.getDataFolder(), MYTHIC_DIR);
|
||||
if (!mythicDirectory.exists() || !mythicDirectory.isDirectory()) {
|
||||
logger.warning("Mythic directory does not exist: " + mythicDirectory.getPath());
|
||||
return mythicItems;
|
||||
}
|
||||
|
||||
File[] mythicJsons = mythicDirectory.listFiles((dir, name) -> name.toLowerCase().endsWith(".json"));
|
||||
if (mythicJsons == null) {
|
||||
return mythicItems;
|
||||
}
|
||||
|
||||
for (File mythicJson : mythicJsons) {
|
||||
String jsonContent;
|
||||
try {
|
||||
jsonContent = new Scanner(mythicJson).useDelimiter("\\Z").next();
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.warning("Failed to read mythic file " + mythicJson.getName() + ": " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
mythicItems.add(new MythicItem(new JSONObject(jsonContent)));
|
||||
}
|
||||
|
||||
return mythicItems;
|
||||
}
|
||||
|
||||
public static MythicItem getMythicById(int id) {
|
||||
if (plugin == null) {
|
||||
logger.warning("MythicItem plugin reference is null; cannot load mythics by id.");
|
||||
return new MythicItem();
|
||||
}
|
||||
|
||||
File mythicDirectory = new File(plugin.getDataFolder(), MYTHIC_DIR);
|
||||
if (!mythicDirectory.exists() || !mythicDirectory.isDirectory()) {
|
||||
logger.warning("Mythic directory does not exist: " + mythicDirectory.getPath());
|
||||
return new MythicItem();
|
||||
}
|
||||
|
||||
File[] mythicJsons = mythicDirectory.listFiles((dir, name) -> name.toLowerCase().endsWith(".json"));
|
||||
if (mythicJsons == null) {
|
||||
return new MythicItem();
|
||||
}
|
||||
|
||||
for (File mythicJson : mythicJsons) {
|
||||
String jsonContent;
|
||||
try {
|
||||
jsonContent = new Scanner(mythicJson).useDelimiter("\\Z").next();
|
||||
} catch (FileNotFoundException e) {
|
||||
logger.warning("Failed to read mythic file " + mythicJson.getName() + ": " + e.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
JSONObject json = new JSONObject(jsonContent);
|
||||
if (json.has("mythic_id") && json.getInt("mythic_id") == id) {
|
||||
return new MythicItem(json);
|
||||
}
|
||||
}
|
||||
|
||||
logger.warning("No mythic found with id " + id + "; returning default MythicItem.");
|
||||
return new MythicItem();
|
||||
}
|
||||
|
||||
public static int getMythicId(ItemStack item) {
|
||||
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
|
||||
|
||||
return itemData.get(Constants.mythic_key, PersistentDataType.INTEGER);
|
||||
}
|
||||
|
||||
public static boolean isMythic(ItemStack item) {
|
||||
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
|
||||
|
||||
return itemData.has(Constants.mythic_key);
|
||||
}
|
||||
|
||||
protected void setMythicId(int id) {
|
||||
ItemMeta itemData = item.getItemMeta();
|
||||
itemData.getPersistentDataContainer().set(Constants.mythic_key, PersistentDataType.INTEGER, id);
|
||||
this.item.setItemMeta(itemData);
|
||||
}
|
||||
}
|
||||
11
src/main/resources/mythic-items/essence.json
Normal file
11
src/main/resources/mythic-items/essence.json
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"item_id" : "minecraft:clay_ball",
|
||||
"Enchantments" : {
|
||||
"FORTUNE" : 7
|
||||
},
|
||||
"Name" : "§4Mythic Essence",
|
||||
"Lore" : [
|
||||
"§o§aMaybe this will give you something nice?"
|
||||
],
|
||||
"mythic_id" : 0
|
||||
}
|
||||
13
src/main/resources/mythic-items/terra-pickaxe.json
Normal file
13
src/main/resources/mythic-items/terra-pickaxe.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"item_id" : "minecraft:netherite_pickaxe",
|
||||
"Enchantments" : {
|
||||
"UNBREAKING" : 9,
|
||||
"EFFICIENCY" : 9
|
||||
},
|
||||
"Name" : "§2§lTerra§r §fPickaxe",
|
||||
"Lore" : [
|
||||
"and the land thrashes in furious pain..."
|
||||
],
|
||||
"Unbreakable" : true,
|
||||
"mythic_id" : 1
|
||||
}
|
||||
13
src/main/resources/mythic-items/terra-shovel.json
Normal file
13
src/main/resources/mythic-items/terra-shovel.json
Normal file
@ -0,0 +1,13 @@
|
||||
{
|
||||
"item_id" : "minecraft:netherite_shovel",
|
||||
"Enchantments" : {
|
||||
"UNBREAKING" : 10,
|
||||
"EFFICIENCY" : 9
|
||||
},
|
||||
"Name" : "§2§lTerra§r§f Shovel",
|
||||
"Lore" : [
|
||||
"All will eventually return to Terra."
|
||||
],
|
||||
"Unbreakable" : true,
|
||||
"mythic_id" : 2
|
||||
}
|
||||
@ -7,3 +7,6 @@ commands:
|
||||
essence:
|
||||
description: Gives a Mythic Item Essence
|
||||
usage: /<command>
|
||||
listMythics:
|
||||
description: Lists Mythic Items
|
||||
usage: /<command>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user