summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-07-14 12:41:27 +0100
committerKHobbits <rob@khobbits.co.uk>2013-07-14 12:41:27 +0100
commit11f87eccb000b618a320ac5bad5f5f88852f1246 (patch)
treefc60e7ca70ae59363ca4750a12ee4339d3079d27
parent0d2dea41e3da531fcf14c0fef7df1605bf9066eb (diff)
downloadEssentials-11f87eccb000b618a320ac5bad5f5f88852f1246.tar
Essentials-11f87eccb000b618a320ac5bad5f5f88852f1246.tar.gz
Essentials-11f87eccb000b618a320ac5bad5f5f88852f1246.tar.lz
Essentials-11f87eccb000b618a320ac5bad5f5f88852f1246.tar.xz
Essentials-11f87eccb000b618a320ac5bad5f5f88852f1246.zip
Tidy and slightly expand user API
-rw-r--r--Essentials/src/com/earth2me/essentials/IUser.java88
-rw-r--r--Essentials/src/com/earth2me/essentials/User.java82
2 files changed, 113 insertions, 57 deletions
diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java
index a991c2d1a..fbd0e355d 100644
--- a/Essentials/src/com/earth2me/essentials/IUser.java
+++ b/Essentials/src/com/earth2me/essentials/IUser.java
@@ -2,44 +2,52 @@ package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.math.BigDecimal;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import net.ess3.api.ITeleport;
import org.bukkit.Location;
+import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
public interface IUser
{
- long getLastTeleportTimestamp();
-
boolean isAuthorized(String node);
boolean isAuthorized(IEssentialsCommand cmd);
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
- void setLastTeleportTimestamp(long time);
+ void healCooldown() throws Exception;
- Location getLastLocation();
+ void giveMoney(BigDecimal value);
- Player getBase();
+ void giveMoney(final BigDecimal value, final CommandSender initiator);
- BigDecimal getMoney();
+ void payUser(final User reciever, final BigDecimal value) throws Exception;
void takeMoney(BigDecimal value);
- void giveMoney(BigDecimal value);
+ void takeMoney(final BigDecimal value, final CommandSender initiator);
boolean canAfford(BigDecimal value);
- String getGroup();
+ Boolean canSpawnItem(final int itemId);
void setLastLocation();
- Location getHome(String name) throws Exception;
+ void setLogoutLocation();
- Location getHome(Location loc) throws Exception;
+ void requestTeleport(final User player, final boolean here);
+
+ ITeleport getTeleport();
+
+ BigDecimal getMoney();
+
+ void setMoney(final BigDecimal value);
+
+ void setAfk(final boolean set);
/**
* 'Hidden' Represents when a player is hidden from others. This status includes when the player is hidden via other
@@ -52,6 +60,22 @@ public interface IUser
void setHidden(boolean vanish);
+ boolean isGodModeEnabled();
+
+ String getGroup();
+
+ boolean inGroup(final String group);
+
+ boolean canBuild();
+
+ long getTeleportRequestTime();
+
+ void enableInvulnerabilityAfterTeleport();
+
+ void resetInvulnerabilityAfterTeleport();
+
+ boolean hasInvulnerabilityAfterTeleport();
+
/**
* 'Vanished' Represents when a player is hidden from others by Essentials. This status does NOT include when the
* player is hidden via other plugins. Use isHidden() if you want to check if a user is vanished by any supported
@@ -64,20 +88,44 @@ public interface IUser
void setVanished(boolean vanish);
- ITeleport getTeleport();
+ boolean isIgnoreExempt();
- void setJail(String jail);
+ public void sendMessage(String message);
- boolean isIgnoreExempt();
+ /*
+ * UserData
+ */
+
+ Location getHome(String name) throws Exception;
- boolean isAfk();
+ Location getHome(Location loc) throws Exception;
- void setAfk(final boolean set);
+ List<String> getHomes();
- void setLogoutLocation();
+ void setHome(String name, Location loc);
+
+ void delHome(String name) throws Exception;
+ boolean hasHome();
+
+ Location getLastLocation();
+
Location getLogoutLocation();
+
+ long getLastTeleportTimestamp();
+
+ void setLastTeleportTimestamp(long time);
+
+ String getJail();
+ void setJail(String jail);
+
+ List<String> getMails();
+
+ void addMail(String mail);
+
+ boolean isAfk();
+
void setConfigProperty(String node, Object object);
Set<String> getConfigKeys();
@@ -85,8 +133,12 @@ public interface IUser
Map<String, Object> getConfigMap();
Map<String, Object> getConfigMap(String node);
-
- public void sendMessage(String message);
+
+ /*
+ * PlayerExtension
+ */
+
+ Player getBase();
public String getName();
}
diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java
index c4392eb2c..19f29bfef 100644
--- a/Essentials/src/com/earth2me/essentials/User.java
+++ b/Essentials/src/com/earth2me/essentials/User.java
@@ -109,6 +109,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
}
+ @Override
public void healCooldown() throws Exception
{
final Calendar now = new GregorianCalendar();
@@ -133,6 +134,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
giveMoney(value, null);
}
+ @Override
public void giveMoney(final BigDecimal value, final CommandSender initiator)
{
if (value.signum() == 0)
@@ -147,6 +149,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
}
+ @Override
public void payUser(final User reciever, final BigDecimal value) throws Exception
{
if (value.signum() == 0)
@@ -172,6 +175,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
takeMoney(value, null);
}
+ @Override
public void takeMoney(final BigDecimal value, final CommandSender initiator)
{
if (value.signum() == 0)
@@ -212,50 +216,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
@Override
- public void setReplyTo(final CommandSender user)
- {
- replyTo = user;
- }
-
- @Override
- public CommandSender getReplyTo()
- {
- return replyTo;
- }
-
- @Override
- public int compareTo(final User other)
- {
- return FormatUtil.stripFormat(this.getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName()));
- }
-
- @Override
- public boolean equals(final Object object)
- {
- if (!(object instanceof User))
- {
- return false;
- }
- return this.getName().equalsIgnoreCase(((User)object).getName());
-
- }
-
- @Override
- public int hashCode()
- {
- return this.getName().hashCode();
- }
-
public Boolean canSpawnItem(final int itemId)
{
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
}
- public Location getHome() throws Exception
- {
- return getHome(getHomes().get(0));
- }
-
@Override
public void setLastLocation()
{
@@ -633,11 +598,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
return ess.getPermissionsHandler().getGroup(base);
}
+ @Override
public boolean inGroup(final String group)
{
return ess.getPermissionsHandler().inGroup(base, group);
}
+ @Override
public boolean canBuild()
{
if (isOp())
@@ -673,6 +640,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
private transient long teleportInvulnerabilityTimestamp = 0;
+ @Override
public void enableInvulnerabilityAfterTeleport()
{
final long time = ess.getSettings().getTeleportInvulnerability();
@@ -682,6 +650,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
}
}
+ @Override
public void resetInvulnerabilityAfterTeleport()
{
if (teleportInvulnerabilityTimestamp != 0
@@ -790,4 +759,39 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
base.sendMessage(message);
}
}
+
+ @Override
+ public void setReplyTo(final CommandSender user)
+ {
+ replyTo = user;
+ }
+
+ @Override
+ public CommandSender getReplyTo()
+ {
+ return replyTo;
+ }
+
+ @Override
+ public int compareTo(final User other)
+ {
+ return FormatUtil.stripFormat(this.getDisplayName()).compareToIgnoreCase(FormatUtil.stripFormat(other.getDisplayName()));
+ }
+
+ @Override
+ public boolean equals(final Object object)
+ {
+ if (!(object instanceof User))
+ {
+ return false;
+ }
+ return this.getName().equalsIgnoreCase(((User)object).getName());
+
+ }
+
+ @Override
+ public int hashCode()
+ {
+ return this.getName().hashCode();
+ }
}