mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-05 07:57:59 +01:00
Restore ID-based charges in /repair
This commit is contained in:
parent
3b1cef918e
commit
19cffe3872
@ -4,6 +4,7 @@ import com.earth2me.essentials.ChargeException;
|
|||||||
import com.earth2me.essentials.Trade;
|
import com.earth2me.essentials.Trade;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import com.earth2me.essentials.utils.StringUtil;
|
import com.earth2me.essentials.utils.StringUtil;
|
||||||
|
import com.earth2me.essentials.utils.VersionUtil;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import net.ess3.api.IUser;
|
import net.ess3.api.IUser;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -48,7 +49,7 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
final Trade charge = getCharge(item.getType());
|
||||||
|
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
|
|
||||||
@ -95,7 +96,8 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
final Trade charge = getCharge(item.getType());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
charge.isAffordableFor(user);
|
charge.isAffordableFor(user);
|
||||||
} catch (ChargeException ex) {
|
} catch (ChargeException ex) {
|
||||||
@ -120,6 +122,16 @@ public class Commandrepair extends EssentialsCommand {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Trade getCharge(final Material material) {
|
||||||
|
final String itemName = material.toString().toLowerCase(Locale.ENGLISH);
|
||||||
|
if (VersionUtil.getServerBukkitVersion().isLowerThan(VersionUtil.v1_13_0_R01)) {
|
||||||
|
final int itemId = material.getId();
|
||||||
|
return new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-" + itemId, new Trade("repair-item", ess), ess), ess);
|
||||||
|
} else {
|
||||||
|
return new Trade("repair-" + itemName.replace('_', '-'), new Trade("repair-item", ess), ess);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
protected List<String> getTabCompleteOptions(Server server, User user, String commandLabel, String[] args) {
|
||||||
if (args.length == 1) {
|
if (args.length == 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user