예제 #1
0
	private Trade rechargeSign(final ISign sign, final IEssentials ess, final IUser player) throws SignException, ChargeException
	{
		final Trade trade = getTrade(sign, 2, false, false, ess);
		ItemStack itemInHand = player.getPlayer().getItemInHand();
		if (trade.getItemStack() != null && itemInHand != null
			&& trade.getItemStack().getTypeId() == itemInHand.getTypeId()
			&& trade.getItemStack().getDurability() == itemInHand.getDurability()
			&& trade.getItemStack().getEnchantments().equals(itemInHand.getEnchantments()))
		{
			int amount = itemInHand.getAmount();
			amount -= amount % trade.getItemStack().getAmount();
			if (amount > 0)
			{
				final ItemStack stack = itemInHand.clone();
				stack.setAmount(amount);
				final Trade store = new Trade(stack, ess);
				addAmount(sign, 2, store, ess);
				store.charge(player);
				return store;
			}
		}
		return null;
	}
예제 #2
0
	protected final void validateTrade(final ISign sign, final int amountIndex, final int itemIndex, final IUser player, final IEssentials ess) throws SignException
	{
		if (sign.getLine(itemIndex).equalsIgnoreCase("exp") || sign.getLine(itemIndex).equalsIgnoreCase("xp"))
		{
			int amount = getIntegerPositive(sign.getLine(amountIndex));
			sign.setLine(amountIndex, Integer.toString(amount));
			sign.setLine(itemIndex, "exp");
			return;
		}
		final Trade trade = getTrade(sign, amountIndex, itemIndex, player, ess);
		final ItemStack item = trade.getItemStack();
		sign.setLine(amountIndex, Integer.toString(item.getAmount()));
		sign.setLine(itemIndex, sign.getLine(itemIndex).trim());
	}
예제 #3
0
	protected final void addAmount(final ISign sign, final int index, final Trade trade, final IEssentials ess) throws SignException
	{
		final Double money = trade.getMoney();
		if (money != null)
		{
			changeAmount(sign, index, money, ess);
		}
		final ItemStack item = trade.getItemStack();
		if (item != null)
		{
			changeAmount(sign, index, item.getAmount(), ess);
		}
		final Integer exp = trade.getExperience();
		if (exp != null)
		{
			changeAmount(sign, index, exp.intValue(), ess);
		}
	}