Log location of /sell and signs

This commit is contained in:
snowleo 2011-07-18 04:49:38 +02:00
parent 277c623a77
commit 5aa2bc1706
6 changed files with 22 additions and 9 deletions

View File

@ -8,6 +8,7 @@ import java.util.Date;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.inventory.ItemStack;
@ -131,7 +132,7 @@ public class Trade
}
private static FileWriter fw = null;
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, IEssentials ess)
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
if (!ess.getSettings().isEcoLogEnabled())
{
@ -201,6 +202,18 @@ public class Trade
sb.append(ess.getSettings().getCurrencySymbol());
}
}
if (loc == null)
{
sb.append(",\"\",\"\",\"\",\"\"");
}
else
{
sb.append(",\"");
sb.append(loc.getWorld().getName()).append("\",");
sb.append(loc.getBlockX()).append(",");
sb.append(loc.getBlockY()).append(",");
sb.append(loc.getBlockZ()).append(",");
}
sb.append("\n");
try
{

View File

@ -153,7 +153,7 @@ public class Commandsell extends EssentialsCommand
final ItemStack ris = new ItemStack(is.getType(), amount, is.getDurability());
InventoryWorkaround.removeItem(user.getInventory(), true, ris);
user.updateInventory();
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth*amount, ess), ess);
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth*amount, ess), user.getLocation(), ess);
user.giveMoney(worth * amount);
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
logger.log(Level.INFO, Util.format("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));

View File

@ -29,7 +29,7 @@ public class SignBuy extends EssentialsSign
charge.isAffordableFor(player);
items.pay(player);
charge.charge(player);
Trade.log("Sign", "Buy", "Interact", username, charge, username, items, ess);
Trade.log("Sign", "Buy", "Interact", username, charge, username, items, sign.getBlock().getLocation(), ess);
return true;
}
}

View File

@ -32,7 +32,7 @@ public class SignFree extends EssentialsSign
inv.clear();
InventoryWorkaround.addItem(inv, true, item);
player.showInventory(inv);
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), ess);
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
return true;
}
}

View File

@ -29,7 +29,7 @@ public class SignSell extends EssentialsSign
charge.isAffordableFor(player);
money.pay(player);
charge.charge(player);
Trade.log("Sign", "Sell", "Interact", username, charge, username, money, ess);
Trade.log("Sign", "Sell", "Interact", username, charge, username, money, sign.getBlock().getLocation(), ess);
return true;
}
}

View File

@ -24,7 +24,7 @@ public class SignTrade extends EssentialsSign
charge.isAffordableFor(player);
sign.setLine(3, "§8" + username);
charge.charge(player);
Trade.log("Sign", "Trade", "Create", username, charge, username, null, ess);
Trade.log("Sign", "Trade", "Create", username, charge, username, null, sign.getBlock().getLocation(), ess);
return true;
}
@ -36,7 +36,7 @@ public class SignTrade extends EssentialsSign
final Trade stored = getTrade(sign, 1, true, true, ess);
substractAmount(sign, 1, stored, ess);
stored.pay(player);
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, ess);
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess);
}
else
{
@ -47,7 +47,7 @@ public class SignTrade extends EssentialsSign
trade.pay(player);
addAmount(sign, 1, charge, ess);
charge.charge(player);
Trade.log("Sign", "Trade", "Interact", sign.getLine(3), charge, username, trade, ess);
Trade.log("Sign", "Trade", "Interact", sign.getLine(3), charge, username, trade, sign.getBlock().getLocation(), ess);
}
sign.updateSign();
return true;
@ -63,7 +63,7 @@ public class SignTrade extends EssentialsSign
final Trade stored2 = getTrade(sign, 2, true, false, ess);
stored1.pay(player);
stored2.pay(player);
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, ess);
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
return true;
}
else