mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-02-12 12:23:59 +00:00
Tidy and slightly expand user API
This commit is contained in:
parent
0d2dea41e3
commit
11f87eccb0
2 changed files with 118 additions and 62 deletions
|
@ -2,44 +2,52 @@ package com.earth2me.essentials;
|
||||||
|
|
||||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import net.ess3.api.ITeleport;
|
import net.ess3.api.ITeleport;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
|
||||||
public interface IUser
|
public interface IUser
|
||||||
{
|
{
|
||||||
long getLastTeleportTimestamp();
|
|
||||||
|
|
||||||
boolean isAuthorized(String node);
|
boolean isAuthorized(String node);
|
||||||
|
|
||||||
boolean isAuthorized(IEssentialsCommand cmd);
|
boolean isAuthorized(IEssentialsCommand cmd);
|
||||||
|
|
||||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||||
|
|
||||||
void setLastTeleportTimestamp(long time);
|
void healCooldown() throws Exception;
|
||||||
|
|
||||||
Location getLastLocation();
|
|
||||||
|
|
||||||
Player getBase();
|
|
||||||
|
|
||||||
BigDecimal getMoney();
|
|
||||||
|
|
||||||
void takeMoney(BigDecimal value);
|
|
||||||
|
|
||||||
void giveMoney(BigDecimal value);
|
void giveMoney(BigDecimal value);
|
||||||
|
|
||||||
|
void giveMoney(final BigDecimal value, final CommandSender initiator);
|
||||||
|
|
||||||
|
void payUser(final User reciever, final BigDecimal value) throws Exception;
|
||||||
|
|
||||||
|
void takeMoney(BigDecimal value);
|
||||||
|
|
||||||
|
void takeMoney(final BigDecimal value, final CommandSender initiator);
|
||||||
|
|
||||||
boolean canAfford(BigDecimal value);
|
boolean canAfford(BigDecimal value);
|
||||||
|
|
||||||
String getGroup();
|
Boolean canSpawnItem(final int itemId);
|
||||||
|
|
||||||
void setLastLocation();
|
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
|
* '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);
|
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
|
* '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
|
* 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);
|
void setVanished(boolean vanish);
|
||||||
|
|
||||||
ITeleport getTeleport();
|
boolean isIgnoreExempt();
|
||||||
|
|
||||||
|
public void sendMessage(String message);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* UserData
|
||||||
|
*/
|
||||||
|
|
||||||
|
Location getHome(String name) throws Exception;
|
||||||
|
|
||||||
|
Location getHome(Location loc) throws Exception;
|
||||||
|
|
||||||
|
List<String> getHomes();
|
||||||
|
|
||||||
|
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);
|
void setJail(String jail);
|
||||||
|
|
||||||
boolean isIgnoreExempt();
|
List<String> getMails();
|
||||||
|
|
||||||
|
void addMail(String mail);
|
||||||
|
|
||||||
boolean isAfk();
|
boolean isAfk();
|
||||||
|
|
||||||
void setAfk(final boolean set);
|
|
||||||
|
|
||||||
void setLogoutLocation();
|
|
||||||
|
|
||||||
Location getLogoutLocation();
|
|
||||||
|
|
||||||
void setConfigProperty(String node, Object object);
|
void setConfigProperty(String node, Object object);
|
||||||
|
|
||||||
Set<String> getConfigKeys();
|
Set<String> getConfigKeys();
|
||||||
|
@ -86,7 +134,11 @@ public interface IUser
|
||||||
|
|
||||||
Map<String, Object> getConfigMap(String node);
|
Map<String, Object> getConfigMap(String node);
|
||||||
|
|
||||||
public void sendMessage(String message);
|
/*
|
||||||
|
* PlayerExtension
|
||||||
|
*/
|
||||||
|
|
||||||
|
Player getBase();
|
||||||
|
|
||||||
public String getName();
|
public String getName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,6 +109,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void healCooldown() throws Exception
|
public void healCooldown() throws Exception
|
||||||
{
|
{
|
||||||
final Calendar now = new GregorianCalendar();
|
final Calendar now = new GregorianCalendar();
|
||||||
|
@ -133,6 +134,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
giveMoney(value, null);
|
giveMoney(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void giveMoney(final BigDecimal value, final CommandSender initiator)
|
public void giveMoney(final BigDecimal value, final CommandSender initiator)
|
||||||
{
|
{
|
||||||
if (value.signum() == 0)
|
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
|
public void payUser(final User reciever, final BigDecimal value) throws Exception
|
||||||
{
|
{
|
||||||
if (value.signum() == 0)
|
if (value.signum() == 0)
|
||||||
|
@ -172,6 +175,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
takeMoney(value, null);
|
takeMoney(value, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public void takeMoney(final BigDecimal value, final CommandSender initiator)
|
public void takeMoney(final BigDecimal value, final CommandSender initiator)
|
||||||
{
|
{
|
||||||
if (value.signum() == 0)
|
if (value.signum() == 0)
|
||||||
|
@ -212,50 +216,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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)
|
public Boolean canSpawnItem(final int itemId)
|
||||||
{
|
{
|
||||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location getHome() throws Exception
|
|
||||||
{
|
|
||||||
return getHome(getHomes().get(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setLastLocation()
|
public void setLastLocation()
|
||||||
{
|
{
|
||||||
|
@ -633,11 +598,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
return ess.getPermissionsHandler().getGroup(base);
|
return ess.getPermissionsHandler().getGroup(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean inGroup(final String group)
|
public boolean inGroup(final String group)
|
||||||
{
|
{
|
||||||
return ess.getPermissionsHandler().inGroup(base, group);
|
return ess.getPermissionsHandler().inGroup(base, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
public boolean canBuild()
|
public boolean canBuild()
|
||||||
{
|
{
|
||||||
if (isOp())
|
if (isOp())
|
||||||
|
@ -673,6 +640,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
}
|
}
|
||||||
private transient long teleportInvulnerabilityTimestamp = 0;
|
private transient long teleportInvulnerabilityTimestamp = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
public void enableInvulnerabilityAfterTeleport()
|
public void enableInvulnerabilityAfterTeleport()
|
||||||
{
|
{
|
||||||
final long time = ess.getSettings().getTeleportInvulnerability();
|
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()
|
public void resetInvulnerabilityAfterTeleport()
|
||||||
{
|
{
|
||||||
if (teleportInvulnerabilityTimestamp != 0
|
if (teleportInvulnerabilityTimestamp != 0
|
||||||
|
@ -790,4 +759,39 @@ public class User extends UserData implements Comparable<User>, IReplyTo, net.es
|
||||||
base.sendMessage(message);
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue