Skip to content

Commit

Permalink
RE-149 Fixed Repair Command
Browse files Browse the repository at this point in the history
  • Loading branch information
Relluem94 committed Feb 28, 2024
1 parent febfbcc commit 8744611
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ private Strings() {
public static final String PLUGIN_COMMAND_MORE = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast mehr von " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " erzeugt!";
public static final String PLUGIN_COMMAND_MORE_PLAYER = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast mehr von " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " erhalten!";

public static final String PLUGIN_COMMAND_REPAIR = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " repariert!";
public static final String PLUGIN_COMMAND_REPAIR = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + " repariert!";
public static final String PLUGIN_COMMAND_CANNOT_REPAIR = PLUGIN_FORMS_COMMAND_PREFIX + "Du kannst " + PLUGIN_COLOR_COMMAND_ARG + "%s" + PLUGIN_COLOR_COMMAND + " nicht reparieren!";
public static final String PLUGIN_COMMAND_REPAIR_PLAYER = PLUGIN_FORMS_COMMAND_PREFIX + "Du hast " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + " repariert bekommen!";

public static final String PLUGIN_COMMAND_GAMERULES = PLUGIN_FORMS_COMMAND_PREFIX + "Die Welt " + PLUGIN_COLOR_COMMAND_ARG + "%s " + PLUGIN_COLOR_COMMAND + "hat folgende Einstellungen:";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package de.relluem94.minecraft.server.spigot.essentials.commands;

import lombok.NonNull;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.chat.TranslatableComponent;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
Expand Down Expand Up @@ -30,14 +32,15 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul
ItemStack item = p.getInventory().getItemInMainHand();
ItemMeta im = item.getItemMeta();

if (im instanceof Damageable dmg) {
if (dmg.hasDamage()) {
dmg.setDamage(0);
}
if (im instanceof Damageable dmg && dmg.hasDamage()) {
dmg.setDamage(0);
item.setItemMeta(im);
p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, p.getInventory().getItemInMainHand().getType().name()));
}
else{
p.sendMessage(String.format(PLUGIN_COMMAND_CANNOT_REPAIR, p.getInventory().getItemInMainHand().getType().name()));
}

p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, p.getInventory().getItemInMainHand().getType()));
return true;
} else {
p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING);
Expand All @@ -54,15 +57,16 @@ public boolean onCommand(@NonNull CommandSender sender, Command command, @NonNul
ItemStack item = target.getInventory().getItemInMainHand();
ItemMeta im = item.getItemMeta();

if (im instanceof Damageable dmg) {
if (dmg.hasDamage()) {
dmg.setDamage(0);
}
if (im instanceof Damageable dmg && dmg.hasDamage()) {
dmg.setDamage(0);
item.setItemMeta(im);
p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, target.getInventory().getItemInMainHand().getType().name()));
target.sendMessage(String.format(PLUGIN_COMMAND_REPAIR_PLAYER, target.getInventory().getItemInMainHand().getType().name()));
}
else{
p.sendMessage(String.format(PLUGIN_COMMAND_CANNOT_REPAIR, p.getInventory().getItemInMainHand().getType().name()));
}

p.sendMessage(String.format(PLUGIN_COMMAND_REPAIR, target.getInventory().getItemInMainHand().getType()));
target.sendMessage(String.format(PLUGIN_COMMAND_REPAIR_PLAYER, target.getInventory().getItemInMainHand().getType()));
return true;
} else {
p.sendMessage(PLUGIN_COMMAND_PERMISSION_MISSING);
Expand Down

0 comments on commit 8744611

Please sign in to comment.