mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-06 04:23:02 +00:00
missed this from checkin oops
This commit is contained in:
parent
962b6848c4
commit
8a1fb88ecd
1 changed files with 54 additions and 38 deletions
|
@ -6,7 +6,6 @@ import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -20,44 +19,44 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
private boolean teleportRequestHere;
|
private boolean teleportRequestHere;
|
||||||
private final Teleport teleport;
|
private final Teleport teleport;
|
||||||
private long lastActivity;
|
private long lastActivity;
|
||||||
|
|
||||||
User(Player base, IEssentials ess)
|
User(Player base, IEssentials ess)
|
||||||
{
|
{
|
||||||
super(base, ess);
|
super(base, ess);
|
||||||
teleport = new Teleport(this, ess);
|
teleport = new Teleport(this, ess);
|
||||||
}
|
}
|
||||||
|
|
||||||
User update(Player base)
|
User update(Player base)
|
||||||
{
|
{
|
||||||
setBase(base);
|
setBase(base);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||||
{
|
{
|
||||||
return isAuthorized(cmd, "essentials.");
|
return isAuthorized(cmd, "essentials.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
||||||
{
|
{
|
||||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAuthorized(String node)
|
public boolean isAuthorized(String node)
|
||||||
{
|
{
|
||||||
if (isOp())
|
if (isOp())
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isJailed())
|
if (isJailed())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ess.getPermissionsHandler().hasPermission(this, node);
|
return ess.getPermissionsHandler().hasPermission(this, node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void healCooldown() throws Exception
|
public void healCooldown() throws Exception
|
||||||
{
|
{
|
||||||
Calendar now = new GregorianCalendar();
|
Calendar now = new GregorianCalendar();
|
||||||
|
@ -75,8 +74,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
setLastHealTimestamp(now.getTimeInMillis());
|
setLastHealTimestamp(now.getTimeInMillis());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void giveMoney(double value)
|
public void giveMoney(double value)
|
||||||
|
{
|
||||||
|
giveMoney(value, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveMoney(double value, CommandSender initiator)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
|
@ -84,8 +88,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
setMoney(getMoney() + value);
|
setMoney(getMoney() + value);
|
||||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value)));
|
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value)));
|
||||||
|
if (initiator != null)
|
||||||
|
{
|
||||||
|
initiator.sendMessage((Util.format("addedToAccount", Util.formatCurrency(value))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void payUser(User reciever, double value) throws Exception
|
public void payUser(User reciever, double value) throws Exception
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
|
@ -104,8 +112,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void takeMoney(double value)
|
public void takeMoney(double value)
|
||||||
|
{
|
||||||
|
takeMoney(value, null);
|
||||||
|
}
|
||||||
|
public void takeMoney(double value, CommandSender initiator)
|
||||||
{
|
{
|
||||||
if (value == 0)
|
if (value == 0)
|
||||||
{
|
{
|
||||||
|
@ -113,44 +125,48 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
setMoney(getMoney() - value);
|
setMoney(getMoney() - value);
|
||||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value)));
|
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value)));
|
||||||
|
if (initiator != null)
|
||||||
|
{
|
||||||
|
initiator.sendMessage((Util.format("addedToAccount", Util.formatCurrency(value))));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canAfford(double cost)
|
public boolean canAfford(double cost)
|
||||||
{
|
{
|
||||||
double mon = getMoney();
|
double mon = getMoney();
|
||||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose()
|
public void dispose()
|
||||||
{
|
{
|
||||||
this.base = new OfflinePlayer(getName());
|
this.base = new OfflinePlayer(getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getJustPortaled()
|
public boolean getJustPortaled()
|
||||||
{
|
{
|
||||||
return justPortaled;
|
return justPortaled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJustPortaled(boolean value)
|
public void setJustPortaled(boolean value)
|
||||||
{
|
{
|
||||||
justPortaled = value;
|
justPortaled = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplyTo(CommandSender user)
|
public void setReplyTo(CommandSender user)
|
||||||
{
|
{
|
||||||
replyTo = user;
|
replyTo = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CommandSender getReplyTo()
|
public CommandSender getReplyTo()
|
||||||
{
|
{
|
||||||
return replyTo;
|
return replyTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int compareTo(User t)
|
public int compareTo(User t)
|
||||||
{
|
{
|
||||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o)
|
public boolean equals(Object o)
|
||||||
{
|
{
|
||||||
|
@ -159,51 +175,51 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode()
|
public int hashCode()
|
||||||
{
|
{
|
||||||
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean canSpawnItem(int itemId)
|
public Boolean canSpawnItem(int itemId)
|
||||||
{
|
{
|
||||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome()
|
public void setHome()
|
||||||
{
|
{
|
||||||
setHome(getLocation(), true);
|
setHome(getLocation(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHome(boolean defaultHome)
|
public void setHome(boolean defaultHome)
|
||||||
{
|
{
|
||||||
setHome(getLocation(), defaultHome);
|
setHome(getLocation(), defaultHome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastLocation()
|
public void setLastLocation()
|
||||||
{
|
{
|
||||||
setLastLocation(getLocation());
|
setLastLocation(getLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestTeleport(User player, boolean here)
|
public void requestTeleport(User player, boolean here)
|
||||||
{
|
{
|
||||||
teleportRequester = player;
|
teleportRequester = player;
|
||||||
teleportRequestHere = here;
|
teleportRequestHere = here;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getTeleportRequest()
|
public User getTeleportRequest()
|
||||||
{
|
{
|
||||||
return teleportRequester;
|
return teleportRequester;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTeleportRequestHere()
|
public boolean isTeleportRequestHere()
|
||||||
{
|
{
|
||||||
return teleportRequestHere;
|
return teleportRequestHere;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getNick()
|
public String getNick()
|
||||||
{
|
{
|
||||||
String nickname = getNickname();
|
String nickname = getNickname();
|
||||||
|
@ -227,22 +243,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
return nickname;
|
return nickname;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Teleport getTeleport()
|
public Teleport getTeleport()
|
||||||
{
|
{
|
||||||
return teleport;
|
return teleport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getLastActivity()
|
public long getLastActivity()
|
||||||
{
|
{
|
||||||
return lastActivity;
|
return lastActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLastActivity(long timestamp)
|
public void setLastActivity(long timestamp)
|
||||||
{
|
{
|
||||||
lastActivity = timestamp;
|
lastActivity = timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double getMoney()
|
public double getMoney()
|
||||||
{
|
{
|
||||||
|
@ -264,7 +280,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
return super.getMoney();
|
return super.getMoney();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMoney(double value)
|
public void setMoney(double value)
|
||||||
{
|
{
|
||||||
|
@ -286,14 +302,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
}
|
}
|
||||||
super.setMoney(value);
|
super.setMoney(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setAfk(boolean set)
|
public void setAfk(boolean set)
|
||||||
{
|
{
|
||||||
this.setSleepingIgnored(set);
|
this.setSleepingIgnored(set);
|
||||||
super.setAfk(set);
|
super.setAfk(set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean toggleAfk()
|
public boolean toggleAfk()
|
||||||
{
|
{
|
||||||
|
@ -301,4 +317,4 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||||
this.setSleepingIgnored(now);
|
this.setSleepingIgnored(now);
|
||||||
return now;
|
return now;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue