dont know why it doesn't work, so i fixed

This commit is contained in:
night0721 2022-07-14 00:36:13 +01:00
parent c1243cf83a
commit 4dd88fd075
6 changed files with 109 additions and 11 deletions

View file

@ -6,7 +6,7 @@
<groupId>com.night</groupId> <groupId>com.night</groupId>
<artifactId>NullValkyrie</artifactId> <artifactId>NullValkyrie</artifactId>
<version>1.0</version> <version>1.0.1</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>NullValkyrie</name> <name>NullValkyrie</name>

View file

@ -11,6 +11,7 @@ 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.block.Action;
import org.bukkit.event.entity.*; import org.bukkit.event.entity.*;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerFishEvent; import org.bukkit.event.player.PlayerFishEvent;
import org.bukkit.event.player.PlayerInteractEvent; 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);
}
}
}
} }

View file

@ -62,6 +62,7 @@ public final class Main extends JavaPlugin implements Listener {
new CraftCommand(); new CraftCommand();
new EnchantingCommand(); new EnchantingCommand();
new RankCommand(this); new RankCommand(this);
new UtilCommand(this);
new WeaponCommand(this); new WeaponCommand(this);
bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12); bossbar = Bukkit.createBossBar(ChatColor.GOLD + "Kuudra", BarColor.RED, BarStyle.SEGMENTED_12);
Bukkit.getPluginManager().registerEvents(this, this); Bukkit.getPluginManager().registerEvents(this, this);

View file

@ -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<String> 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<String> onTabComplete(CommandSender sender, String[] args) {
if(args.length == 1) {
List<String> hh = getAllFilesFromDirectory("ItemData");
ArrayList<String> 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<>();
}
}

View file

@ -1,6 +1,5 @@
package com.night.nullvalkyrie.commands; package com.night.nullvalkyrie.commands;
import com.night.nullvalkyrie.Items.CustomItemManager;
import com.night.nullvalkyrie.Main; import com.night.nullvalkyrie.Main;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -60,7 +59,9 @@ public class WeaponCommand extends Command {
ArrayList<String> cc = new ArrayList<>(); ArrayList<String> cc = new ArrayList<>();
for(int kk = 0; kk < hh.size(); kk++) { for(int kk = 0; kk < hh.size(); kk++) {
FileConfiguration c = loadConfig("ItemData\\" + hh.get(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<>()); return StringUtil.copyPartialMatches(args[0], cc, new ArrayList<>());
} }

View file

@ -2,7 +2,7 @@ ExplosiveBow:
name: "Explosive Bow" name: "Explosive Bow"
material: "BOW" material: "BOW"
type: "Weapon" type: "Weapon"
rarity: LEGENDARY rarity: "LEGENDARY"
lore: lore:
properties: properties:
damage: 50 damage: 50
@ -19,7 +19,7 @@ FragGrenade:
name: "Frag Grenade" name: "Frag Grenade"
material: "EGG" material: "EGG"
type: "Weapon" type: "Weapon"
rarity: LEGENDARY rarity: "LEGENDARY"
lore: lore:
properties: properties:
damage: 50 damage: 50
@ -34,8 +34,8 @@ FragGrenade:
GrapplingHook: GrapplingHook:
name: "Grappling Hook" name: "Grappling Hook"
material: "FISHING_ROD" material: "FISHING_ROD"
type: "Weapon" type: "Util"
rarity: RARE rarity: "RARE"
lore: lore:
ability: ability:
name: Hook name: Hook
@ -47,7 +47,7 @@ SnowGun:
name: "Snow Gun" name: "Snow Gun"
material: "DIAMOND_HOE" material: "DIAMOND_HOE"
type: "Weapon" type: "Weapon"
rarity: ULTRA rarity: "ULTRA"
lore: lore:
properties: properties:
damage: 25 damage: 25
@ -65,7 +65,7 @@ TeleportDoor:
name: "Teleport Door" name: "Teleport Door"
material: "DIAMOND_SHOVEL" material: "DIAMOND_SHOVEL"
type: "Weapon" type: "Weapon"
rarity: GRAND rarity: "GRAND"
lore: lore:
properties: properties:
damage: 75 damage: 75
@ -83,7 +83,7 @@ Terminator:
name: "Terminator" name: "Terminator"
material: "BOW" material: "BOW"
type: "Weapon" type: "Weapon"
rarity: MYTHIC rarity: "MYTHIC"
lore: lore:
properties: properties:
damage: 50 damage: 50
@ -104,7 +104,7 @@ WidowSword:
name: "Widow Sword" name: "Widow Sword"
material: "STICK" material: "STICK"
type: "Weapon" type: "Weapon"
rarity: MYTHIC rarity: "MYTHIC"
lore: lore:
properties: properties:
damage: 100 damage: 100
@ -126,3 +126,13 @@ WidowSword:
zombie: 100 zombie: 100
skeleton: 100 skeleton: 100
spider: 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"