summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2011-09-22 10:46:23 +0200
committersnowleo <schneeleo@gmail.com>2011-09-22 10:46:23 +0200
commit91b504cc66783add6589f29648d0aa6b825a1ab9 (patch)
tree0c8031e51b05605e13ff867a6d30c2d76d1de917
parent6ea57bcd2fcae5b83cd8c690f9cb59d4723de30e (diff)
downloadEssentials-91b504cc66783add6589f29648d0aa6b825a1ab9.tar
Essentials-91b504cc66783add6589f29648d0aa6b825a1ab9.tar.gz
Essentials-91b504cc66783add6589f29648d0aa6b825a1ab9.tar.lz
Essentials-91b504cc66783add6589f29648d0aa6b825a1ab9.tar.xz
Essentials-91b504cc66783add6589f29648d0aa6b825a1ab9.zip
Correctly implement food level on god mode
-rw-r--r--Essentials/src/com/earth2me/essentials/Essentials.java1
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsTimer.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java9
3 files changed, 10 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java
index 518e853bb..c98671d94 100644
--- a/Essentials/src/com/earth2me/essentials/Essentials.java
+++ b/Essentials/src/com/earth2me/essentials/Essentials.java
@@ -188,6 +188,7 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
+ pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
jail = new Jail(this);
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
index ab19450f8..f3b447dae 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsTimer.java
@@ -26,10 +26,6 @@ public class EssentialsTimer implements Runnable
onlineUsers.add(user);
user.setLastOnlineActivity(currentTime);
user.checkActivity();
- // Food for god mode
- if (user.isGodModeEnabled() && user.getFoodLevel() < 20) {
- user.setFoodLevel(20);
- }
}
final Iterator<User> iterator = onlineUsers.iterator();
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index 2f4fc2951..736274de0 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -464,4 +464,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
return afkPosition;
}
+
+ @Override
+ public boolean toggleGodModeEnabled()
+ {
+ if (!isGodModeEnabled()) {
+ setFoodLevel(20);
+ }
+ return super.toggleGodModeEnabled();
+ }
}