# changes

- added shoot wither skull ability to witherite (may be changed later idk, depends how people feel about it)
- refactored custom gear set code to be more concise with less boilerplate

# additions
- added dragon armour
  - right click with sword to dash
  - chestplate is actually an elytra, uses a clientside resourcepack to render a chestplate as well.
  - chestplate has the armour value of prot4 netherite
- added blazing armour
  - full set provides complete immunity to fire
  - right click with sword shoots three fireballs just like a blaze.
  - sword has the equivalent of fire aspect 3 built in.
- started working on a basic abstract class for custom food and drinks to make additions easier in the future.

# improved clientside resourcepack with new additions
- dragon armour / sword
- blazing armour / sword
This commit is contained in:
2025-02-06 09:19:49 +00:00
parent 70ebcbe87b
commit c20714b3a7
13 changed files with 538 additions and 134 deletions
@@ -3,9 +3,11 @@ package dev.zxq5.fantasysmp;
import dev.zxq5.fantasysmp.events.HereticWarner; import dev.zxq5.fantasysmp.events.HereticWarner;
import dev.zxq5.fantasysmp.events.StevenKillCheck; import dev.zxq5.fantasysmp.events.StevenKillCheck;
import dev.zxq5.fantasysmp.items.*; import dev.zxq5.fantasysmp.items.*;
import dev.zxq5.fantasysmp.items.gear.LightningSword;
import dev.zxq5.fantasysmp.items.gear.StevensWrath;
import dev.zxq5.fantasysmp.items.gear.WitheriteGear;
import dev.zxq5.fantasysmp.warps.Warp; import dev.zxq5.fantasysmp.warps.Warp;
import dev.zxq5.fantasysmp.warps.Warper; import dev.zxq5.fantasysmp.warps.Warper;
import org.bukkit.entity.Panda;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
public final class Fantasysmp extends JavaPlugin { public final class Fantasysmp extends JavaPlugin {
@@ -33,15 +35,6 @@ public final class Fantasysmp extends JavaPlugin {
getServer().broadcastMessage("registered commands + \n /home \n /sethome \n /warp \n /setwarp"); getServer().broadcastMessage("registered commands + \n /home \n /sethome \n /warp \n /setwarp");
GenericGearSet witherite = new Witherite();
witherite.registerRecipes();
Lightning lightning = new Lightning();
lightning.registerRecipes();
StevensWrath stevensWrath = new StevensWrath();
stevensWrath.registerRecipes();
getServer().getPluginManager().registerEvents(new StevenKillCheck(), this); getServer().getPluginManager().registerEvents(new StevenKillCheck(), this);
HereticWarner hereticWarner = new HereticWarner(); HereticWarner hereticWarner = new HereticWarner();
@@ -0,0 +1,4 @@
package dev.zxq5.fantasysmp.items;
public class Food {
}
@@ -1,22 +1,22 @@
package dev.zxq5.fantasysmp.items; package dev.zxq5.fantasysmp.items;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.attribute.Attribute; import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier; import org.bukkit.attribute.AttributeModifier;
import org.bukkit.entity.Item; import org.bukkit.event.Listener;
import org.bukkit.inventory.EquipmentSlotGroup; import org.bukkit.inventory.*;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.EquippableComponent;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
public abstract class GenericGearSet implements HasRecipes { public abstract class GenericGearSet implements HasRecipes, Listener {
protected ItemStats sword = new ItemStats(); protected ItemStats sword = new ItemStats();
protected ItemStats helmet = new ItemStats(); protected ItemStats helmet = new ItemStats();
@@ -27,6 +27,10 @@ public abstract class GenericGearSet implements HasRecipes {
protected static RecipeChoice NETHERITE_UPGRADE = new RecipeChoice.MaterialChoice(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE); protected static RecipeChoice NETHERITE_UPGRADE = new RecipeChoice.MaterialChoice(Material.NETHERITE_UPGRADE_SMITHING_TEMPLATE);
protected static RecipeChoice WITHER_SKULL = new RecipeChoice.MaterialChoice(Material.WITHER_SKELETON_SKULL); protected static RecipeChoice WITHER_SKULL = new RecipeChoice.MaterialChoice(Material.WITHER_SKELETON_SKULL);
public void registerEvents(Plugin plugin) {
Bukkit.getServer().getPluginManager().registerEvents(this, plugin);
}
public void setTier1() { public void setTier1() {
sword.setMaterial(Material.WOODEN_SWORD); sword.setMaterial(Material.WOODEN_SWORD);
helmet.setMaterial(Material.LEATHER_HELMET); helmet.setMaterial(Material.LEATHER_HELMET);
@@ -143,13 +147,13 @@ public abstract class GenericGearSet implements HasRecipes {
meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES); meta.addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
meta.setDisplayName(sword.name); meta.setDisplayName(sword.name);
if (!sword.customModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + sword.customModel)); if (!sword.customItemModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + sword.customItemModel));
ArrayList<String> lore = new ArrayList<>(List.of(sword.lore)); ArrayList<String> lore = new ArrayList<>(List.of(sword.lore));
lore.add("\n"); lore.add("\n");
lore.add(ChatColor.GRAY + "When in Main Hand:" + ChatColor.RESET); lore.add(ChatColor.GRAY + "When in Main Hand:" + ChatColor.RESET);
if (sword.attackDamage > 0) lore.add(ChatColor.GREEN + " " + sword.attackDamage + " Attack Damage" + ChatColor.RESET); if (sword.attackDamage > 0) lore.add(ChatColor.GREEN + String.format(" %.1f Attack Damage", sword.attackDamage) + ChatColor.RESET);
if (sword.attackSpeed > 0) lore.add(ChatColor.GREEN + " " + sword.attackSpeed + " Attack Speed" + ChatColor.RESET); if (sword.attackSpeed > 0) lore.add(ChatColor.GREEN + String.format(" %.1f Attack Speed", sword.attackSpeed) + ChatColor.RESET);
meta.setLore(lore); meta.setLore(lore);
item.setItemMeta(meta); item.setItemMeta(meta);
@@ -163,6 +167,7 @@ public abstract class GenericGearSet implements HasRecipes {
meta.setDisplayName(helmet.name); meta.setDisplayName(helmet.name);
meta.setLore(new ArrayList<>(List.of(helmet.lore))); meta.setLore(new ArrayList<>(List.of(helmet.lore)));
meta.addAttributeModifier(Attribute.ARMOR, new AttributeModifier( meta.addAttributeModifier(Attribute.ARMOR, new AttributeModifier(
UUID.randomUUID(), UUID.randomUUID(),
"armour", "armour",
@@ -188,7 +193,11 @@ public abstract class GenericGearSet implements HasRecipes {
EquipmentSlotGroup.HEAD EquipmentSlotGroup.HEAD
)); ));
} }
if (!helmet.customModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + helmet.customModel)); if (!helmet.customItemModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + helmet.customItemModel));
EquippableComponent equippable = meta.getEquippable();
equippable.setModel(NamespacedKey.fromString("fantasysmp:" + helmet.customEquipmentModel));
equippable.setSlot(EquipmentSlot.HEAD);
meta.setEquippable(equippable);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
@@ -227,7 +236,11 @@ public abstract class GenericGearSet implements HasRecipes {
)); ));
} }
if (!chestplate.customModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + chestplate.customModel)); if (!chestplate.customItemModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + chestplate.customItemModel));
EquippableComponent equippable = meta.getEquippable();
equippable.setModel(NamespacedKey.fromString("fantasysmp:" + chestplate.customEquipmentModel));
equippable.setSlot(EquipmentSlot.CHEST);
meta.setEquippable(equippable);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
@@ -266,7 +279,12 @@ public abstract class GenericGearSet implements HasRecipes {
)); ));
} }
if (!leggings.customModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + leggings.customModel)); if (!leggings.customItemModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + leggings.customItemModel));
EquippableComponent equippable = meta.getEquippable();
equippable.setModel(NamespacedKey.fromString("fantasysmp:" + leggings.customEquipmentModel));
equippable.setSlot(EquipmentSlot.LEGS);
meta.setEquippable(equippable);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
@@ -304,42 +322,17 @@ public abstract class GenericGearSet implements HasRecipes {
)); ));
} }
if (!boots.customModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + boots.customModel)); if (!boots.customItemModel.isEmpty()) meta.setItemModel(NamespacedKey.fromString("fantasysmp:" + boots.customItemModel));
EquippableComponent equippable = meta.getEquippable();
equippable.setModel(NamespacedKey.fromString("fantasysmp:" + boots.customEquipmentModel));
equippable.setSlot(EquipmentSlot.FEET);
meta.setEquippable(equippable);
item.setItemMeta(meta); item.setItemMeta(meta);
return item; return item;
} }
} }
class ItemStats {
public double attackDamage;
public double attackSpeed;
public int durability;
public int armour;
public int armourToughness;
public double knockbackResistance ;
public String name;
public String lore;
public String customModel;
public ItemStack material;
public ItemStats() {
this.attackDamage = 0;
this.attackSpeed = 0;
this.durability = 0;
this.armour = 0;
this.armourToughness = 0;
this.knockbackResistance = 0;
this.name = "";
this.lore = "";
this.customModel = "";
this.material = new ItemStack(Material.AIR);
}
public void setMaterial(Material material) {
this.material = new ItemStack(material);
}
}
@@ -0,0 +1,36 @@
package dev.zxq5.fantasysmp.items;
import org.bukkit.Material;
import org.bukkit.inventory.ItemStack;
public class ItemStats {
public double attackDamage;
public double attackSpeed;
public int durability;
public int armour;
public int armourToughness;
public double knockbackResistance ;
public String name;
public String lore;
public String customItemModel;
public String customEquipmentModel;
public ItemStack material;
public ItemStats() {
this.attackDamage = 0;
this.attackSpeed = 0;
this.durability = 0;
this.armour = 0;
this.armourToughness = 0;
this.knockbackResistance = 0;
this.name = "";
this.lore = "";
this.customItemModel = "";
this.customEquipmentModel = "";
this.material = new ItemStack(Material.AIR);
}
public void setMaterial(Material material) {
this.material = new ItemStack(material);
}
}
@@ -1,11 +1,8 @@
package dev.zxq5.fantasysmp.items; package dev.zxq5.fantasysmp.items;
import org.bukkit.Bukkit; import dev.zxq5.fantasysmp.items.gear.*;
import org.bukkit.block.data.type.Light;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Wither;
import org.bukkit.event.EventHandler;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
@@ -36,7 +33,12 @@ public class Items implements CommandExecutor {
CommandExecutor handler; CommandExecutor handler;
switch (args[0]) { switch (args[0]) {
case "witherite" -> handler = new Witherite(); case "witherite" -> handler = new WitheriteGear();
case "lightning" -> handler = new LightningSword();
case "steven" -> handler = new StevensWrath();
case "blazing" -> handler = new BlazingGear();
case "dragon" -> handler = new DragonGear();
case "trueneth" -> handler = new TrueNetheriteGear();
default -> { return false; } default -> { return false; }
} }
@@ -46,10 +48,29 @@ public class Items implements CommandExecutor {
} }
public Items(JavaPlugin plugin) { public Items(JavaPlugin plugin) {
Witherite.init();
Lightning.init(); WitheriteGear witherite = new WitheriteGear();
getServer().getPluginManager().registerEvents(new Witherite(), plugin); witherite.registerRecipes();
getServer().getPluginManager().registerEvents(new Lightning(), plugin); witherite.registerEvents(plugin);
getServer().getPluginManager().registerEvents(new StevensWrath(), plugin);
LightningSword lightning = new LightningSword();
lightning.registerRecipes();
lightning.registerEvents(plugin);
StevensWrath stevensWrath = new StevensWrath();
stevensWrath.registerRecipes();
stevensWrath.registerEvents(plugin);
BlazingGear blazing = new BlazingGear();
blazing.registerRecipes();
blazing.registerEvents(plugin);
DragonGear dragon = new DragonGear();
dragon.registerRecipes();
dragon.registerEvents(plugin);
TrueNetheriteGear trueNetherite = new TrueNetheriteGear();
trueNetherite.registerRecipes();
trueNetherite.registerEvents(plugin);
} }
} }
@@ -0,0 +1,40 @@
package dev.zxq5.fantasysmp.items.food;
import dev.zxq5.fantasysmp.items.HasRecipes;
import org.bukkit.Material;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.PotionMeta;
import java.util.ArrayList;
import java.util.List;
public abstract class GenericDrink implements Listener, CommandExecutor, HasRecipes {
public String name;
public String lore;
@EventHandler
public abstract void itemCraftingHandler(org.bukkit.event.inventory.PrepareItemCraftEvent event);
@Override
public abstract boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args);
public abstract void registerRecipes();
public ItemStack getDrink() {
ItemStack item = new ItemStack(Material.POTION, 1);
PotionMeta pm = (PotionMeta) item.getItemMeta();
pm.setBasePotionType(org.bukkit.potion.PotionType.WATER);
List<String> lore = new ArrayList<>();
lore.add(this.lore);
pm.setLore(lore);
pm.setDisplayName(this.name);
item.setItemMeta(pm);
return item;
}
}
@@ -0,0 +1,130 @@
package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker;
import org.bukkit.*;
import org.bukkit.command.CommandExecutor;
import org.bukkit.damage.DamageType;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.entity.SmallFireball;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.SmithingTransformRecipe;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Objects;
import static org.bukkit.Bukkit.*;
public class BlazingGear extends GenericGearSet implements Listener, CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(this.getHelmet());
player.getInventory().addItem(this.getChestplate());
player.getInventory().addItem(this.getLeggings());
player.getInventory().addItem(this.getBoots());
return true;
}
@Override
public void registerRecipes() {}
@EventHandler
public void onPlayerSetOnFire(org.bukkit.event.entity.EntityDamageEvent event) {
if (!(event.getEntity() instanceof Player player)) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getHelmet(), this.helmet.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getChestplate(), this.chestplate.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore))) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore))) return;
if (event.getDamageSource().getDamageType() == DamageType.ON_FIRE) event.setCancelled(true);
if (event.getDamageSource().getDamageType() == DamageType.IN_FIRE) event.setCancelled(true);
if (event.getDamageSource().getDamageType() == DamageType.LAVA) event.setCancelled(true);
player.setFireTicks(0);
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem(); // Get the item the player interacted with
if (!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
return;
}
if (!(LoreChecker.itemLoreContains(item, this.sword.lore))) return;
if (cooldown.contains(player)) return;
Plugin plugin = getPluginManager().getPlugin("fantasysmp");
cooldown.add(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> cooldown.remove(player), 25);
shootFireball(player);
Bukkit.getScheduler().runTaskLater(plugin, () -> shootFireball(player), 4);
Bukkit.getScheduler().runTaskLater(plugin, () -> shootFireball(player), 8);
}
@EventHandler
public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
if (!(event.getDamager() instanceof Player player)) return;
if (!(LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore))) return;
if (event.getEntity().getFireTicks() < 240) event.getEntity().setFireTicks(240);
}
public void shootFireball(Player player) {
Location location = player.getLocation();
World world = player.getWorld();
player.launchProjectile(SmallFireball.class);
player.playSound(location, Sound.ENTITY_BLAZE_SHOOT, 1.0f, 1.0f);
world.spawnParticle(Particle.FLAME, location, 1);
}
public static void init() {}
public BlazingGear() {
this.setTier4();
this.sword.name = "Blazing Sword";
this.sword.customItemModel = "blazing_sword";
this.helmet.name = "Blazing Helmet";
this.helmet.customItemModel = "blazing_helmet";
this.helmet.customEquipmentModel = "blazing";
this.chestplate.name = "Blazing Chestplate";
this.chestplate.customItemModel = "blazing_chestplate";
this.chestplate.customEquipmentModel = "blazing";
this.leggings.name = "Blazing Leggings";
this.leggings.customItemModel = "blazing_leggings";
this.leggings.customEquipmentModel = "blazing";
this.boots.name = "Blazing Boots";
this.boots.customItemModel = "blazing_boots";
this.boots.customEquipmentModel = "blazing";
this.sword.lore = "Forged from molten lava and the essence of blazes";
this.helmet.lore = "Forged from molten lava and the essence of blazes";
this.chestplate.lore = "Forged from molten lava and the essence of blazes";
this.leggings.lore = "Forged from molten lava and the essence of blazes";
this.boots.lore = "Forged from molten lava and the essence of blazes";
}
}
@@ -0,0 +1,142 @@
package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.items.ItemStats;
import dev.zxq5.fantasysmp.util.LoreChecker;
import org.bukkit.*;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeModifier;
import org.bukkit.command.CommandExecutor;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.LivingEntity;
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.player.PlayerInteractEvent;
import org.bukkit.inventory.*;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.EquippableComponent;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import static org.bukkit.Bukkit.getServer;
public class DragonGear extends GenericGearSet implements Listener, CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(this.getHelmet());
player.getInventory().addItem(this.getChestplate());
player.getInventory().addItem(this.getLeggings());
player.getInventory().addItem(this.getBoots());
return true;
}
@Override
public void registerRecipes() {}
@EventHandler
public void onEntityPotionEffectEvent(org.bukkit.event.entity.EntityPotionEffectEvent event) {
if (event.getEntity() instanceof Player player) {
if (event.getNewEffect() == null) return;
if (event.getNewEffect().getType() != PotionEffectType.LEVITATION) {
return;
}
try {
if (LoreChecker.itemLoreContains(player.getInventory().getHelmet(), this.helmet.lore)
&& LoreChecker.itemLoreContains(player.getInventory().getChestplate(), this.chestplate.lore)
&& LoreChecker.itemLoreContains(player.getInventory().getLeggings(), this.leggings.lore)
&& LoreChecker.itemLoreContains(player.getInventory().getBoots(), this.boots.lore)
) {
event.setCancelled(true);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem(); // Get the item the player interacted with
if (!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
return;
}
if (!(LoreChecker.itemLoreContains(item, this.sword.lore))) return;
if (cooldown.contains(player)) return;
Location location = player.getLocation();
Vector direction = location.getDirection();
player.setVelocity(direction.multiply(2.0));
player.playSound(location, Sound.ENTITY_ENDERMAN_TELEPORT, 1.0f, 1.0f);
World world = player.getWorld();
world.spawnParticle(Particle.PORTAL, location, 1);
cooldown.add(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(
Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("fantasysmp")),
() -> cooldown.remove(player),
25
);
}
@Override
public ItemStack getHelmet() {
// helmet.setMaterial(Material.DRAGON_HEAD);
return super.getHelmet();
}
@Override
public ItemStack getChestplate() {
chestplate.setMaterial(Material.ELYTRA);
ItemStack item = super.getChestplate();
item.addUnsafeEnchantment(Enchantment.PROTECTION, 4);
return item;
}
public static void init() {}
public DragonGear() {
this.setTier5();
this.sword.name = "Dragon Sword";
this.sword.customItemModel = "dragon_sword";
this.helmet.name = "Dragon Helmet";
this.helmet.customItemModel = "dragon_helmet";
this.helmet.customEquipmentModel = "dragon";
this.chestplate.name = "Dragon Chestplate";
this.chestplate.customItemModel = "dragon_chestplate";
this.chestplate.customEquipmentModel = "dragon";
this.leggings.name = "Dragon Leggings";
this.leggings.customItemModel = "dragon_leggings";
this.leggings.customEquipmentModel = "dragon";
this.boots.name = "Dragon Boots";
this.boots.customItemModel = "dragon_boots";
this.boots.customEquipmentModel = "dragon";
this.sword.lore = "A blade forged from dragon scales and chorus fruit";
this.helmet.lore = "Forged from dragon scales and chorus fruit";
this.chestplate.lore = "Forged from dragon scales and chorus fruit";
this.leggings.lore = "Forged from dragon scales and chorus fruit";
this.boots.lore = "Forged from dragon scales and chorus fruit";
}
}
@@ -1,38 +1,27 @@
package dev.zxq5.fantasysmp.items; package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker; import dev.zxq5.fantasysmp.util.LoreChecker;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.NamespacedKey; import org.bukkit.NamespacedKey;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.LightningStrike; import org.bukkit.entity.*;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
import java.util.List;
import static org.bukkit.Bukkit.broadcastMessage;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
public class Lightning extends GenericGearSet implements Listener, CommandExecutor { public class LightningSword extends GenericGearSet implements Listener, CommandExecutor {
@Override @Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) { public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
if (!(args[0].equals("lightning"))) {
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(new Lightning().getSword());
return true; return true;
} }
@@ -77,7 +66,6 @@ public class Lightning extends GenericGearSet implements Listener, CommandExecut
@EventHandler @EventHandler
public void onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event) { public void onEntityDamage(org.bukkit.event.entity.EntityDamageEvent event) {
if (event.getEntity() instanceof Player player) { if (event.getEntity() instanceof Player player) {
if (!(event if (!(event
.getDamageSource() .getDamageSource()
.getDamageType() .getDamageType()
@@ -88,16 +76,30 @@ public class Lightning extends GenericGearSet implements Listener, CommandExecut
if (LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore)) { if (LoreChecker.itemLoreContains(player.getInventory().getItemInMainHand(), this.sword.lore)) {
event.setCancelled(true); event.setCancelled(true);
return;
}
}
}
@EventHandler
public void onEntityDeath(org.bukkit.event.entity.EntityDeathEvent event) {
if (event.getEntity() instanceof Mob mob) {
if (
event.getDamageSource().getDamageType().getKey().toString().equals("minecraft:lightning_bolt")
|| event.getDamageSource().getDamageType().getKey().toString().equals("minecraft:on_fire")
) {
Entity e = event.getEntity();
((ExperienceOrb) e.getLocation().getWorld().spawn(e.getLocation(), ExperienceOrb.class)).setExperience(10);
} }
} }
} }
public static void init() {} public static void init() {}
public Lightning() { public LightningSword() {
this.setTier5(); this.setTier5();
this.sword.name = "Lightning Sword"; this.sword.name = "Lightning Sword";
this.sword.customModel = "lightning_sword"; this.sword.customItemModel = "lightning_sword";
this.sword.lore = "All who oppose shall be smitten."; this.sword.lore = "All who oppose shall be smitten.";
} }
} }
@@ -1,43 +1,26 @@
package dev.zxq5.fantasysmp.items; package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker; import dev.zxq5.fantasysmp.util.LoreChecker;
import org.bukkit.*; import org.bukkit.*;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.LightningStrike;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.SmithingTransformRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.potion.PotionEffect;
import java.util.List;
import static org.bukkit.Bukkit.broadcastMessage;
import static org.bukkit.Bukkit.getServer;
public class StevensWrath extends GenericGearSet implements Listener, CommandExecutor { public class StevensWrath extends GenericGearSet implements Listener, CommandExecutor {
@Override @Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) { public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
if (!(args[0].equals("wrath"))) {
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(new StevensWrath().getSword());
return true; return true;
} }
@EventHandler @EventHandler
public void onCraft(org.bukkit.event.inventory.PrepareItemCraftEvent event) { public void onCraft(org.bukkit.event.inventory.PrepareItemCraftEvent event) {
if (!event.getInventory().contains(Material.NETHERITE_BLOCK)) return; if (!event.getInventory().contains(Material.NETHERITE_BLOCK)) return;
if (!event.getInventory().contains(new Lightning().getSword())) return; if (!event.getInventory().contains(new LightningSword().getSword())) return;
event.getInventory().setResult(new StevensWrath().getSword()); event.getInventory().setResult(new StevensWrath().getSword());
} }
@@ -89,7 +72,7 @@ public class StevensWrath extends GenericGearSet implements Listener, CommandExe
public StevensWrath() { public StevensWrath() {
this.setTier6(); this.setTier6();
this.sword.name = ChatColor.LIGHT_PURPLE + "Stevens Wrath" + ChatColor.RESET; this.sword.name = ChatColor.LIGHT_PURPLE + "Stevens Wrath" + ChatColor.RESET;
this.sword.customModel = "stevens_wrath"; this.sword.customItemModel = "stevens_wrath";
this.sword.lore = ChatColor.LIGHT_PURPLE + "All who oppose the mighty Steven shall face his wrath of lightning."; this.sword.lore = ChatColor.LIGHT_PURPLE + "All who oppose the mighty Steven shall face his wrath of lightning.";
} }
} }
@@ -0,0 +1,22 @@
package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import org.bukkit.command.CommandExecutor;
import org.bukkit.event.Listener;
public class TrueNetheriteGear extends GenericGearSet implements CommandExecutor, Listener {
@Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
return false;
}
@Override
public void registerRecipes() {}
public TrueNetheriteGear() {
this.setTier6();
this.sword.name = "True Netherite Sword";
this.sword.customItemModel = "true_netherite_sword";
this.sword.lore = "Destruction awaits.";
}
}
@@ -1,38 +1,38 @@
package dev.zxq5.fantasysmp.items; package dev.zxq5.fantasysmp.items.gear;
import dev.zxq5.fantasysmp.items.GenericGearSet;
import dev.zxq5.fantasysmp.util.LoreChecker; import dev.zxq5.fantasysmp.util.LoreChecker;
import org.bukkit.Material; import org.bukkit.*;
import org.bukkit.NamespacedKey;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.WitherSkull;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.RecipeChoice; import org.bukkit.inventory.RecipeChoice;
import org.bukkit.inventory.SmithingTransformRecipe; import org.bukkit.inventory.SmithingTransformRecipe;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.inventory.meta.components.CustomModelDataComponent;
import org.bukkit.inventory.meta.components.EquippableComponent;
import org.bukkit.potion.PotionEffect; import org.bukkit.potion.PotionEffect;
import java.util.ArrayList;
import java.util.Objects;
import static org.bukkit.Bukkit.getServer; import static org.bukkit.Bukkit.getServer;
public class Witherite extends GenericGearSet implements Listener, CommandExecutor { public class WitheriteGear extends GenericGearSet implements Listener, CommandExecutor {
private ArrayList<Player> cooldown = new ArrayList<>();
@Override @Override
public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) { public boolean onCommand(org.bukkit.command.CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
if (!(args[0].equals("witherite"))) {
return false;
}
Player player = (Player) sender; Player player = (Player) sender;
player.getInventory().addItem(this.getSword());
player.getInventory().addItem(new Witherite().getSword()); player.getInventory().addItem(this.getHelmet());
player.getInventory().addItem(new Witherite().getHelmet()); player.getInventory().addItem(this.getChestplate());
player.getInventory().addItem(new Witherite().getChestplate()); player.getInventory().addItem(this.getLeggings());
player.getInventory().addItem(new Witherite().getLeggings()); player.getInventory().addItem(this.getBoots());
player.getInventory().addItem(new Witherite().getBoots());
return true; return true;
} }
@@ -91,6 +91,32 @@ public class Witherite extends GenericGearSet implements Listener, CommandExecut
} }
@EventHandler
public void onPlayerInteract(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = event.getItem(); // Get the item the player interacted with
if (!(event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK)) {
return;
}
if (!(LoreChecker.itemLoreContains(item, this.sword.lore))) return;
if (cooldown.contains(player)) return;
Location location = player.getLocation();
player.launchProjectile(WitherSkull.class);
player.playSound(location, Sound.ENTITY_WITHER_SHOOT, 1.0f, 1.0f);
World world = player.getWorld();
world.spawnParticle(Particle.SOUL_FIRE_FLAME, location, 1);
cooldown.add(player);
Bukkit.getScheduler().scheduleSyncDelayedTask(
Objects.requireNonNull(Bukkit.getPluginManager().getPlugin("fantasysmp")),
() -> cooldown.remove(player),
25
);
}
@EventHandler @EventHandler
public void onEntityPotionEffectEvent(org.bukkit.event.entity.EntityPotionEffectEvent event) { public void onEntityPotionEffectEvent(org.bukkit.event.entity.EntityPotionEffectEvent event) {
if (event.getEntity() instanceof Player player) { if (event.getEntity() instanceof Player player) {
@@ -116,18 +142,26 @@ public class Witherite extends GenericGearSet implements Listener, CommandExecut
public static void init() {} public static void init() {}
public Witherite() { public WitheriteGear() {
this.setTier5(); this.setTier5();
this.sword.name = "Witherite Sword"; this.sword.name = "Witherite Sword";
this.sword.customModel = "witherite_sword"; this.sword.customItemModel = "witherite_sword";
this.helmet.name = "Witherite Helmet"; this.helmet.name = "Witherite Helmet";
this.helmet.customModel = "witherite_helmet"; this.helmet.customItemModel = "witherite_helmet";
this.helmet.customEquipmentModel = "witherite";
this.chestplate.name = "Witherite Chestplate"; this.chestplate.name = "Witherite Chestplate";
this.chestplate.customModel = "witherite_chestplate"; this.chestplate.customItemModel = "witherite_chestplate";
this.chestplate.customEquipmentModel = "witherite";
this.leggings.name = "Witherite Leggings"; this.leggings.name = "Witherite Leggings";
this.leggings.customModel = "witherite_leggings"; this.leggings.customItemModel = "witherite_leggings";
this.leggings.customEquipmentModel = "witherite";
this.boots.name = "Witherite Boots"; this.boots.name = "Witherite Boots";
this.boots.customModel = "witherite_boots"; this.boots.customItemModel = "witherite_boots";
this.boots.customEquipmentModel = "witherite";
this.sword.lore = "A sword forged with the skulls of wither skeletons."; this.sword.lore = "A sword forged with the skulls of wither skeletons.";
this.helmet.lore = "A helmet forged with the skulls of wither skeletons."; this.helmet.lore = "A helmet forged with the skulls of wither skeletons.";
+11 -7
View File
@@ -39,12 +39,6 @@ commands:
permissions: permissions:
fantasysmp.admin:
description: Manage plugin
default: op
children:
fantasysmp.*: true
fantasysmp.items: fantasysmp.items:
description: create custom items from plugin description: create custom items from plugin
default: false default: false
@@ -59,4 +53,14 @@ permissions:
fantasysmp.home: fantasysmp.home:
description: commands for teleporting home description: commands for teleporting home
default: true default: true
fantasysmp.admin:
description: Manage plugin
default: op
children:
fantasysmp.items: true
fantasysmp.manage_warps: true
fantasysmp.home: true
fantasysmp.warps: true