began working on blockshop mechanic
This commit is contained in:
parent
d311394be0
commit
5422c9cbe3
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -26,5 +26,15 @@
|
|||||||
<option name="name" value="sonatype" />
|
<option name="name" value="sonatype" />
|
||||||
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
<option name="url" value="https://oss.sonatype.org/content/groups/public/" />
|
||||||
</remote-repository>
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="maven" />
|
||||||
|
<option name="name" value="maven" />
|
||||||
|
<option name="url" value="https://jitpack.io" />
|
||||||
|
</remote-repository>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
@ -3,7 +3,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.newt-tech'
|
group = 'com.newt-tech'
|
||||||
version = '1.10-RELEASE'
|
version = '1.11-RELEASE'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
@ -15,10 +15,14 @@ repositories {
|
|||||||
name = "sonatype"
|
name = "sonatype"
|
||||||
url = "https://oss.sonatype.org/content/groups/public/"
|
url = "https://oss.sonatype.org/content/groups/public/"
|
||||||
}
|
}
|
||||||
|
maven { url 'https://jitpack.io' }
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.4-R0.1-SNAPSHOT")
|
||||||
|
compileOnly("com.github.MilkBowl:VaultAPI:1.7") {
|
||||||
|
exclude group: 'org.bukkit', module: 'bukkit' // Exclude bukkit dependency
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
def targetJavaVersion = 21
|
def targetJavaVersion = 21
|
||||||
|
BIN
build/classes/java/main/CoswayUtil/BlockShop$1.class
Normal file
BIN
build/classes/java/main/CoswayUtil/BlockShop$1.class
Normal file
Binary file not shown.
BIN
build/classes/java/main/CoswayUtil/BlockShop.class
Normal file
BIN
build/classes/java/main/CoswayUtil/BlockShop.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
build/classes/java/main/CoswayUtil/RapidFireBow$1.class
Normal file
BIN
build/classes/java/main/CoswayUtil/RapidFireBow$1.class
Normal file
Binary file not shown.
BIN
build/classes/java/main/CoswayUtil/RapidFireBow.class
Normal file
BIN
build/classes/java/main/CoswayUtil/RapidFireBow.class
Normal file
Binary file not shown.
Binary file not shown.
34
build/resources/main/config.yml
Normal file
34
build/resources/main/config.yml
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
# config.yml
|
||||||
|
|
||||||
|
shop:
|
||||||
|
categories:
|
||||||
|
- name: "Building Blocks"
|
||||||
|
items:
|
||||||
|
- material: "STONE"
|
||||||
|
price: 1
|
||||||
|
display_name: "Stone"
|
||||||
|
- material: "WOOD"
|
||||||
|
price: 2
|
||||||
|
display_name: "Wood"
|
||||||
|
- material: "BRICK"
|
||||||
|
price: 3
|
||||||
|
display_name: "Brick"
|
||||||
|
- name: "Decorative Blocks"
|
||||||
|
items:
|
||||||
|
- material: "LANTERN"
|
||||||
|
price: 5
|
||||||
|
display_name: "Lantern"
|
||||||
|
- material: "PAINTING"
|
||||||
|
price: 10
|
||||||
|
display_name: "Painting"
|
||||||
|
- name: "Tools"
|
||||||
|
items:
|
||||||
|
- material: "WOODEN_SWORD"
|
||||||
|
price: 10
|
||||||
|
display_name: "Wooden Sword"
|
||||||
|
- material: "IRON_SWORD"
|
||||||
|
price: 20
|
||||||
|
display_name: "Iron Sword"
|
||||||
|
|
||||||
|
pagination:
|
||||||
|
max_items_per_page: 45 # Max items to display per page
|
@ -1,9 +1,10 @@
|
|||||||
name: CoswayUtil
|
name: CoswayUtil
|
||||||
version: '1.10-RELEASE'
|
version: '1.11-RELEASE'
|
||||||
main: CoswayUtil.CoswayUtil
|
main: CoswayUtil.CoswayUtil
|
||||||
description: "utility plugin for Cosway servers, a yescraft network server"
|
description: "utility plugin for Cosway servers, a yescraft network server"
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
author: "Newt_00"
|
author: "Newt_00"
|
||||||
|
depend: [Vault]
|
||||||
website: "ycs.Newt-Tech.com"
|
website: "ycs.Newt-Tech.com"
|
||||||
commands:
|
commands:
|
||||||
scale:
|
scale:
|
||||||
@ -22,6 +23,18 @@ commands:
|
|||||||
usage: "/getwand"
|
usage: "/getwand"
|
||||||
permission: CoswayUtil.wand
|
permission: CoswayUtil.wand
|
||||||
launchstick:
|
launchstick:
|
||||||
description: give player a stick to use for launching themselves
|
description: "give player a stick to use for launching themselves"
|
||||||
usage: /launchstick
|
usage: "/launchstick"
|
||||||
permission: CoswayUtil.launchStick
|
permission: CoswayUtil.launchStick
|
||||||
|
rapidbow:
|
||||||
|
description: "gives player a rapid fire bow"
|
||||||
|
usage: "/rapidbow"
|
||||||
|
permission: CoswayUtil.rapidBow
|
||||||
|
shopbook:
|
||||||
|
description: "gives player shop book"
|
||||||
|
usage: "/shopbook"
|
||||||
|
permission: CoswayUtil.shop
|
||||||
|
blockshop:
|
||||||
|
description: "opens block shop"
|
||||||
|
usage: "/blockshop"
|
||||||
|
permission: CoswayUtil.shop
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,4 +1,166 @@
|
|||||||
package CoswayUtil;
|
package CoswayUtil;
|
||||||
|
|
||||||
public class shop {
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
import org.bukkit.*;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.*;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.player.*;
|
||||||
|
import org.bukkit.inventory.*;
|
||||||
|
import org.bukkit.inventory.meta.*;
|
||||||
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class BlockShop implements Listener {
|
||||||
|
private JavaPlugin plugin;
|
||||||
|
private final Economy economy;
|
||||||
|
private static FileConfiguration config;
|
||||||
|
|
||||||
|
private final NamespacedKey shopItemKey = new NamespacedKey("coswayutil", "block_shop_access");
|
||||||
|
|
||||||
|
public BlockShop(JavaPlugin plugin, Economy economy) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.economy = economy;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Method to create the special book (or other item) to open the shop
|
||||||
|
public static ItemStack createShopItem() {
|
||||||
|
ItemStack item = new ItemStack(Material.WRITTEN_BOOK); // Or use any other item
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName(ChatColor.GREEN + "Block Shop Access");
|
||||||
|
meta.setLore(Collections.singletonList(ChatColor.GOLD + "Right click to open the shop."));
|
||||||
|
meta.getPersistentDataContainer().set(new NamespacedKey("coswayutil", "block_shop_access"), PersistentDataType.STRING, "true");
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void ShopGUI(JavaPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
config = plugin.getConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void openShop(Player player, int page) {
|
||||||
|
Inventory shopInventory = Bukkit.createInventory(null, 54, "Shop");
|
||||||
|
|
||||||
|
// Get the categories from the config
|
||||||
|
List<String> categories = config.getStringList("shop.categories");
|
||||||
|
int maxItemsPerPage = config.getInt("pagination.max_items_per_page");
|
||||||
|
int startIndex = (page - 1) * maxItemsPerPage;
|
||||||
|
int endIndex = startIndex + maxItemsPerPage;
|
||||||
|
|
||||||
|
// Loop through the categories
|
||||||
|
for (String categoryName : categories) {
|
||||||
|
List<ItemStack> items = loadItemsFromCategory(categoryName);
|
||||||
|
|
||||||
|
// Calculate the correct number of items for pagination
|
||||||
|
for (int i = startIndex; i < endIndex && i < items.size(); i++) {
|
||||||
|
ItemStack item = items.get(i);
|
||||||
|
shopInventory.addItem(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Show inventory to the player
|
||||||
|
player.openInventory(shopInventory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<ItemStack> loadItemsFromCategory(String category) {
|
||||||
|
List<ItemStack> items = new ArrayList<>();
|
||||||
|
|
||||||
|
// Load items for the category from the config
|
||||||
|
List<String> itemList = config.getStringList("shop.categories." + category + ".items");
|
||||||
|
|
||||||
|
for (String item : itemList) {
|
||||||
|
String materialName = config.getString("shop.categories." + category + ".items." + item + ".material");
|
||||||
|
Material material = Material.getMaterial(materialName.toUpperCase());
|
||||||
|
int price = config.getInt("shop.categories." + category + ".items." + item + ".price");
|
||||||
|
String displayName = config.getString("shop.categories." + category + ".items." + item + ".display_name");
|
||||||
|
|
||||||
|
if (material != null) {
|
||||||
|
ItemStack itemStack = new ItemStack(material);
|
||||||
|
ItemMeta meta = itemStack.getItemMeta();
|
||||||
|
if (meta != null) {
|
||||||
|
meta.setDisplayName(displayName);
|
||||||
|
List<String> lore = new ArrayList<>();
|
||||||
|
lore.add(ChatColor.GOLD + "Price: " + price + " coins");
|
||||||
|
meta.setLore(lore);
|
||||||
|
itemStack.setItemMeta(meta);
|
||||||
|
items.add(itemStack);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to add items to the shop
|
||||||
|
private void addItemToShop(Inventory shop, Material material, String displayName, double price) {
|
||||||
|
ItemStack item = new ItemStack(material);
|
||||||
|
ItemMeta meta = item.getItemMeta();
|
||||||
|
meta.setDisplayName(displayName);
|
||||||
|
meta.setLore(Collections.singletonList(ChatColor.GOLD + "Price: " + price + " currency"));
|
||||||
|
item.setItemMeta(meta);
|
||||||
|
shop.addItem(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle item right-click to open the shop
|
||||||
|
@EventHandler
|
||||||
|
public void onItemUse(PlayerInteractEvent event) {
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
ItemStack item = player.getInventory().getItemInMainHand();
|
||||||
|
|
||||||
|
if (item != null && item.hasItemMeta() && item.getItemMeta().getPersistentDataContainer().has(shopItemKey, PersistentDataType.STRING)) {
|
||||||
|
if (event.getAction() == Action.RIGHT_CLICK_AIR || event.getAction() == Action.RIGHT_CLICK_BLOCK) {
|
||||||
|
openShop(player,1);
|
||||||
|
event.setCancelled(true); // Prevent default interaction
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Handle purchases from the shop
|
||||||
|
@EventHandler
|
||||||
|
public void onInventoryClick(InventoryClickEvent event) {
|
||||||
|
Player player = (Player) event.getWhoClicked();
|
||||||
|
InventoryView clickedInventory = event.getWhoClicked().getOpenInventory();
|
||||||
|
|
||||||
|
if (clickedInventory.getTitle().equals(ChatColor.DARK_GREEN + "Block Shop")) {
|
||||||
|
event.setCancelled(true); // Prevent item from being moved
|
||||||
|
|
||||||
|
ItemStack clickedItem = event.getCurrentItem();
|
||||||
|
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
||||||
|
double price = getPrice(clickedItem);
|
||||||
|
if (economy.has(player, price)) {
|
||||||
|
economy.withdrawPlayer(player, price);
|
||||||
|
player.getInventory().addItem(clickedItem);
|
||||||
|
player.sendMessage(ChatColor.GREEN + "You bought " + clickedItem.getType() + " for " + price + " currency.");
|
||||||
|
} else {
|
||||||
|
player.sendMessage(ChatColor.RED + "You don't have enough currency to buy this.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Helper method to retrieve the price of an item (can be customized to use a config file for prices)
|
||||||
|
private double getPrice(ItemStack item) {
|
||||||
|
// For simplicity, we assign prices based on material name, you can use a config file for more flexibility
|
||||||
|
switch (item.getType()) {
|
||||||
|
case STONE: return 10;
|
||||||
|
case DIRT: return 5;
|
||||||
|
case OAK_PLANKS: return 15;
|
||||||
|
case BRICKS: return 20;
|
||||||
|
default: return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Register the block shop commands and events
|
||||||
|
public void register() {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import org.bukkit.block.BlockState;
|
|||||||
import org.bukkit.block.data.type.LightningRod;
|
import org.bukkit.block.data.type.LightningRod;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.entity.ArmorStand;
|
import org.bukkit.entity.ArmorStand;
|
||||||
import org.bukkit.entity.Monster;
|
import org.bukkit.entity.Monster;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -30,7 +31,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.block.data.type.RespawnAnchor;
|
import org.bukkit.block.data.type.RespawnAnchor;
|
||||||
import CoswayUtil.GravityGauntletCommand;
|
import CoswayUtil.GravityGauntletCommand;
|
||||||
|
import net.milkbowl.vault.economy.Economy;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -38,9 +39,13 @@ import java.util.Map;
|
|||||||
|
|
||||||
|
|
||||||
public final class CoswayUtil extends JavaPlugin implements Listener {
|
public final class CoswayUtil extends JavaPlugin implements Listener {
|
||||||
|
private Economy economy;
|
||||||
|
private FileConfiguration config;
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
|
// Create or load the configuration file
|
||||||
|
saveDefaultConfig(); // This creates the config file if it doesn't exist.
|
||||||
|
config = getConfig(); // Get the loaded configuration
|
||||||
serverMessage(ColorKey("&aaw sheit here we go again...."));
|
serverMessage(ColorKey("&aaw sheit here we go again...."));
|
||||||
Bukkit.getPluginManager().registerEvents(new AnchorShield(), this);
|
Bukkit.getPluginManager().registerEvents(new AnchorShield(), this);
|
||||||
// Start the detection loop when the plugin is enabled
|
// Start the detection loop when the plugin is enabled
|
||||||
@ -73,6 +78,16 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
|
|||||||
new TotemShield(this);
|
new TotemShield(this);
|
||||||
// Register the ShadowStep listener
|
// Register the ShadowStep listener
|
||||||
new MobLevitationWand(this);
|
new MobLevitationWand(this);
|
||||||
|
if (!setupEconomy()) {
|
||||||
|
getLogger().severe("Vault not found or no economy provider found.");
|
||||||
|
getServer().getPluginManager().disablePlugin(this);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BlockShop(this, economy).register();
|
||||||
|
new BlockShop(this, economy);
|
||||||
|
new RapidFireBow(this);
|
||||||
|
getServer().getPluginManager().registerEvents(new RapidFireBow(this), this);
|
||||||
getServer().getPluginManager().registerEvents(new ShadowStep(this), this);
|
getServer().getPluginManager().registerEvents(new ShadowStep(this), this);
|
||||||
//register levitation wand
|
//register levitation wand
|
||||||
Bukkit.getPluginManager().registerEvents(new MobLevitationWand(this), this);
|
Bukkit.getPluginManager().registerEvents(new MobLevitationWand(this), this);
|
||||||
@ -84,11 +99,17 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
|
|||||||
this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand());
|
this.getCommand("gravitygauntlet").setExecutor(new GravityGauntletCommand());
|
||||||
this.getCommand("getwand").setExecutor(new GiveWandCommand());
|
this.getCommand("getwand").setExecutor(new GiveWandCommand());
|
||||||
getServer().getPluginManager().registerEvents(new LaunchStick(this), this);
|
getServer().getPluginManager().registerEvents(new LaunchStick(this), this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private boolean setupEconomy() {
|
||||||
|
// Setup Vault economy (make sure it's enabled and available)
|
||||||
|
if (getServer().getPluginManager().getPlugin("Vault") != null) {
|
||||||
|
economy = getServer().getServicesManager().getRegistration(Economy.class).getProvider();
|
||||||
|
return economy != null;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
serverMessage(ColorKey("&cim dead, im alive but im dead...."));
|
serverMessage(ColorKey("&cim dead, im alive but im dead...."));
|
||||||
@ -104,6 +125,12 @@ public final class CoswayUtil extends JavaPlugin implements Listener {
|
|||||||
if (cmd.getName().equalsIgnoreCase("launchstick") && sender instanceof Player player) {
|
if (cmd.getName().equalsIgnoreCase("launchstick") && sender instanceof Player player) {
|
||||||
player.getInventory().addItem(LaunchStick.createLaunchStick());
|
player.getInventory().addItem(LaunchStick.createLaunchStick());
|
||||||
}
|
}
|
||||||
|
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("throw") && sender instanceof Player player) {
|
if (cmd.getName().equalsIgnoreCase("throw") && sender instanceof Player player) {
|
||||||
Player Target = getNearestPlayer(player,10);
|
Player Target = getNearestPlayer(player,10);
|
||||||
if(Target == null) {
|
if(Target == null) {
|
||||||
|
@ -1,12 +1,16 @@
|
|||||||
package CoswayUtil;
|
package CoswayUtil;
|
||||||
|
|
||||||
import org.bukkit.*;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.*;
|
||||||
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.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
|
import org.bukkit.event.player.PlayerSwapHandItemsEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
import org.bukkit.persistence.PersistentDataType;
|
import org.bukkit.persistence.PersistentDataType;
|
||||||
@ -25,6 +29,16 @@ public class RapidFireBow implements Listener {
|
|||||||
public RapidFireBow(CoswayUtil plugin) {
|
public RapidFireBow(CoswayUtil plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
public void removeGroundedArrows() {
|
||||||
|
for (World world : Bukkit.getWorlds()) {
|
||||||
|
for (Arrow arrow : world.getEntitiesByClass(Arrow.class)) {
|
||||||
|
if (arrow.isOnGround()) {
|
||||||
|
arrow.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onRightClick(PlayerInteractEvent event) {
|
public void onRightClick(PlayerInteractEvent event) {
|
||||||
@ -37,6 +51,8 @@ public class RapidFireBow implements Listener {
|
|||||||
// If the player is already shooting, do nothing
|
// If the player is already shooting, do nothing
|
||||||
if (shootingTasks.containsKey(player.getUniqueId())) return;
|
if (shootingTasks.containsKey(player.getUniqueId())) return;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Start firing arrows every tick
|
// Start firing arrows every tick
|
||||||
BukkitRunnable task = new BukkitRunnable() {
|
BukkitRunnable task = new BukkitRunnable() {
|
||||||
@Override
|
@Override
|
||||||
@ -62,8 +78,14 @@ public class RapidFireBow implements Listener {
|
|||||||
shootingTasks.put(player.getUniqueId(), task);
|
shootingTasks.put(player.getUniqueId(), task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stop shooting when the player switches item or swaps hands
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onItemSwitch(PlayerItemHeldEvent event) {
|
||||||
|
stopShooting(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onSwapHands(PlayerSwapHandItemsEvent event) {
|
||||||
stopShooting(event.getPlayer());
|
stopShooting(event.getPlayer());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,6 +105,7 @@ public class RapidFireBow implements Listener {
|
|||||||
if (shootingTasks.containsKey(playerId)) {
|
if (shootingTasks.containsKey(playerId)) {
|
||||||
shootingTasks.get(playerId).cancel();
|
shootingTasks.get(playerId).cancel();
|
||||||
shootingTasks.remove(playerId);
|
shootingTasks.remove(playerId);
|
||||||
|
removeGroundedArrows();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +113,7 @@ public class RapidFireBow implements Listener {
|
|||||||
ItemStack bow = new ItemStack(Material.BOW);
|
ItemStack bow = new ItemStack(Material.BOW);
|
||||||
ItemMeta meta = bow.getItemMeta();
|
ItemMeta meta = bow.getItemMeta();
|
||||||
meta.setDisplayName(ChatColor.GOLD + "Rapid-Fire Bow");
|
meta.setDisplayName(ChatColor.GOLD + "Rapid-Fire Bow");
|
||||||
meta.setLore(Collections.singletonList(ChatColor.RED + "Hold Right-Click to unleash rapid arrows!"));
|
meta.setLore(Collections.singletonList(ChatColor.RED + "Press Right-Click to unleash rapid arrows! Switch hands to stop."));
|
||||||
meta.getPersistentDataContainer().set(new NamespacedKey("coswayutil", "rapid_fire_bow"), PersistentDataType.STRING, "true");
|
meta.getPersistentDataContainer().set(new NamespacedKey("coswayutil", "rapid_fire_bow"), PersistentDataType.STRING, "true");
|
||||||
bow.setItemMeta(meta);
|
bow.setItemMeta(meta);
|
||||||
return bow;
|
return bow;
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
# config.yml
|
||||||
|
|
||||||
|
shop:
|
||||||
|
categories:
|
||||||
|
- name: "Building Blocks"
|
||||||
|
items:
|
||||||
|
- material: "STONE"
|
||||||
|
price: 1
|
||||||
|
display_name: "Stone"
|
||||||
|
- material: "WOOD"
|
||||||
|
price: 2
|
||||||
|
display_name: "Wood"
|
||||||
|
- material: "BRICK"
|
||||||
|
price: 3
|
||||||
|
display_name: "Brick"
|
||||||
|
- name: "Decorative Blocks"
|
||||||
|
items:
|
||||||
|
- material: "LANTERN"
|
||||||
|
price: 5
|
||||||
|
display_name: "Lantern"
|
||||||
|
- material: "PAINTING"
|
||||||
|
price: 10
|
||||||
|
display_name: "Painting"
|
||||||
|
- name: "Tools"
|
||||||
|
items:
|
||||||
|
- material: "WOODEN_SWORD"
|
||||||
|
price: 10
|
||||||
|
display_name: "Wooden Sword"
|
||||||
|
- material: "IRON_SWORD"
|
||||||
|
price: 20
|
||||||
|
display_name: "Iron Sword"
|
||||||
|
|
||||||
|
pagination:
|
||||||
|
max_items_per_page: 45 # Max items to display per page
|
@ -4,6 +4,7 @@ main: CoswayUtil.CoswayUtil
|
|||||||
description: "utility plugin for Cosway servers, a yescraft network server"
|
description: "utility plugin for Cosway servers, a yescraft network server"
|
||||||
api-version: '1.21'
|
api-version: '1.21'
|
||||||
author: "Newt_00"
|
author: "Newt_00"
|
||||||
|
depend: [Vault]
|
||||||
website: "ycs.Newt-Tech.com"
|
website: "ycs.Newt-Tech.com"
|
||||||
commands:
|
commands:
|
||||||
scale:
|
scale:
|
||||||
@ -22,10 +23,18 @@ commands:
|
|||||||
usage: "/getwand"
|
usage: "/getwand"
|
||||||
permission: CoswayUtil.wand
|
permission: CoswayUtil.wand
|
||||||
launchstick:
|
launchstick:
|
||||||
description: give player a stick to use for launching themselves
|
description: "give player a stick to use for launching themselves"
|
||||||
usage: /launchstick
|
usage: "/launchstick"
|
||||||
permission: CoswayUtil.launchStick
|
permission: CoswayUtil.launchStick
|
||||||
rapidbow:
|
rapidbow:
|
||||||
description: gives player a rapid fire bow
|
description: "gives player a rapid fire bow"
|
||||||
usage: /rapidbow
|
usage: "/rapidbow"
|
||||||
permission: CoswayUtil.rapidBow
|
permission: CoswayUtil.rapidBow
|
||||||
|
shopbook:
|
||||||
|
description: "gives player shop book"
|
||||||
|
usage: "/shopbook"
|
||||||
|
permission: CoswayUtil.shop
|
||||||
|
blockshop:
|
||||||
|
description: "opens block shop"
|
||||||
|
usage: "/blockshop"
|
||||||
|
permission: CoswayUtil.shop
|
Loading…
Reference in New Issue
Block a user