use of com.iCo6.IO.mini.Arguments in project Core by iConomy.
the class Purge method perform.
@Override
public boolean perform(CommandSender sender, LinkedHashMap<String, Argument> arguments) throws InvalidUsage {
if (!hasPermissions(sender, "purge"))
throw new InvalidUsage("You do not have permission to do that.");
Accounts.purge();
String tag = template.color(Template.Node.TAG_MONEY);
template.set(Template.Node.ACCOUNTS_PURGE);
Messaging.send(sender, tag + template.parse());
return false;
}
use of com.iCo6.IO.mini.Arguments in project Core by iConomy.
the class Remove method perform.
@Override
public boolean perform(CommandSender sender, LinkedHashMap<String, Argument> arguments) throws InvalidUsage {
if (!hasPermissions(sender, "remove"))
throw new InvalidUsage("You do not have permission to do that.");
String name = arguments.get("name").getStringValue();
String tag = template.color(Template.Node.TAG_MONEY);
if (name.equals("0"))
throw new InvalidUsage("Missing <white>name<rose>: /money remove <name>");
if (!Accounts.exists(name)) {
template.set(Template.Node.ERROR_ACCOUNT);
template.add("name", name);
Messaging.send(sender, tag + template.parse());
return false;
}
if (!Accounts.remove(name)) {
template.set(Template.Node.ERROR_CREATE);
template.add("name", name);
Messaging.send(sender, tag + template.parse());
return false;
}
template.set(Template.Node.ACCOUNTS_REMOVE);
template.add("name", name);
Messaging.send(sender, tag + template.parse());
return false;
}
use of com.iCo6.IO.mini.Arguments in project Core by iConomy.
the class MoneyComparator method createAccount.
static boolean createAccount(String name, Double balance, Integer status) {
Boolean created = false;
if (useMiniDB() || useInventoryDB() || useOrbDB()) {
if (hasAccount(name))
return false;
if (useOrbDB())
if (iConomy.Server.getPlayer(name) != null)
return false;
if (useInventoryDB())
if (inventory.dataExists(name))
return false;
Arguments Row = new Arguments(name);
Row.setValue("balance", balance);
Row.setValue("status", status);
database.addIndex(Row.getKey(), Row);
database.update();
return true;
}
try {
QueryRunner run = new QueryRunner();
Connection c = iConomy.Database.getConnection();
try {
String t = Constants.Nodes.DatabaseTable.toString();
Integer amount = run.update(c, "INSERT INTO " + t + "(username, balance, status) values (?, ?, ?)", name.toLowerCase(), balance, status);
if (amount > 0)
created = true;
} catch (SQLException ex) {
System.out.println("[iConomy] Error issueing SQL query: " + ex);
} finally {
DbUtils.close(c);
}
} catch (SQLException ex) {
System.out.println("[iConomy] Database Error: " + ex);
}
return false;
}
use of com.iCo6.IO.mini.Arguments in project Core by iConomy.
the class Mini method read.
private void read(boolean pushed) {
this.Database = new Manager(this.folder, this.database, true);
this.Database.removeDuplicates();
this.Database.read();
this.Indexes = new LinkedHashMap<String, Arguments>();
if (pushed)
this.pushedIndexes = new LinkedHashMap<String, Arguments>();
for (String line : this.Database.getLines()) {
if (line.trim().isEmpty())
continue;
String[] parsed = trim(line.trim().split(Dict.SPACER));
if (parsed[0].contains(Dict.ARGUMENT_SPLIT) || parsed[0].isEmpty())
continue;
Arguments entry = new Arguments(parseIndice(parsed[0]));
for (String item : parsed) {
if (!item.contains(Dict.ARGUMENT_SPLIT))
continue;
String[] map = trim(item.split(Dict.ARGUMENT_SPLIT, 2));
String key = map[0], value = map[1];
if (key == null)
continue;
entry.setValue(key, value);
}
this.Indexes.put(parseIndice(parsed[0]), entry);
}
}
use of com.iCo6.IO.mini.Arguments in project Core by iConomy.
the class Transactions method insert.
/**
* Insert a balance transaction change or update.
*
* @param data Transaction class
*/
public static void insert(Transaction data) {
if (!Constants.Nodes.Logging.getBoolean())
return;
if (Common.matches(iConomy.Database.getType().toString(), "inventorydb", "minidb", "orbdb")) {
Mini database = iConomy.Database.getTransactionDatabase();
if (database == null)
return;
Arguments entry = new Arguments(data.time);
entry.setValue("where", data.where);
entry.setValue("from", data.from);
entry.setValue("to", data.to);
entry.setValue("from_balance", data.fromBalance);
entry.setValue("to_balance", data.toBalance);
entry.setValue("gain", data.gain);
entry.setValue("loss", data.loss);
entry.setValue("set", data.set);
database.addIndex(entry);
database.update();
return;
}
}
Aggregations