Hopefully with working functionality

This commit is contained in:
BuildTools 2024-01-15 22:16:11 +01:00
parent 700d05996e
commit 54bcdea4f7
4 changed files with 85 additions and 0 deletions

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View file

@ -1,17 +1,38 @@
package xyz.tronax.repairall; package xyz.tronax.repairall;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandExecutor;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import xyz.tronax.repairall.commands.CMD_repairall;
public final class RepairAll extends JavaPlugin { public final class RepairAll extends JavaPlugin {
public static String prefix = "§cRepair§7All §8| ";
@Override @Override
public void onEnable() { public void onEnable() {
// Plugin startup logic // Plugin startup logic
cmdmsg(prefix + " §aPlugin started successfully!");
registerCmd("repairall", new CMD_repairall());
} }
@Override @Override
public void onDisable() { public void onDisable() {
// Plugin shutdown logic // Plugin shutdown logic
cmdmsg(prefix + " §cPlugin stopped successfully!");
}
public void cmdmsg(String msg) {
Bukkit.getConsoleSender().sendMessage(msg);
}
private void registerCmd(String CommandName, CommandExecutor CommandClass) {
getCommand(CommandName).setExecutor(CommandClass);
} }
} }

View file

@ -0,0 +1,55 @@
package xyz.tronax.repairall.commands;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta;
import xyz.tronax.repairall.RepairAll;
public class CMD_repairall implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(!(sender instanceof Player)) {
sender.sendMessage(RepairAll.prefix + " §cYou are not a player!");
} else {
Player p = (Player) sender;
ItemStack[] items = p.getInventory().getContents();
ItemStack[] armor = p.getInventory().getArmorContents();
for(int i = 0; i < items.length; i++) {
ItemStack e = items[i];
if(e != null) {
ItemMeta me = e.getItemMeta();
Damageable mee = (Damageable) me;
mee.setDamage(0);
e.setItemMeta(mee);
}else{
}
}
for(int i = 0; i < armor.length; i++) {
ItemStack a = armor[i];
if(a != null) {
ItemMeta ae = a.getItemMeta();
Damageable aee = (Damageable) ae;
aee.setDamage(0);
a.setItemMeta(aee);
} else {
}
}
p.sendMessage(RepairAll.prefix + "§aAll your items have been repaired!");
Bukkit.getConsoleSender().sendMessage(RepairAll.prefix + "§4" + p.getName().toString() + " §ahas repaired all his items!");
}
return false;
}
}

View file

@ -5,3 +5,12 @@ api-version: '1.20'
authors: [TronaxYT] authors: [TronaxYT]
description: Repairs all your items description: Repairs all your items
website: https://tronax.xyz website: https://tronax.xyz
commands:
repairall:
description: Repairs all of your items!
permission: repairall.repair
permission-message: '§cRepair§7All §8| §cYou are not allowed to do this!'
aliases:
- ra
- repall
- rall