diff --git a/pom.xml b/pom.xml index 3a1595f..d3018a2 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.night NullValkyrie - 1.0 + 1.0.1 jar NullValkyrie diff --git a/src/main/java/com/night/nullvalkyrie/Events/CustomItemEvents.java b/src/main/java/com/night/nullvalkyrie/Events/CustomItemEvents.java index 0753103..4161d3a 100644 --- a/src/main/java/com/night/nullvalkyrie/Events/CustomItemEvents.java +++ b/src/main/java/com/night/nullvalkyrie/Events/CustomItemEvents.java @@ -11,6 +11,7 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.Action; import org.bukkit.event.entity.*; +import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerInteractEvent; @@ -188,4 +189,21 @@ public class CustomItemEvents implements Listener { } } } + @EventHandler + public void onPlayerBucketEmpty(PlayerBucketEmptyEvent e) { + int x = e.getBlockClicked().getX() + e.getBlockFace().getModX(); + int y = e.getBlockClicked().getY() + e.getBlockFace().getModY(); + int z = e.getBlockClicked().getZ() + e.getBlockFace().getModZ(); + Player player = e.getPlayer(); + if(player.getInventory().getItemInMainHand().getItemMeta() != null) { + String name = player.getInventory().getItemInMainHand().getItemMeta().getDisplayName(); + if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite Water Bucket")) { + e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.WATER); + e.setCancelled(true); + } else if (name.equalsIgnoreCase(Rarity.EPIC.getColor() + "Infinite LAVA Bucket")) { + e.getPlayer().getWorld().getBlockAt(x,y,z).setType(Material.LAVA); + e.setCancelled(true); + } + } + } } \ No newline at end of file diff --git a/src/main/java/com/night/nullvalkyrie/Main.java b/src/main/java/com/night/nullvalkyrie/Main.java index f92b1c5..e885e16 100644 --- a/src/main/java/com/night/nullvalkyrie/Main.java +++ b/src/main/java/com/night/nullvalkyrie/Main.java @@ -62,6 +62,7 @@ public final class Main extends JavaPlugin implements Listener { new CraftCommand(); new EnchantingCommand(); new RankCommand(this); + new UtilCommand(this); new WeaponCommand(this); bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12); Bukkit.getPluginManager().registerEvents(this, this); diff --git a/src/main/java/com/night/nullvalkyrie/commands/UtilCommand.java b/src/main/java/com/night/nullvalkyrie/commands/UtilCommand.java new file mode 100644 index 0000000..dd068e7 --- /dev/null +++ b/src/main/java/com/night/nullvalkyrie/commands/UtilCommand.java @@ -0,0 +1,68 @@ +package com.night.nullvalkyrie.commands; + +import com.night.nullvalkyrie.Main; +import org.bukkit.ChatColor; +import org.bukkit.command.CommandSender; +import org.bukkit.configuration.file.FileConfiguration; +import org.bukkit.entity.Player; +import org.bukkit.inventory.ItemStack; +import org.bukkit.util.StringUtil; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Objects; + +import static com.night.nullvalkyrie.Items.CustomItemManager.getAllFilesFromDirectory; +import static com.night.nullvalkyrie.Items.CustomItemManager.loadConfig; + +public class UtilCommand extends Command { + private Main main; + public UtilCommand(Main main) { + super( + "util", + new String[]{}, + "Give you a tool", + "" + + ); + this.main = main; + } + @Override + public void onCommand(CommandSender sender, String[] args) { + Player player = (Player) sender; + StringBuilder s = new StringBuilder(); + List b = Arrays.asList(args); + for(String a: args) { + if(a.equals(b.get(b.size() - 1))) { + s.append(a); + } else { + s.append(a); + s.append(" "); + } + + } + ItemStack item = main.getCustomItemManager().getItem(s.toString()); + if(item.hasItemMeta()) { + player.getInventory().addItem(item); + } else { + player.sendMessage(ChatColor.RED + "This item doesn't exist"); + } + } + + @Override + public List onTabComplete(CommandSender sender, String[] args) { + if(args.length == 1) { + List hh = getAllFilesFromDirectory("ItemData"); + ArrayList cc = new ArrayList<>(); + for(int kk = 0; kk < hh.size(); kk++) { + FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk)); + if(Objects.equals(c.getString("type"), "Util")) { + cc.add(c.getString("name")); + } + } + return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>()); + } + return new ArrayList<>(); + } +} diff --git a/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java b/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java index 8281c50..78a7466 100644 --- a/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java +++ b/src/main/java/com/night/nullvalkyrie/commands/WeaponCommand.java @@ -1,6 +1,5 @@ package com.night.nullvalkyrie.commands; -import com.night.nullvalkyrie.Items.CustomItemManager; import com.night.nullvalkyrie.Main; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; @@ -60,7 +59,9 @@ public class WeaponCommand extends Command { ArrayList cc = new ArrayList<>(); for(int kk = 0; kk < hh.size(); kk++) { FileConfiguration c = loadConfig("ItemData\\" + hh.get(kk)); - cc.add(c.getString("name")); + if(Objects.equals(c.getString("type"), "Weapon")) { + cc.add(c.getString("name")); + } } return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>()); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 503a063..38add75 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,7 +2,7 @@ ExplosiveBow: name: "Explosive Bow" material: "BOW" type: "Weapon" - rarity: LEGENDARY + rarity: "LEGENDARY" lore: properties: damage: 50 @@ -19,7 +19,7 @@ FragGrenade: name: "Frag Grenade" material: "EGG" type: "Weapon" - rarity: LEGENDARY + rarity: "LEGENDARY" lore: properties: damage: 50 @@ -34,8 +34,8 @@ FragGrenade: GrapplingHook: name: "Grappling Hook" material: "FISHING_ROD" - type: "Weapon" - rarity: RARE + type: "Util" + rarity: "RARE" lore: ability: name: Hook @@ -47,7 +47,7 @@ SnowGun: name: "Snow Gun" material: "DIAMOND_HOE" type: "Weapon" - rarity: ULTRA + rarity: "ULTRA" lore: properties: damage: 25 @@ -65,7 +65,7 @@ TeleportDoor: name: "Teleport Door" material: "DIAMOND_SHOVEL" type: "Weapon" - rarity: GRAND + rarity: "GRAND" lore: properties: damage: 75 @@ -83,7 +83,7 @@ Terminator: name: "Terminator" material: "BOW" type: "Weapon" - rarity: MYTHIC + rarity: "MYTHIC" lore: properties: damage: 50 @@ -104,7 +104,7 @@ WidowSword: name: "Widow Sword" material: "STICK" type: "Weapon" - rarity: MYTHIC + rarity: "MYTHIC" lore: properties: damage: 100 @@ -126,3 +126,13 @@ WidowSword: zombie: 100 skeleton: 100 spider: 100 +InfiniteWaterBucket: + name: "Infinite Water Bucket" + material: "WATER_BUCKET" + type: "Util" + rarity: "EPIC" +InfiniteLavaBucket: + name: "Infinite Lava Bucket" + material: "LAVA_BUCKET" + type: "Util" + rarity: "EPIC" \ No newline at end of file