From d3dd8208ef32259cb5f27c3ccd0269e098882fa9 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 13 Dec 2011 04:29:16 +0000 Subject: [PATCH] Fixing Sell/Buy Signs which use EXP as a currency. --- .../src/com/earth2me/essentials/IUser.java | 4 ++-- .../src/com/earth2me/essentials/Trade.java | 8 ++++---- .../src/com/earth2me/essentials/User.java | 17 +++++++++++++++++ .../src/com/earth2me/essentials/user/User.java | 13 +++++++++++++ 4 files changed, 36 insertions(+), 6 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index 09d3c294d..c7038e905 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -65,7 +65,7 @@ public interface IUser void setJail(String jail); - public int getTotalExperience(); + public int getXP(); - public void setTotalExperience(int l); + public void setXP(int l); } diff --git a/Essentials/src/com/earth2me/essentials/Trade.java b/Essentials/src/com/earth2me/essentials/Trade.java index 1c8e20db9..8ca6ede1b 100644 --- a/Essentials/src/com/earth2me/essentials/Trade.java +++ b/Essentials/src/com/earth2me/essentials/Trade.java @@ -80,7 +80,7 @@ public class Trade } if (exp != null && exp > 0 - && user.getTotalExperience() < exp) { + && user.getXP() < exp) { throw new ChargeException(_("notEnoughExperience")); } } @@ -115,7 +115,7 @@ public class Trade } if (getExperience() != null) { - user.setTotalExperience(user.getTotalExperience() + getExperience()); + user.setXP(user.getXP() + getExperience()); } return success; } @@ -154,12 +154,12 @@ public class Trade } if (getExperience() != null) { - final int experience = user.getTotalExperience(); + final int experience = user.getXP(); if (experience < getExperience() && getExperience() > 0) { throw new ChargeException(_("notEnoughExperience")); } - user.setTotalExperience(experience - getExperience()); + user.setXP(experience - getExperience()); } } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 8c678d734..6f389f749 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -544,4 +544,21 @@ public class User extends UserData implements Comparable, IReplyTo, IUser { return teleportRequestTime; } + + @Override + public int getXP() { + return base.getTotalExperience(); + } + + @Override + public void setXP(int l) { + base.setExp(0); + base.setLevel(0); + base.setTotalExperience(0); + for(int i=0;i