diff --git a/src/com/massivecraft/mcore/money/Money.java b/src/com/massivecraft/mcore/money/Money.java index 0ff613e8..6a01f63f 100644 --- a/src/com/massivecraft/mcore/money/Money.java +++ b/src/com/massivecraft/mcore/money/Money.java @@ -20,6 +20,10 @@ public class Money public static String accountId(Object account) { + // It's OK to send to or from null... + if (account == null) return null; + + // ... but if something is supplied we must manage to extract an id. String ret = MUtil.extract(String.class, "accountId", account); if (ret == null) throw new IllegalArgumentException("extraction of accountId from object failed"); return ret; @@ -100,82 +104,82 @@ public class Money // MOVE - public static boolean move(double amount, Object cause, Object from, Object to, Collection categories) + public static boolean move(Object from, Object to, Object by, double amount, Collection categories) { if (disabled()) return false; - return mixin.move(amount, accountId(cause), accountId(from), accountId(to), categories); + return mixin.move(accountId(from), accountId(to), accountId(by), amount, categories); } - public static boolean move(double amount, Object cause, Object from, Object to, String... categories) + public static boolean move(Object from, Object to, Object by, double amount, String... categories) { if (disabled()) return false; - return mixin.move(amount, accountId(cause), accountId(from), accountId(to), categories); + return mixin.move(accountId(from), accountId(to), accountId(by), amount, categories); } - public static boolean move(double amount, Object cause, Object from, Object to) + public static boolean move(Object from, Object to, Object by, double amount) { if (disabled()) return false; - return mixin.move(amount, accountId(cause), accountId(from), accountId(to)); + return mixin.move(accountId(from), accountId(to), accountId(by), amount); } // SPAWN - public static boolean spawn(double amount, Object cause, Object to, Collection categories) + public static boolean spawn(Object to, Object by, double amount, Collection categories) { if (disabled()) return false; - return mixin.spawn(amount, accountId(cause), accountId(to), categories); + return mixin.spawn(accountId(to), accountId(by), amount, categories); } - public static boolean spawn(double amount, Object cause, Object to, String... categories) + public static boolean spawn(Object to, Object by, double amount, String... categories) { if (disabled()) return false; - return mixin.spawn(amount, accountId(cause), accountId(to), categories); + return mixin.spawn(accountId(to), accountId(by), amount, categories); } - public static boolean spawn(double amount, Object cause, Object toId) + public static boolean spawn(Object toId, Object by, double amount) { if (disabled()) return false; - return mixin.spawn(amount, accountId(cause), accountId(toId)); + return mixin.spawn(accountId(toId), accountId(by), amount); } // DESPAWN - public static boolean despawn(double amount, Object cause, Object from, Collection categories) + public static boolean despawn(Object from, Object by, double amount, Collection categories) { if (disabled()) return false; - return mixin.despawn(amount, accountId(cause), accountId(from), categories); + return mixin.despawn(accountId(from), accountId(by), amount, categories); } - public static boolean despawn(double amount, Object cause, Object from, String... categories) + public static boolean despawn(Object from, Object by, double amount, String... categories) { if (disabled()) return false; - return mixin.despawn(amount, accountId(cause), accountId(from), categories); + return mixin.despawn(accountId(from), accountId(by), amount, categories); } - public static boolean despawn(double amount, Object cause, Object from) + public static boolean despawn(Object from, Object by, double amount) { if (disabled()) return false; - return mixin.despawn(amount, accountId(cause), accountId(from)); + return mixin.despawn(accountId(from), accountId(by), amount); } // SET - public static boolean set(double amount, Object cause, Object account, Collection categories) + public static boolean set(Object account, Object by, double amount, Collection categories) { if (disabled()) return false; - return mixin.set(amount, accountId(cause), accountId(account), categories); + return mixin.set(accountId(account), accountId(by), amount, categories); } - public static boolean set(double amount, Object cause, Object account, String... categories) + public static boolean set(Object account, Object by, double amount, String... categories) { if (disabled()) return false; - return mixin.set(amount, accountId(cause), accountId(account), categories); + return mixin.set(accountId(account), accountId(by), amount, categories); } - public static boolean set(double amount, Object cause, Object account) + public static boolean set(Object account, Object by, double amount) { if (disabled()) return false; - return mixin.set(amount, accountId(cause), accountId(account)); + return mixin.set(accountId(account), accountId(by), amount); } } diff --git a/src/com/massivecraft/mcore/money/MoneyMixin.java b/src/com/massivecraft/mcore/money/MoneyMixin.java index c1a368d3..51233402 100644 --- a/src/com/massivecraft/mcore/money/MoneyMixin.java +++ b/src/com/massivecraft/mcore/money/MoneyMixin.java @@ -36,20 +36,20 @@ public interface MoneyMixin // MODIFY // -------------------------------------------- // - public boolean move(double amount, String causeId, String fromId, String toId, Collection categories); - public boolean move(double amount, String causeId, String fromId, String toId, String... categories); - public boolean move(double amount, String causeId, String fromId, String toId); + public boolean move(String fromId, String toId, String byId, double amount, Collection categories); + public boolean move(String fromId, String toId, String byId, double amount, String... categories); + public boolean move(String fromId, String toId, String byId, double amount); - public boolean spawn(double amount, String causeId, String toId, Collection categories); - public boolean spawn(double amount, String causeId, String toId, String... categories); - public boolean spawn(double amount, String causeId, String toId); + public boolean spawn(String toId, String byId, double amount, Collection categories); + public boolean spawn(String toId, String byId, double amount, String... categories); + public boolean spawn(String toId, String byId, double amount); - public boolean despawn(double amount, String causeId, String fromId, Collection categories); - public boolean despawn(double amount, String causeId, String fromId, String... categories); - public boolean despawn(double amount, String causeId, String fromId); + public boolean despawn(String fromId, String byId, double amount, Collection categories); + public boolean despawn(String fromId, String byId, double amount, String... categories); + public boolean despawn(String fromId, String byId, double amount); - public boolean set(double amount, String causeId, String accountId, Collection categories); - public boolean set(double amount, String causeId, String accountId, String... categories); - public boolean set(double amount, String causeId, String accountId); + public boolean set(String accountId, String byId, double amount, Collection categories); + public boolean set(String accountId, String byId, double amount, String... categories); + public boolean set(String accountId, String byId, double amount); } diff --git a/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java b/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java index be39ab4a..536794a9 100644 --- a/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java +++ b/src/com/massivecraft/mcore/money/MoneyMixinAbstract.java @@ -12,73 +12,76 @@ public abstract class MoneyMixinAbstract implements MoneyMixin // MOVE - /*public boolean move(double amount, String causeId, String fromId, String toId, Collection categories) + // this is the abstract one + /* + public boolean move(String fromId, String toId, String byId, double amount, Collection categories) { - // LOL this one shall be abstract still :3 + // TODO Auto-generated method stub + return false; }*/ - public boolean move(double amount, String causeId, String fromId, String toId, String... categories) + public boolean move(String fromId, String toId, String byId, double amount, String... categories) { - return this.move(amount, causeId, fromId, toId, Arrays.asList(categories)); + return this.move(fromId, toId, byId, amount, Arrays.asList(categories)); } - public boolean move(double amount, String causeId, String fromId, String toId) + public boolean move(String fromId, String toId, String byId, double amount) { - return this.move(amount, causeId, fromId, toId, new ArrayList()); + return this.move(fromId, toId, byId, amount, new ArrayList()); } // SPAWN - public boolean spawn(double amount, String causeId, String toId, Collection categories) + public boolean spawn(String toId, String byId, double amount, Collection categories) { // Based on Move - return this.move(amount, causeId, null, toId, categories); + return this.move(null, toId, byId, amount, categories); } - public boolean spawn(double amount, String causeId, String toId, String... categories) + public boolean spawn(String toId, String byId, double amount, String... categories) { - return this.spawn(amount, causeId, toId, Arrays.asList(categories)); + return this.spawn(toId, byId, amount, Arrays.asList(categories)); } - public boolean spawn(double amount, String causeId, String toId) + public boolean spawn(String toId, String byId, double amount) { - return this.spawn(amount, causeId, toId, new ArrayList()); + return this.spawn(toId, byId, amount, new ArrayList()); } // DESPAWN - public boolean despawn(double amount, String causeId, String fromId, Collection categories) + public boolean despawn(String fromId, String byId, double amount, Collection categories) { // Based on Move - return this.move(amount, causeId, fromId, null, categories); + return this.move(fromId, null, byId, amount, categories); } - public boolean despawn(double amount, String causeId, String fromId, String... categories) + public boolean despawn(String fromId, String byId, double amount, String... categories) { - return this.despawn(amount, causeId, fromId, Arrays.asList(categories)); + return this.despawn(fromId, byId, amount, Arrays.asList(categories)); } - public boolean despawn(double amount, String causeId, String fromId) + public boolean despawn(String fromId, String byId, double amount) { - return this.despawn(amount, causeId, fromId, new ArrayList()); + return this.despawn(fromId, byId, amount, new ArrayList()); } // SET - public boolean set(double amount, String causeId, String accountId, Collection categories) + public boolean set(String accountId, String byId, double amount, Collection categories) { // Based on Move - return this.move(amount - this.get(accountId), causeId, null, accountId, categories); + return this.move(null, accountId, byId, amount - this.get(accountId), categories); } - public boolean set(double amount, String causeId, String accountId, String... categories) + public boolean set(String accountId, String byId, double amount, String... categories) { - return this.set(amount, causeId, accountId, Arrays.asList(categories)); + return this.set(accountId, byId, amount, Arrays.asList(categories)); } - public boolean set(double amount, String causeId, String accountId) + public boolean set(String accountId, String byId, double amount) { - return this.set(amount, causeId, accountId, new ArrayList()); + return this.set(accountId, byId, amount, new ArrayList()); } } \ No newline at end of file diff --git a/src/com/massivecraft/mcore/money/MoneyMixinVault.java b/src/com/massivecraft/mcore/money/MoneyMixinVault.java index 9b57fca7..8c0a7b60 100644 --- a/src/com/massivecraft/mcore/money/MoneyMixinVault.java +++ b/src/com/massivecraft/mcore/money/MoneyMixinVault.java @@ -117,7 +117,7 @@ public class MoneyMixinVault extends MoneyMixinAbstract // -------------------------------------------- // @Override - public boolean move(double amount, String causeId, String fromId, String toId, Collection categories) + public boolean move(String fromId, String toId, String byId, double amount, Collection categories) { // Ensure positive direction if (amount < 0)