Add user messages.

This commit is contained in:
Faris Rehman 2014-05-16 20:30:26 +01:00 committed by KHobbits
parent bd866de950
commit ed9e4ecd28
24 changed files with 77 additions and 21 deletions

View file

@ -1,23 +1,19 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.ChargeException; import static com.earth2me.essentials.I18n.tl;
import com.earth2me.essentials.Trade; import java.util.*;
import com.earth2me.essentials.Trade.OverflowType;
import com.earth2me.essentials.User;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import net.ess3.api.MaxMoneyException;
import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.Recipe; import org.bukkit.inventory.Recipe;
import org.bukkit.inventory.ShapedRecipe; import org.bukkit.inventory.ShapedRecipe;
import org.bukkit.inventory.ShapelessRecipe; import org.bukkit.inventory.ShapelessRecipe;
import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.Trade.OverflowType;
import com.earth2me.essentials.User;
import net.ess3.api.MaxMoneyException;
public class Commandcondense extends EssentialsCommand public class Commandcondense extends EssentialsCommand
@ -32,12 +28,11 @@ public class Commandcondense extends EssentialsCommand
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{ {
List<ItemStack> is = new ArrayList<ItemStack>(); List<ItemStack> is = new ArrayList<ItemStack>();
boolean validateReverse;
boolean validateReverse = false;
if (args.length > 0) if (args.length > 0)
{ {
is = ess.getItemDb().getMatching(user, args); is = ess.getItemDb().getMatching(user, args);
validateReverse = false;
} }
else else
{ {
@ -52,14 +47,28 @@ public class Commandcondense extends EssentialsCommand
validateReverse = true; validateReverse = true;
} }
boolean didConvert = false;
for (final ItemStack itemStack : is) for (final ItemStack itemStack : is)
{ {
condenseStack(user, itemStack, validateReverse); if (condenseStack(user, itemStack, validateReverse))
{
didConvert = true;
}
} }
user.getBase().updateInventory(); user.getBase().updateInventory();
if (didConvert)
{
user.sendMessage(tl("itemsConverted"));
}
else
{
user.sendMessage(tl("itemsNotConverted"));
throw new NoChargeException();
}
} }
private void condenseStack(final User user, final ItemStack stack, final boolean validateReverse) throws ChargeException, MaxMoneyException private boolean condenseStack(final User user, final ItemStack stack, final boolean validateReverse) throws ChargeException, MaxMoneyException
{ {
final SimpleRecipe condenseType = getCondenseType(stack); final SimpleRecipe condenseType = getCondenseType(stack);
if (condenseType != null) if (condenseType != null)
@ -72,7 +81,6 @@ public class Commandcondense extends EssentialsCommand
boolean pass = false; boolean pass = false;
for (Recipe revRecipe : ess.getServer().getRecipesFor(input)) for (Recipe revRecipe : ess.getServer().getRecipesFor(input))
{ {
if (getStackOnRecipeMatch(revRecipe, result) != null) if (getStackOnRecipeMatch(revRecipe, result) != null)
{ {
pass = true; pass = true;
@ -81,7 +89,7 @@ public class Commandcondense extends EssentialsCommand
} }
if (!pass) if (!pass)
{ {
return; return false;
} }
} }
@ -106,8 +114,10 @@ public class Commandcondense extends EssentialsCommand
final Trade add = new Trade(result, ess); final Trade add = new Trade(result, ess);
remove.charge(user); remove.charge(user);
add.pay(user, OverflowType.DROP); add.pay(user, OverflowType.DROP);
return true;
} }
} }
return false;
} }
private SimpleRecipe getCondenseType(final ItemStack stack) private SimpleRecipe getCondenseType(final ItemStack stack)
@ -186,12 +196,12 @@ public class Commandcondense extends EssentialsCommand
} }
class SimpleRecipe implements Recipe private class SimpleRecipe implements Recipe
{ {
private ItemStack result; private ItemStack result;
private ItemStack input; private ItemStack input;
SimpleRecipe(ItemStack result, ItemStack input) private SimpleRecipe(ItemStack result, ItemStack input)
{ {
this.result = result; this.result = result;
this.input = input; this.input = input;

View file

@ -549,3 +549,5 @@ mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Bylo odeslano prilis mnoho mailu. Pockej minutu. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=In der letzten Minute wurden zu viele Mails gesendet. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Demasiados correos han sido enviados en el \u00faltimo minuto. M\u00e1
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Saatsid liiga palju kirju viimase minuti jooskul. Maksimaalne kirjade
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Trop de mails ont \u00e9t\u00e9 envoy\u00e9s durant la derni\u00e8re m
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=T\u00fal sok lev\u00e9l lett elk\u00fcldve az utols\u00f3 percben. Max
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Hai mandato troppe mail nell''ultimo minuto. Massimo\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=\ub108\ubb34 \ub9ce\uc740 \uc591\uc758 \uc774\uba54\uc77c\uc744 \ubcf4
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Per daug lai\u0161k\u0173 buvo i\u0161si\u0173stos per paskutin\u0119
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Er zijn teveel mails verzonden in een minuut. Het maximale aantal beri
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=\u00a74Za duzo wyslanych wiadomosci. Maksimum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Muitos e-mails foram enviados no \u00faltimo minuto. M\u00e1ximo\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Prea multe mail-uri au fost trimise in ultimul minute.Maxim \: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=\u0421\u043b\u0438\u0448\u043a\u043e\u043c \u043c\u043d\u043e\u0433\u0
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=F\u00f6r m\u00e5nga mails har skickats sen senaste minuten. Max\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Cok fazla posta gonderildi. Sinir\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=Too many mails have been sent within the last minute. Maximum\: {0}
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.

View file

@ -549,3 +549,5 @@ mailDelay=\u5728\u6700\u5f8c\u4e00\u5206\u9418\u5167\u767c\u9001\u592a\u591a\u90
seenAccounts=\u00a76Player has also been known as\:\u00a7c {0} seenAccounts=\u00a76Player has also been known as\:\u00a7c {0}
unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item. unableToSpawnItem=\u00a74Cannot spawn \u00a7c{0}\u00a74, this is not a spawnable item.
itemsConverted=\u00a76Converted all items into blocks.
itemsNotConverted=\u00a74You have no items that can be converted into blocks.