working on a mythic system

This commit is contained in:
JISAUAY 2025-02-14 14:45:19 -06:00
parent dd69ac63eb
commit 1f5a062416
7 changed files with 103 additions and 1 deletions

View File

@ -0,0 +1,25 @@
package net.hexa.Plugin;
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 net.hexa.Plugin.Mythics.RockCracker;
public class CommandMythicEssence implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
ItemStack item = new RockCracker().item;
player.getInventory().addItem(item);
}
return true;
}
}

View File

@ -0,0 +1,28 @@
package net.hexa.Plugin;
import net.hexa.Plugin.Mythics.Constants;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
public class MythicListener implements Listener {
@EventHandler
public void onBlockBreak(BlockBreakEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
PersistentDataContainer itemData = item.getItemMeta().getPersistentDataContainer();
boolean isMythic = itemData.has(Constants.mythic_key);
if (isMythic) {
int mythic_id = itemData.get(Constants.mythic_key, PersistentDataType.INTEGER);
}
}
}

View File

@ -0,0 +1,8 @@
package net.hexa.Plugin.Mythics;
import net.hexa.Plugin.Plugin;
import org.bukkit.NamespacedKey;
public class Constants {
public static NamespacedKey mythic_key = new NamespacedKey(new Plugin(), "mythic-id");
}

View File

@ -0,0 +1,9 @@
package net.hexa.Plugin.Mythics;
import org.bukkit.inventory.ItemStack;
public abstract class MythicItem {
public ItemStack item;
public MythicItem() {}
}

View File

@ -0,0 +1,26 @@
package net.hexa.Plugin.Mythics;
import net.hexa.Plugin.Plugin;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
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);
item.getItemMeta().setUnbreakable(true);
item.getItemMeta().setItemName("Rock Cracker");
item.getItemMeta().setLore(Arrays.asList("and the land thrashes in furious pain..."));
item.getItemMeta().setEnchantable(0);
item.getItemMeta().getPersistentDataContainer().set(Constants.mythic_key, PersistentDataType.INTEGER, 1);
}
}

View File

@ -6,6 +6,7 @@ public class Plugin extends JavaPlugin {
@Override
public void onEnable() {
getLogger().info("onEnable is called!");
this.getCommand("essence").setExecutor(new CommandMythicEssence());
}
@Override

View File

@ -2,3 +2,8 @@ name: EconPlugin
version: 1.0
main: net.hexa.Plugin.Plugin
api-version: '1.21.4'
commands:
essence:
description: Gives a Mythic Item Essence
usage: /<command>