Skip to content

Commit

Permalink
close #60
Browse files Browse the repository at this point in the history
  • Loading branch information
RecursiveG committed Feb 12, 2016
1 parent bbe125f commit 623ae03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/main/java/think/rpgitems/Handler.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@ public void getItemDamage(CommandSender sender, RPGItem item) {
@CommandDocumentation("$command.rpgitem.damage.set")
@CommandGroup("item_damage")
public void setItemDamage(CommandSender sender, RPGItem item, int damage) {
if (damage > 32767) {
sender.sendMessage(ChatColor.RED + Locale.get("message.error.damagetolarge"));
return;
}
item.setDamage(damage, damage);
sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.damage.set"), item.getName(), item.getDamageMin()));
ItemManager.save(Plugin.plugin);
Expand All @@ -202,6 +206,10 @@ public void setItemDamage(CommandSender sender, RPGItem item, int damage) {
@CommandDocumentation("$command.rpgitem.damage.set.range")
@CommandGroup("item_damage")
public void setItemDamage(CommandSender sender, RPGItem item, int min, int max) {
if (min > 32767 || max > 32767) {
sender.sendMessage(ChatColor.RED + Locale.get("message.error.damagetolarge"));
return;
}
item.setDamage(min, max);
sender.sendMessage(ChatColor.AQUA + String.format(Locale.get("message.damage.set.range"), item.getName(), item.getDamageMin(), item.getDamageMax()));
ItemManager.save(Plugin.plugin);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/locale/en_GB.lang
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ message.error.permission=You do not have permission
message.error.player=Cannot find player %s
message.error.string.length='%s' in longer than max length %d
message.error.unknown.command=Error: Unknown command %s
message.error.damagetolarge=Damage TOO large. MAX: 32767
message.give.console=Cannot give console items
message.hand.get=Item '%s' hand is '%s'
message.hand.set=Item '%s' hand set to '%s'
Expand Down

0 comments on commit 623ae03

Please sign in to comment.