implimented Newts proprietary PDC control system to add plugin side permissions and settings

added treasure fountain (W.I.P) mechanic
This commit is contained in:
newt_00 2025-02-28 12:22:57 -05:00
parent fa38a0f2d2
commit b472f2f28f
80 changed files with 579 additions and 104 deletions

Binary file not shown.

Binary file not shown.

View File

@ -3,7 +3,7 @@ plugins {
}
group = 'com.newt-tech'
version = '1.12-RELEASE'
version = '1.13-RELEASE'
repositories {
mavenCentral()

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -94,44 +94,69 @@ shop:
quantity: 10
display_name: "Obsidian"
available: true
utilities:
utils:
items:
ASK:
ask:
material: KNOWLEDGE_BOOK
price: 450000
price: 400000
quantity: 1
display_name: "Anchor Shield Kit"
available: true
gravity_gauntlet:
material: KNOWLEDGE_BOOK
price: 200000
quantity: 1
display_name: "Gravity Gauntlet"
available: true
levitation_wand:
material: KNOWLEDGE_BOOK
price: 1000000
quantity: 1
display_name: "Levitation Wand"
available: true
launch_stick:
material: KNOWLEDGE_BOOK
price: 1234567
quantity: 1
display_name: "Launch Stick"
available: true
rapid_fire_bow:
material: KNOWLEDGE_BOOK
price: 9000000
quantity: 1
display_name: "Rapid Fire Bow"
available: true
illumination_wand:
material: KNOWLEDGE_BOOK
price: 9000000
quantity: 1
display_name: "Illumination Wand"
available: true
tool_id: 1
utils1:
items:
gravity_gauntlet:
material: KNOWLEDGE_BOOK
price: 1500000
quantity: 1
display_name: "Gravity Gauntlet"
available: true
tool_id: 2
utils2:
items:
levitation_wand:
material: KNOWLEDGE_BOOK
price: 600000
quantity: 1
display_name: "Levitation Wand"
available: true
tool_id: 3
utils3:
items:
launch_stick:
material: KNOWLEDGE_BOOK
price: 2000000
quantity: 1
display_name: "Launch Stick"
available: true
tool_id: 4
utils4:
items:
rapid_fire_bow:
material: KNOWLEDGE_BOOK
price: 1000000
quantity: 1
display_name: "Rapid Fire Bow"
available: false
tool_id: 5
utils5:
items:
illumination_wand:
material: KNOWLEDGE_BOOK
price: 500000
quantity: 1
display_name: "Illumination Wand"
available: true
tool_id: 6
utils6:
items:
maceofstorms:
material: KNOWLEDGE_BOOK
price: 600000
quantity: 1
display_name: "Mace Of Storms"
available: true
tool_id: 7
poor: "you're too poor for that, get gooder..."
inventory_full: "you got too much clutter, cant fit your purchase into that mess..."
pagination:

View File

@ -1,5 +1,5 @@
name: CoswayUtil
version: '1.12-RELEASE'
version: '1.13-RELEASE'
main: CoswayUtil.CoswayUtil
description: "utility plugin for Cosway servers, a yescraft network server"
api-version: '1.21'
@ -45,4 +45,23 @@ commands:
repair:
description: Repairs the held tool to full durability.
usage: /repair
permission: coswayutil.repair
permission: coswayutil.repair
getmace:
description: get the mace of storms
usage: /getmace
permission: CoswayUtil.storm_mace
tone:
description: play the tone
usage: /tone
permission: CoswayUtil.tone
treasurefountain:
description: give player a treasure fountain item
usage: /treasurefountain
permission: CoswayUtil.treasurefountain
coswaysetpdc:
description: set a persistent data container for a desired player
usage: /coswaysetpdc <key> <value>
permission: CoswayUtil.admin
coswaygetpdc:
description: get set value of a players persistent data container key
usage: /coswaygetpdc <player> <key>

View File

@ -10,6 +10,7 @@ import org.bukkit.block.data.type.LightningRod;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.ArmorStand;
import org.bukkit.entity.Monster;
import org.bukkit.event.EventHandler;
@ -26,6 +27,7 @@ import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
@ -56,7 +58,7 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
Bukkit.getPluginManager().registerEvents(new AnchorShield(), this);
// Start the detection loop when the plugin is enabled
new AnchorShield().startDetectionLoop();
registration("Anchor Shield");
registration("Anchor Shield",1);
new BukkitRunnable() {
@Override
public void run() {
@ -79,17 +81,17 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
}
}
}.runTaskTimer(this, 0, 2); // Runs every 10 ticks (0.5 seconds)
registration("Wither Contract");
registration("Totem Tweaks");
registration("Wither Contract",3);
registration("Totem Tweaks",1);
// Register Gravity Gauntlet
new GravityGauntlet(this);
registration("Gravity Gauntlet");
registration("Gravity Gauntlet",2);
// Register TotemShield
new TotemShield(this);
registration("Totem Shield");
registration("Totem Shield",3);
// Register the ShadowStep listener
new MobLevitationWand(this);
registration("Levitation Wand");
registration("Levitation Wand",2);
if (!setupEconomy()) {
getLogger().severe("Vault not found or no economy provider found.");
getServer().getPluginManager().disablePlugin(this);
@ -98,9 +100,9 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
new BlockShop(this, economy).register();
new BlockShop(this, economy);
registration("BlockShop");
registration("BlockShop",3);
new RapidFireBow(this);
registration("Rapid Fire Bow");
registration("Rapid Fire Bow",2);
getServer().getPluginManager().registerEvents(new RapidFireBow(this), this);
getServer().getPluginManager().registerEvents(new ShadowStep(this), this);
//register levitation wand
@ -114,12 +116,20 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
this.getCommand("getwand").setExecutor(new GiveWandCommand());
getServer().getPluginManager().registerEvents(new LaunchStick(this), this);
new FireflySimulator(this);
registration("FireFlies");
registration("FireFlies",3);
getCommand("unbreakable").setExecutor(new UnbreakableCommand());
registration("Unbreakable Command");
registration("Unbreakable Command",1);
getCommand("repair").setExecutor(new RepairCommand());
registration("Repair Command");
//getServer().getPluginManager().registerEvents(new FireflySimulator(this), this);
registration("Repair Command",1);
new MaceOfStorms(this);
getServer().getPluginManager().registerEvents(new MaceOfStorms(this), this);
getCommand("getmace").setExecutor(new MaceOfStormsCommand());
registration("Mace Of Storms",2);
NoteStudio.init(this);
registration("Note Studio",1);
new TreasureFountain(this);
getServer().getPluginManager().registerEvents(new TreasureFountain(this), this);
registration("Treasure Fountain",3);
new BukkitRunnable() {
@Override
@ -141,16 +151,22 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Launch Stick")) {
player.getInventory().addItem(LaunchStick.createLaunchStick());
}
if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Mace Of Storms")) {
ItemStack gauntlet = new ItemStack(Material.MACE); // You can change this to any item you prefer
ItemMeta meta = gauntlet.getItemMeta();
if (meta != null) {
meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Mace of Storms");
meta.setLore(Collections.singletonList(ChatColor.GOLD + "Right Click to Smite the target"+ChatColor.GRAY+"\n range: 20 blocks"));
meta.addEnchant(Enchantment.MENDING,1,true);
meta.setUnbreakable(true);
gauntlet.setItemMeta(meta);
}
player.getInventory().addItem(gauntlet);
player.sendMessage(ChatColor.GREEN + "You have been given the Mace Of Storms!");
}
if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Anchor Shield Kit")) {
// Create a chest item
giveAnchorKit(player);
/* ItemStack anchor = new ItemStack(Material.RESPAWN_ANCHOR, 1);
ItemStack rod = new ItemStack(Material.LIGHTNING_ROD, 1);
ItemStack core = new ItemStack(Material.HEAVY_CORE, 1);
ItemStack charge = new ItemStack(Material.GLOWSTONE,4);
// Give the chest and items to the player
player.getInventory().addItem(anchor,rod,core,charge);*/
}
if(removeCustomKnowledgeBook(player,ChatColor.GREEN+"Levitation Wand")) {
player.getInventory().addItem(MobLevitationWand.createWand());
@ -165,14 +181,21 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
}
}.runTaskTimer(this,0,2);
new IlluminationWand(this);
registration("Illumination Wand");
registration("Illumination Wand",2);
new BlackholeEffect(this);
registration("BlackHole (W.I.P.)");
registration("BlackHole (W.I.P.)",1);
}
public void registration(String msg) {
Bukkit.broadcastMessage(ColorKey("&7[&eRegistrations&7] &aUtility Registered: &6"+msg));
public void registration(String msg, int type) {
if(type == 1) {
Bukkit.broadcastMessage(ColorKey("&7[&eRegistrations&7] &aUtility Registered: &6" + msg));
} else if(type == 2) {
Bukkit.broadcastMessage(ColorKey("&7[&eRegistrations&7] &bTool Registered: &6" + msg));
} else if(type == 3) {
Bukkit.broadcastMessage(ColorKey("&7[&eRegistrations&7] &dMechanic Registered: &6" + msg));
}
}
private boolean setupEconomy() {
// Setup Vault economy (make sure it's enabled and available)
@ -197,15 +220,21 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
if (cmd.getName().equalsIgnoreCase("launchstick") && sender instanceof Player player) {
player.getInventory().addItem(LaunchStick.createLaunchStick());
}
if (cmd.getName().equalsIgnoreCase("blockshop") && sender instanceof Player player) {
if (cmd.getName().equalsIgnoreCase("treasurefountain") && sender instanceof Player player) {
player.getInventory().addItem(TreasureFountain.getTreasureFountainItem());
}
if (cmd.getName().equalsIgnoreCase("blockshop") && sender instanceof Player player) {
BlockShop.openShop(player,1);
}
if (cmd.getName().equalsIgnoreCase("shopbook") && sender instanceof Player player) {
player.getInventory().addItem(BlockShop.createShopItem());
}
if (cmd.getName().equalsIgnoreCase("Illumination Wand") && sender instanceof Player player) {
if (cmd.getName().equalsIgnoreCase("IlluminationWand") && sender instanceof Player player) {
player.getInventory().addItem(IlluminationWand.getIlluminationWand());
}
if (cmd.getName().equalsIgnoreCase("tone") && sender instanceof Player player) {
NoteStudio.playNoteBlockSong(player);
}
if (cmd.getName().equalsIgnoreCase("throw") && sender instanceof Player player) {
Player Target = getNearestPlayer(player,10);
if(Target == null) {
@ -219,10 +248,48 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
if (cmd.getName().equalsIgnoreCase("rapidbow") && sender instanceof Player player) {
player.getInventory().addItem(RapidFireBow.createRapidFireBow());
}
if (cmd.getName().equalsIgnoreCase("coswaysetpdc") && sender instanceof Player player) {
if(args.length < 3) {
return false;
} else {
Player target = getServer().getPlayer(args[0]);
assert target != null;
setpdc(target,args[1],args[2]);
String msg = getpdc(target,args[1]);
if(msg == null) {
msg = "&cNULL";
}
returnMsg(player,"&aSet "+args[1]+" from "+msg+" to "+args[2]+" for "+target.getName());
}
}
if (cmd.getName().equalsIgnoreCase("coswaygetpdc") && sender instanceof Player player) {
if(args.length < 2) {
return false;
} else {
Player target = getServer().getPlayer(args[0]);
assert target != null;
String msg = getpdc(target,args[1]);
if(msg == null) {
returnMsg(player,"&cNo data found for &7[&6"+target.getName()+"&7]-&e"+args[1]);
} else {
returnMsg(player, "PDC data: &7[&6"+target+"&7]-&e"+args[1]+"="+getpdc(target, args[1]));
}
}
}
return true;
}
CoswayUtil plugin = this;
public void setpdc(Player player, String key, String value) {
NamespacedKey thiskey = new NamespacedKey(plugin, key);
assert player != null;
player.getPersistentDataContainer().set(thiskey, PersistentDataType.STRING, value);
}
public String getpdc(Player player, String key) {
NamespacedKey thiskey = new NamespacedKey(plugin, key);
String value = player.getPersistentDataContainer().get(thiskey, PersistentDataType.STRING);
return value;
}
public String prefix() {
return ColorKey("[&7Cosway Utility&r] ");
}

View File

@ -1,11 +1,11 @@
package CoswayUtil;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.*;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Objects;
import java.util.Random;
public class FireflySimulator {
@ -19,19 +19,28 @@ public class FireflySimulator {
startSimulation();
}
public String getpdc(Player player, String key) {
NamespacedKey thiskey = new NamespacedKey(plugin, key);
String value = player.getPersistentDataContainer().get(thiskey, PersistentDataType.STRING);
return value;
}
public void startSimulation() {
new BukkitRunnable() {
@Override
public void run() {
for (Player player : Bukkit.getOnlinePlayers()) {
if (player.getWorld().getTime() == 13000) { // Only at night
player.stopAllSounds();
player.playSound(player.getLocation().clone().add(0,100,0), Sound.MUSIC_DISC_MALL,10,1);
if(Objects.equals(getpdc(player,"music"), true)) {
player.stopAllSounds();
player.playSound(player.getLocation().clone().add(0, 100, 0), Sound.MUSIC_DISC_MALL, 10, 1);
}
statMsg(player,"&6time for bed");
}
if (player.getWorld().getTime() == 1137) { // Only at night
player.stopAllSounds();
player.playSound(player.getLocation().clone().add(0,100,0), Sound.MUSIC_DISC_OTHERSIDE,10,1);
if(Objects.equals(getpdc(player,"music"), true)) {
player.stopAllSounds();
player.playSound(player.getLocation().clone().add(0, 100, 0), Sound.MUSIC_DISC_OTHERSIDE, 10, 1);
}
statMsg(player,"&eRize and Shine!");
}
}

View File

@ -0,0 +1,102 @@
package CoswayUtil;
import org.bukkit.*;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import CoswayUtil.CoswayUtil;
import java.util.List;
public class MaceOfStorms implements Listener {
private final CoswayUtil plugin;
public MaceOfStorms(CoswayUtil plugin) {
this.plugin = plugin;
}
@EventHandler
public void onMaceUse(PlayerInteractEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
if (!isMaceOfStorms(item)) {
return;
}
LivingEntity target = getTargetEntity(player, 20);
if (target == null) {
player.sendMessage(ChatColor.RED + "You are not looking at a valid target!");
return;
}
player.getWorld().playSound(player.getLocation(), Sound.ENTITY_LIGHTNING_BOLT_THUNDER, 1, 1);
// Shoot particles from player to target
shootParticleBeam(player.getLocation().add(0, 1.5, 0), target.getLocation());
// Circle the target and strike with lightning
new BukkitRunnable() {
int ticks = 0;
@Override
public void run() {
if (ticks >= 40) { // Runs for 2 seconds
target.getWorld().strikeLightning(target.getLocation());
cancel();
return;
}
spawnCirclingParticles(target.getLocation(), ticks);
ticks += 2;
}
}.runTaskTimer(plugin, 0, 2);
}
private boolean isMaceOfStorms(ItemStack item) {
if (item == null || item.getType() != Material.MACE) { // Mace-like weapon
return false;
}
ItemMeta meta = item.getItemMeta();
return meta != null && meta.hasDisplayName() && meta.getDisplayName().equalsIgnoreCase(ChatColor.LIGHT_PURPLE+"Mace of Storms");
}
private LivingEntity getTargetEntity(Player player, double range) {
List<Entity> nearbyEntities = player.getNearbyEntities(range, range, range);
for (Entity entity : nearbyEntities) {
if (entity instanceof LivingEntity && entity != player) {
Vector direction = player.getLocation().getDirection();
Vector entityDirection = entity.getLocation().toVector().subtract(player.getLocation().toVector()).normalize();
if (direction.dot(entityDirection) > 0.98) { // Check if the entity is in line of sight
return (LivingEntity) entity;
}
}
}
return null;
}
private void shootParticleBeam(Location from, Location to) {
Vector direction = to.toVector().subtract(from.toVector()).normalize();
double distance = from.distance(to);
for (double i = 0; i < distance; i += 0.5) {
Location point = from.clone().add(direction.clone().multiply(i));
from.getWorld().spawnParticle(Particle.ELECTRIC_SPARK, point, 2, 0.1, 0.1, 0.1, 0);
}
}
private void spawnCirclingParticles(Location location, int time) {
double angle = Math.toRadians(time * 9); // Adjust rotation speed
for (int i = 0; i < 6; i++) { // 6 particles around the entity
double offsetX = Math.cos(angle + (i * Math.PI / 3)) * 1.5;
double offsetZ = Math.sin(angle + (i * Math.PI / 3)) * 1.5;
location.getWorld().spawnParticle(Particle.CRIT, location.clone().add(offsetX, 0.5, offsetZ), 1, 0, 0, 0, 0);
}
}
}

View File

@ -0,0 +1,39 @@
package CoswayUtil;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Collections;
public class MaceOfStormsCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (sender instanceof Player) {
Player player = (Player) sender;
ItemStack gauntlet = new ItemStack(Material.MACE); // You can change this to any item you prefer
ItemMeta meta = gauntlet.getItemMeta();
if (meta != null) {
meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Mace of Storms");
meta.setLore(Collections.singletonList(ChatColor.GOLD + "Right Click to Smite the target"+ChatColor.GRAY+"\n range: 20 blocks"));
meta.addEnchant(Enchantment.MENDING,1,true);
meta.setUnbreakable(true);
gauntlet.setItemMeta(meta);
}
player.getInventory().addItem(gauntlet);
player.sendMessage(ChatColor.GREEN + "You have been given the Mace Of Storms!");
} else {
sender.sendMessage(ChatColor.RED + "Only players can use this command!");
}
return true;
}
}

View File

@ -0,0 +1,48 @@
package CoswayUtil;
import org.bukkit.Instrument;
import org.bukkit.Note;
import org.bukkit.Note.Tone;
import org.bukkit.Sound;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
public class NoteStudio {
private static CoswayUtil plugin;
public static void init(CoswayUtil pluginInstance) {
plugin = pluginInstance;
}
public static void playNoteBlockSong(Player player) {
if (plugin == null) {
throw new IllegalStateException("NoteStudio has not been initialized!");
}
Note[] songNotes = {
Note.natural(0, Tone.C), Note.natural(0, Tone.E), Note.natural(0, Tone.G),
Note.natural(1, Tone.C), Note.natural(1, Tone.G), Note.natural(1, Tone.E),
Note.natural(2, Tone.C), Note.natural(2, Tone.D), Note.natural(2, Tone.E)
};
new BukkitRunnable() {
int index = 0;
@Override
public void run() {
if (index >= songNotes.length) {
cancel();
return;
}
// Play the note for the player
player.playNote(player.getLocation(), Instrument.PIANO, songNotes[index]);
// Also play a sound so everyone nearby can hear it
player.getWorld().playSound(player.getLocation(), Sound.BLOCK_NOTE_BLOCK_HARP, 1, songNotes[index].getId() / 24.0f);
index++;
}
}.runTaskTimer(plugin, 0, 10); // Plays one note every 10 ticks (0.5s)
}
}

View File

@ -0,0 +1,122 @@
package CoswayUtil;
import org.bukkit.*;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.List;
import java.util.Random;
public class TreasureFountain implements Listener {
private final CoswayUtil plugin;
private final Random random = new Random();
public TreasureFountain(CoswayUtil plugin) {
this.plugin = plugin;
}
@EventHandler
public void onUseTreasureFountain(PlayerInteractEntityEvent event) {
Player player = event.getPlayer();
ItemStack item = player.getInventory().getItemInMainHand();
Entity target = event.getRightClicked();
// Check if the item is the special "Treasure Fountain"
if (!isTreasureFountain(item)) return;
// Check if the target is a living entity (monster)
if (!(target instanceof Monster)) {
player.sendMessage(ChatColor.RED + "This item only works on monsters!");
return;
}
// Kill the target
Location loc = target.getLocation();
target.remove();
player.sendMessage(ChatColor.GOLD + "The Treasure Fountain is activated!");
// Consume the special item
if (item.getAmount() > 1) {
item.setAmount(item.getAmount() - 1);
} else {
player.getInventory().setItemInMainHand(null);
}
// Spawn the treasure cloud and items
spawnTreasureCloud(loc);
}
public static ItemStack getTreasureFountainItem() {
ItemStack treasureFountain = new ItemStack(Material.BLAZE_ROD, 1);
ItemMeta meta = treasureFountain.getItemMeta();
if (meta != null) {
meta.setDisplayName(ChatColor.LIGHT_PURPLE + "Treasure Fountain");
meta.setLore(List.of(ChatColor.GRAY + "Use this on a monster to", ChatColor.GRAY + "summon a treasure fountain!"));
treasureFountain.setItemMeta(meta);
}
return treasureFountain;
}
private boolean isTreasureFountain(ItemStack item) {
if (item == null || !item.hasItemMeta() || !item.getItemMeta().hasDisplayName()) return false;
return item.getItemMeta().getDisplayName().equals(ChatColor.LIGHT_PURPLE + "Treasure Fountain");
}
private void spawnTreasureCloud(Location loc) {
// Show particles for 3 seconds
new BukkitRunnable() {
int count = 0;
@Override
public void run() {
if (count >= 60) {
spawnTreasureItems(loc);
cancel();
return;
}
loc.getWorld().spawnParticle(Particle.CLOUD, loc, 10, 0.5, 0.5, 0.5, 0);
count++;
}
}.runTaskTimer(plugin, 0, 5);
}
private void spawnTreasureItems(Location loc) {
FileConfiguration config = plugin.getConfig();
List<String> treasureItems = config.getStringList("treasure");
if (treasureItems.isEmpty()) {
Bukkit.getLogger().warning("Treasure list is empty in config!");
return;
}
int itemCount = 10 + random.nextInt(11); // 10-20 items
for (int i = 0; i < itemCount; i++) {
String itemName = treasureItems.get(random.nextInt(treasureItems.size()));
Material material = Material.matchMaterial(itemName);
if (material == null) continue;
ItemStack treasure = new ItemStack(material, 1);
spawnFloatingItem(loc, treasure);
}
}
private void spawnFloatingItem(Location loc, ItemStack item) {
World world = loc.getWorld();
if (world == null) return;
Item droppedItem = world.dropItem(loc, item);
droppedItem.setVelocity(new org.bukkit.util.Vector(
(random.nextDouble() - 0.5) * 0.6, // Random horizontal direction
0.5 + random.nextDouble() * 0.5, // Shoot up
(random.nextDouble() - 0.5) * 0.6 // Random horizontal direction
));
droppedItem.setPickupDelay(20);
}
}

View File

@ -94,44 +94,69 @@ shop:
quantity: 10
display_name: "Obsidian"
available: true
utilities:
utils:
items:
ASK:
ask:
material: KNOWLEDGE_BOOK
price: 450000
price: 400000
quantity: 1
display_name: "Anchor Shield Kit"
available: true
gravity_gauntlet:
material: KNOWLEDGE_BOOK
price: 200000
quantity: 1
display_name: "Gravity Gauntlet"
available: true
levitation_wand:
material: KNOWLEDGE_BOOK
price: 1000000
quantity: 1
display_name: "Levitation Wand"
available: true
launch_stick:
material: KNOWLEDGE_BOOK
price: 1234567
quantity: 1
display_name: "Launch Stick"
available: true
rapid_fire_bow:
material: KNOWLEDGE_BOOK
price: 9000000
quantity: 1
display_name: "Rapid Fire Bow"
available: true
illumination_wand:
material: KNOWLEDGE_BOOK
price: 9000000
quantity: 1
display_name: "Illumination Wand"
available: true
tool_id: 1
utils1:
items:
gravity_gauntlet:
material: KNOWLEDGE_BOOK
price: 1500000
quantity: 1
display_name: "Gravity Gauntlet"
available: true
tool_id: 2
utils2:
items:
levitation_wand:
material: KNOWLEDGE_BOOK
price: 600000
quantity: 1
display_name: "Levitation Wand"
available: true
tool_id: 3
utils3:
items:
launch_stick:
material: KNOWLEDGE_BOOK
price: 2000000
quantity: 1
display_name: "Launch Stick"
available: true
tool_id: 4
utils4:
items:
rapid_fire_bow:
material: KNOWLEDGE_BOOK
price: 1000000
quantity: 1
display_name: "Rapid Fire Bow"
available: false
tool_id: 5
utils5:
items:
illumination_wand:
material: KNOWLEDGE_BOOK
price: 500000
quantity: 1
display_name: "Illumination Wand"
available: true
tool_id: 6
utils6:
items:
maceofstorms:
material: KNOWLEDGE_BOOK
price: 600000
quantity: 1
display_name: "Mace Of Storms"
available: true
tool_id: 7
poor: "you're too poor for that, get gooder..."
inventory_full: "you got too much clutter, cant fit your purchase into that mess..."
pagination:

View File

@ -45,4 +45,23 @@ commands:
repair:
description: Repairs the held tool to full durability.
usage: /repair
permission: coswayutil.repair
permission: coswayutil.repair
getmace:
description: get the mace of storms
usage: /getmace
permission: CoswayUtil.storm_mace
tone:
description: play the tone
usage: /tone
permission: CoswayUtil.tone
treasurefountain:
description: give player a treasure fountain item
usage: /treasurefountain
permission: CoswayUtil.treasurefountain
coswaysetpdc:
description: set a persistent data container for a desired player
usage: /coswaysetpdc <key> <value>
permission: CoswayUtil.admin
coswaygetpdc:
description: get set value of a players persistent data container key
usage: /coswaygetpdc <player> <key>