2011-03-30 06:03:21 +02:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
2011-11-21 02:55:26 +01:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-03-30 06:03:21 +02:00
|
|
|
import com.earth2me.essentials.commands.IEssentialsCommand;
|
2011-05-14 01:39:18 +02:00
|
|
|
import com.earth2me.essentials.register.payment.Method;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.GregorianCalendar;
|
2011-11-19 00:08:16 +01:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2012-08-03 22:57:29 +02:00
|
|
|
import org.bukkit.ChatColor;
|
2011-08-23 04:42:32 +02:00
|
|
|
import org.bukkit.Location;
|
2011-04-05 17:57:54 +02:00
|
|
|
import org.bukkit.command.CommandSender;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
import org.bukkit.entity.Player;
|
2012-08-28 03:06:11 +02:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
2011-03-30 06:03:21 +02:00
|
|
|
|
|
|
|
|
2011-06-01 12:40:12 +02:00
|
|
|
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-04-05 17:57:54 +02:00
|
|
|
private CommandSender replyTo = null;
|
2011-08-27 13:59:39 +02:00
|
|
|
private transient User teleportRequester;
|
|
|
|
private transient boolean teleportRequestHere;
|
2012-05-17 12:25:02 +02:00
|
|
|
private transient boolean vanished;
|
2011-08-27 13:59:39 +02:00
|
|
|
private transient final Teleport teleport;
|
2011-12-09 00:43:09 +01:00
|
|
|
private transient long teleportRequestTime;
|
2011-08-31 12:51:59 +02:00
|
|
|
private transient long lastOnlineActivity;
|
2012-06-17 20:28:59 +02:00
|
|
|
private transient long lastThrottledAction;
|
2011-08-27 22:29:57 +02:00
|
|
|
private transient long lastActivity = System.currentTimeMillis();
|
2011-07-18 03:42:21 +02:00
|
|
|
private boolean hidden = false;
|
2012-08-31 01:47:53 +02:00
|
|
|
private boolean rightClickJump = false;
|
2012-01-16 00:50:52 +01:00
|
|
|
private transient Location afkPosition = null;
|
2012-03-25 11:44:33 +02:00
|
|
|
private boolean invSee = false;
|
2012-08-21 21:02:20 +02:00
|
|
|
private boolean enderSee = false;
|
2011-11-19 00:08:16 +01:00
|
|
|
private static final Logger logger = Logger.getLogger("Minecraft");
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
User(final Player base, final IEssentials ess)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
super(base, ess);
|
|
|
|
teleport = new Teleport(this, ess);
|
2012-01-16 00:50:52 +01:00
|
|
|
if (isAfk())
|
|
|
|
{
|
|
|
|
afkPosition = getLocation();
|
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
User update(final Player base)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
|
|
|
setBase(base);
|
|
|
|
return this;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final IEssentialsCommand cmd)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-06-26 15:47:28 +02:00
|
|
|
return isAuthorized(cmd, "essentials.");
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
2011-06-26 15:47:28 +02:00
|
|
|
{
|
|
|
|
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final String node)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2012-09-16 21:27:35 +02:00
|
|
|
final boolean result = isAuthorizedCheck(node);
|
2012-03-26 14:28:32 +02:00
|
|
|
if (ess.getSettings().isDebug())
|
|
|
|
{
|
2012-09-16 21:27:35 +02:00
|
|
|
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node + " - " + result);
|
2012-03-26 14:28:32 +02:00
|
|
|
}
|
2012-09-16 21:27:35 +02:00
|
|
|
return result;
|
|
|
|
}
|
2012-11-04 22:49:48 +01:00
|
|
|
|
|
|
|
private boolean isAuthorizedCheck(final String node)
|
2012-09-16 21:27:35 +02:00
|
|
|
{
|
|
|
|
|
2011-08-31 12:51:59 +02:00
|
|
|
if (base instanceof OfflinePlayer)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-03-30 06:03:21 +02:00
|
|
|
if (isJailed())
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
{
|
2011-03-30 06:03:21 +02:00
|
|
|
return false;
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-03-22 00:54:57 +01:00
|
|
|
try
|
|
|
|
{
|
2012-03-16 00:15:19 +01:00
|
|
|
return ess.getPermissionsHandler().hasPermission(base, node);
|
|
|
|
}
|
2012-03-22 00:54:57 +01:00
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2012-09-02 19:30:59 +02:00
|
|
|
if (ess.getSettings().isDebug())
|
|
|
|
{
|
|
|
|
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage(), ex);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
|
|
|
}
|
|
|
|
|
2012-03-16 00:15:19 +01:00
|
|
|
return false;
|
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-03-30 06:03:21 +02:00
|
|
|
public void healCooldown() throws Exception
|
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
final Calendar now = new GregorianCalendar();
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
if (getLastHealTimestamp() > 0)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
final double cooldown = ess.getSettings().getHealCooldown();
|
|
|
|
final Calendar cooldownTime = new GregorianCalendar();
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
|
|
|
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
|
|
|
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
|
|
|
if (cooldownTime.after(now) && !isAuthorized("essentials.heal.cooldown.bypass"))
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2011-11-21 02:55:26 +01:00
|
|
|
throw new Exception(_("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
setLastHealTimestamp(now.getTimeInMillis());
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public void giveMoney(final double value)
|
2011-07-08 13:29:06 +02:00
|
|
|
{
|
|
|
|
giveMoney(value, null);
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void giveMoney(final double value, final CommandSender initiator)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2012-08-31 18:47:35 +02:00
|
|
|
if (value == 0.0d)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
return;
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
|
|
|
setMoney(getMoney() + value);
|
2012-03-04 11:11:58 +01:00
|
|
|
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
2011-07-08 13:29:06 +02:00
|
|
|
if (initiator != null)
|
|
|
|
{
|
2012-03-04 11:11:58 +01:00
|
|
|
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
2011-07-08 13:29:06 +02:00
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void payUser(final User reciever, final double value) throws Exception
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2012-08-31 18:47:35 +02:00
|
|
|
if (value == 0.0d)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
if (canAfford(value))
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
|
|
|
setMoney(getMoney() - value);
|
|
|
|
reciever.setMoney(reciever.getMoney() + value);
|
2012-03-04 11:11:58 +01:00
|
|
|
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
|
|
|
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
else
|
|
|
|
{
|
2011-11-21 02:55:26 +01:00
|
|
|
throw new Exception(_("notEnoughMoney"));
|
2011-08-27 13:59:39 +02:00
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public void takeMoney(final double value)
|
2011-07-08 13:29:06 +02:00
|
|
|
{
|
|
|
|
takeMoney(value, null);
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void takeMoney(final double value, final CommandSender initiator)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2012-08-31 18:47:35 +02:00
|
|
|
if (value == 0.0d)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
setMoney(getMoney() - value);
|
2012-03-04 11:11:58 +01:00
|
|
|
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
2011-07-08 13:29:06 +02:00
|
|
|
if (initiator != null)
|
|
|
|
{
|
2012-03-04 11:11:58 +01:00
|
|
|
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
2011-07-08 13:29:06 +02:00
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-04-24 12:30:31 +02:00
|
|
|
@Override
|
2011-08-27 13:59:39 +02:00
|
|
|
public boolean canAfford(final double cost)
|
2012-02-26 05:15:14 +01:00
|
|
|
{
|
|
|
|
return canAfford(cost, true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean canAfford(final double cost, final boolean permcheck)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2012-08-31 18:47:35 +02:00
|
|
|
if (cost <= 0.0d)
|
2012-08-28 03:06:11 +02:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
final double mon = getMoney();
|
2012-02-26 05:15:14 +01:00
|
|
|
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
|
|
|
{
|
2012-02-26 06:10:04 +01:00
|
|
|
return (mon - cost) >= ess.getSettings().getMinMoney();
|
2012-02-26 05:15:14 +01:00
|
|
|
}
|
|
|
|
return cost <= mon;
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-03-30 06:03:21 +02:00
|
|
|
public void dispose()
|
|
|
|
{
|
2011-07-16 01:33:22 +02:00
|
|
|
this.base = new OfflinePlayer(getName(), ess);
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public void setReplyTo(final CommandSender user)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
|
|
|
replyTo = user;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
2011-04-05 17:57:54 +02:00
|
|
|
public CommandSender getReplyTo()
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
|
|
|
return replyTo;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public int compareTo(final User other)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2012-03-22 23:07:13 +01:00
|
|
|
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-06-01 12:40:12 +02:00
|
|
|
@Override
|
2011-08-27 13:59:39 +02:00
|
|
|
public boolean equals(final Object object)
|
2011-06-01 12:40:12 +02:00
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
if (!(object instanceof User))
|
2011-06-01 12:40:12 +02:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-09 22:42:36 +01:00
|
|
|
return this.getName().equalsIgnoreCase(((User)object).getName());
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-06-01 12:40:12 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-06-01 12:40:12 +02:00
|
|
|
@Override
|
|
|
|
public int hashCode()
|
|
|
|
{
|
2011-12-13 08:38:15 +01:00
|
|
|
return this.getName().hashCode();
|
2011-06-01 12:40:12 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public Boolean canSpawnItem(final int itemId)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-24 06:18:35 +02:00
|
|
|
public Location getHome() throws Exception
|
2011-08-23 04:42:32 +02:00
|
|
|
{
|
|
|
|
return getHome(getHomes().get(0));
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
public void setLastLocation()
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
setLastLocation(getLocation());
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void requestTeleport(final User player, final boolean here)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-12-09 00:43:09 +01:00
|
|
|
teleportRequestTime = System.currentTimeMillis();
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
teleportRequester = player;
|
|
|
|
teleportRequestHere = here;
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
public User getTeleportRequest()
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
return teleportRequester;
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-03-20 14:26:49 +01:00
|
|
|
public boolean isTpRequestHere()
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
return teleportRequestHere;
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-05-13 19:58:50 +02:00
|
|
|
public String getNick(final boolean longnick)
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
final StringBuilder prefix = new StringBuilder();
|
|
|
|
String nickname;
|
2012-06-16 18:42:42 +02:00
|
|
|
String suffix = "";
|
2011-07-15 20:35:09 +02:00
|
|
|
final String nick = getNickname();
|
|
|
|
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
nickname = getName();
|
2011-04-03 22:21:20 +02:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
else
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
nickname = ess.getSettings().getNicknamePrefix() + nick;
|
2011-04-03 22:39:39 +02:00
|
|
|
}
|
2012-03-02 20:05:30 +01:00
|
|
|
|
2012-05-13 19:58:50 +02:00
|
|
|
if (isOp())
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2012-03-04 05:43:00 +01:00
|
|
|
try
|
2011-05-10 22:40:32 +02:00
|
|
|
{
|
2012-08-03 22:57:29 +02:00
|
|
|
final ChatColor opPrefix = ess.getSettings().getOperatorColor();
|
|
|
|
if (opPrefix != null && opPrefix.toString().length() > 0)
|
2012-03-12 02:00:57 +01:00
|
|
|
{
|
2012-08-03 22:57:29 +02:00
|
|
|
prefix.insert(0, opPrefix.toString());
|
2012-08-30 21:43:33 +02:00
|
|
|
suffix = "§r";
|
2012-03-04 09:18:25 +01:00
|
|
|
}
|
2011-05-10 22:40:32 +02:00
|
|
|
}
|
2012-03-04 05:43:00 +01:00
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
2012-05-13 19:58:50 +02:00
|
|
|
|
|
|
|
if (ess.getSettings().addPrefixSuffix())
|
2012-03-04 05:43:00 +01:00
|
|
|
{
|
2012-10-06 04:31:34 +02:00
|
|
|
//These two extra toggles are not documented, because they are mostly redundant #EasterEgg
|
2011-10-27 07:17:18 +02:00
|
|
|
if (!ess.getSettings().disablePrefix())
|
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
|
|
|
prefix.insert(0, ptext);
|
2012-08-30 21:43:33 +02:00
|
|
|
suffix = "§r";
|
2011-10-27 07:17:18 +02:00
|
|
|
}
|
|
|
|
if (!ess.getSettings().disableSuffix())
|
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
2012-08-30 21:43:33 +02:00
|
|
|
suffix = stext + "§r";
|
|
|
|
suffix = suffix.replace("§f§f", "§f").replace("§f§r", "§r").replace("§r§r", "§r");
|
2011-07-23 01:43:02 +02:00
|
|
|
}
|
2011-07-20 18:36:29 +02:00
|
|
|
}
|
2012-05-13 19:58:50 +02:00
|
|
|
final String strPrefix = prefix.toString();
|
|
|
|
String output = strPrefix + nickname + suffix;
|
|
|
|
if (!longnick && output.length() > 16)
|
|
|
|
{
|
|
|
|
output = strPrefix + nickname;
|
|
|
|
}
|
|
|
|
if (!longnick && output.length() > 16)
|
|
|
|
{
|
|
|
|
output = Util.lastCode(strPrefix) + nickname;
|
|
|
|
}
|
|
|
|
if (!longnick && output.length() > 16)
|
|
|
|
{
|
|
|
|
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
|
|
|
|
}
|
2012-08-03 22:57:29 +02:00
|
|
|
if (output.charAt(output.length() - 1) == '§')
|
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
output = output.substring(0, output.length() - 1);
|
|
|
|
}
|
|
|
|
return output;
|
2011-04-03 22:21:20 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-11-20 16:43:38 +01:00
|
|
|
public void setDisplayNick()
|
2011-10-04 08:21:09 +02:00
|
|
|
{
|
2012-03-22 00:54:57 +01:00
|
|
|
if (base.isOnline() && ess.getSettings().changeDisplayName())
|
2011-11-19 00:08:16 +01:00
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
setDisplayName(getNick(true));
|
2012-03-23 01:15:22 +01:00
|
|
|
if (ess.getSettings().changePlayerListName())
|
2012-03-22 00:54:57 +01:00
|
|
|
{
|
2012-05-13 19:58:50 +02:00
|
|
|
String name = getNick(false);
|
2012-03-23 01:15:22 +01:00
|
|
|
try
|
|
|
|
{
|
|
|
|
setPlayerListName(name);
|
|
|
|
}
|
|
|
|
catch (IllegalArgumentException e)
|
2012-03-22 00:54:57 +01:00
|
|
|
{
|
2012-03-23 01:15:22 +01:00
|
|
|
if (ess.getSettings().isDebug())
|
|
|
|
{
|
|
|
|
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Name clashed with another online player.");
|
|
|
|
}
|
2012-03-22 00:54:57 +01:00
|
|
|
}
|
2012-03-18 04:29:49 +01:00
|
|
|
}
|
2011-11-19 00:08:16 +01:00
|
|
|
}
|
2011-10-04 08:21:09 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-10-21 01:23:35 +02:00
|
|
|
@Override
|
|
|
|
public String getDisplayName()
|
|
|
|
{
|
|
|
|
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-03-02 20:05:30 +01:00
|
|
|
@Override
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
public Teleport getTeleport()
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
return teleport;
|
2011-04-04 03:26:45 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public long getLastOnlineActivity()
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
return lastOnlineActivity;
|
2011-05-01 13:04:34 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void setLastOnlineActivity(final long timestamp)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 23:07:30 +02:00
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
lastOnlineActivity = timestamp;
|
2011-05-01 13:04:34 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-05-13 18:57:45 +02:00
|
|
|
@Override
|
|
|
|
public double getMoney()
|
|
|
|
{
|
2011-07-15 23:39:56 +02:00
|
|
|
if (ess.getPaymentMethod().hasMethod())
|
2011-05-13 18:57:45 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
final Method method = ess.getPaymentMethod().getMethod();
|
2011-07-06 00:05:44 +02:00
|
|
|
if (!method.hasAccount(this.getName()))
|
|
|
|
{
|
2011-05-13 22:41:49 +02:00
|
|
|
throw new Exception();
|
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
2011-05-13 22:41:49 +02:00
|
|
|
return account.balance();
|
2011-05-13 18:57:45 +02:00
|
|
|
}
|
|
|
|
catch (Throwable ex)
|
2011-07-06 00:05:44 +02:00
|
|
|
{
|
2011-05-13 18:57:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.getMoney();
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-05-13 18:57:45 +02:00
|
|
|
@Override
|
2011-08-27 13:59:39 +02:00
|
|
|
public void setMoney(final double value)
|
2011-05-13 18:57:45 +02:00
|
|
|
{
|
2011-07-15 23:39:56 +02:00
|
|
|
if (ess.getPaymentMethod().hasMethod())
|
2011-05-13 18:57:45 +02:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
final Method method = ess.getPaymentMethod().getMethod();
|
2011-07-06 00:05:44 +02:00
|
|
|
if (!method.hasAccount(this.getName()))
|
|
|
|
{
|
2011-05-13 22:41:49 +02:00
|
|
|
throw new Exception();
|
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
2011-05-14 04:16:47 +02:00
|
|
|
account.set(value);
|
2011-05-13 18:57:45 +02:00
|
|
|
}
|
|
|
|
catch (Throwable ex)
|
|
|
|
{
|
|
|
|
}
|
2012-03-02 20:05:30 +01:00
|
|
|
}
|
2011-05-13 18:57:45 +02:00
|
|
|
super.setMoney(value);
|
2012-02-27 16:31:43 +01:00
|
|
|
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
2011-05-13 18:57:45 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-02-23 16:17:23 +01:00
|
|
|
public void updateMoneyCache(final double value)
|
|
|
|
{
|
2012-02-23 18:25:00 +01:00
|
|
|
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
|
2012-02-26 05:15:14 +01:00
|
|
|
{
|
2012-02-23 16:17:23 +01:00
|
|
|
super.setMoney(value);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-07-06 00:05:44 +02:00
|
|
|
@Override
|
2011-08-27 13:59:39 +02:00
|
|
|
public void setAfk(final boolean set)
|
2011-07-06 00:05:44 +02:00
|
|
|
{
|
2011-07-15 20:13:52 +02:00
|
|
|
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
2011-10-21 01:23:35 +02:00
|
|
|
if (set && !isAfk())
|
|
|
|
{
|
2011-09-02 16:15:57 +02:00
|
|
|
afkPosition = getLocation();
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
else if (!set && isAfk())
|
|
|
|
{
|
|
|
|
afkPosition = null;
|
|
|
|
}
|
2011-07-06 00:05:44 +02:00
|
|
|
super.setAfk(set);
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-07-06 00:05:44 +02:00
|
|
|
@Override
|
|
|
|
public boolean toggleAfk()
|
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
final boolean now = super.toggleAfk();
|
2011-07-15 20:13:52 +02:00
|
|
|
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
2011-07-06 00:05:44 +02:00
|
|
|
return now;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-11-18 19:07:28 +01:00
|
|
|
@Override
|
2011-07-18 03:42:21 +02:00
|
|
|
public boolean isHidden()
|
|
|
|
{
|
|
|
|
return hidden;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void setHidden(final boolean hidden)
|
2011-07-18 03:42:21 +02:00
|
|
|
{
|
|
|
|
this.hidden = hidden;
|
2012-04-04 02:18:21 +02:00
|
|
|
if (hidden == true)
|
|
|
|
{
|
|
|
|
setLastLogout(getLastOnlineActivity());
|
|
|
|
}
|
2011-07-18 03:42:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-09-27 00:37:00 +02:00
|
|
|
//Returns true if status expired during this check
|
|
|
|
public boolean checkJailTimeout(final long currentTime)
|
2011-08-08 14:40:30 +02:00
|
|
|
{
|
|
|
|
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
|
|
|
{
|
|
|
|
setJailTimeout(0);
|
|
|
|
setJailed(false);
|
2011-11-21 02:55:26 +01:00
|
|
|
sendMessage(_("haveBeenReleased"));
|
2011-08-08 14:40:30 +02:00
|
|
|
setJail(null);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
getTeleport().back();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
2012-08-28 03:06:11 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
getTeleport().respawn(null, TeleportCause.PLUGIN);
|
|
|
|
}
|
|
|
|
catch (Exception ex1)
|
|
|
|
{
|
|
|
|
}
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2011-09-27 00:37:00 +02:00
|
|
|
return true;
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2011-09-27 00:37:00 +02:00
|
|
|
return false;
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-09-27 00:37:00 +02:00
|
|
|
//Returns true if status expired during this check
|
|
|
|
public boolean checkMuteTimeout(final long currentTime)
|
2011-08-08 14:40:30 +02:00
|
|
|
{
|
|
|
|
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
|
|
|
{
|
|
|
|
setMuteTimeout(0);
|
2011-11-21 02:55:26 +01:00
|
|
|
sendMessage(_("canTalkAgain"));
|
2011-08-08 14:40:30 +02:00
|
|
|
setMuted(false);
|
2011-09-27 00:37:00 +02:00
|
|
|
return true;
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2011-09-27 00:37:00 +02:00
|
|
|
return false;
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-09-27 00:37:00 +02:00
|
|
|
//Returns true if status expired during this check
|
|
|
|
public boolean checkBanTimeout(final long currentTime)
|
2011-08-08 14:40:30 +02:00
|
|
|
{
|
2011-09-07 22:34:53 +02:00
|
|
|
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
2011-08-08 14:40:30 +02:00
|
|
|
{
|
|
|
|
setBanTimeout(0);
|
2011-09-07 22:34:53 +02:00
|
|
|
setBanned(false);
|
2011-09-27 00:37:00 +02:00
|
|
|
return true;
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2011-09-27 00:37:00 +02:00
|
|
|
return false;
|
2011-08-08 14:40:30 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-09-01 15:29:45 +02:00
|
|
|
public void updateActivity(final boolean broadcast)
|
2011-08-27 13:59:39 +02:00
|
|
|
{
|
|
|
|
if (isAfk())
|
|
|
|
{
|
|
|
|
setAfk(false);
|
2011-09-02 16:15:57 +02:00
|
|
|
if (broadcast && !isHidden())
|
2011-09-01 15:29:45 +02:00
|
|
|
{
|
2012-03-22 00:54:57 +01:00
|
|
|
setDisplayNick();
|
2012-11-04 22:49:48 +01:00
|
|
|
final String msg = _("userIsNotAway", getDisplayName());
|
|
|
|
if (!msg.isEmpty())
|
|
|
|
{
|
|
|
|
ess.broadcastMessage(this, msg);
|
|
|
|
}
|
2011-09-01 15:29:45 +02:00
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
}
|
|
|
|
lastActivity = System.currentTimeMillis();
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void checkActivity()
|
|
|
|
{
|
|
|
|
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
2011-12-03 14:50:32 +01:00
|
|
|
if (autoafkkick > 0 && lastActivity > 0 && (lastActivity + (autoafkkick * 1000)) < System.currentTimeMillis()
|
2011-09-02 16:15:57 +02:00
|
|
|
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
2011-08-27 13:59:39 +02:00
|
|
|
{
|
2011-11-21 02:55:26 +01:00
|
|
|
final String kickReason = _("autoAfkKickReason", autoafkkick / 60.0);
|
2011-12-03 14:50:32 +01:00
|
|
|
lastActivity = 0;
|
2011-08-27 13:59:39 +02:00
|
|
|
kickPlayer(kickReason);
|
2012-01-16 00:50:52 +01:00
|
|
|
|
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
for (Player player : ess.getServer().getOnlinePlayers())
|
|
|
|
{
|
|
|
|
final User user = ess.getUser(player);
|
|
|
|
if (user.isAuthorized("essentials.kick.notify"))
|
|
|
|
{
|
2011-11-21 02:55:26 +01:00
|
|
|
player.sendMessage(_("playerKicked", Console.NAME, getName(), kickReason));
|
2011-08-27 13:59:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final long autoafk = ess.getSettings().getAutoAfk();
|
2012-09-09 20:09:35 +02:00
|
|
|
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk.auto"))
|
2011-08-27 13:59:39 +02:00
|
|
|
{
|
|
|
|
setAfk(true);
|
2011-10-21 01:23:35 +02:00
|
|
|
if (!isHidden())
|
|
|
|
{
|
2012-03-22 00:54:57 +01:00
|
|
|
setDisplayNick();
|
2012-11-04 22:49:48 +01:00
|
|
|
final String msg = _("userIsAway", getDisplayName());
|
|
|
|
if (!msg.isEmpty())
|
|
|
|
{
|
|
|
|
ess.broadcastMessage(this, msg);
|
|
|
|
}
|
2011-09-02 16:15:57 +02:00
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
}
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-09-02 16:15:57 +02:00
|
|
|
public Location getAfkPosition()
|
|
|
|
{
|
|
|
|
return afkPosition;
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-09-30 00:09:48 +02:00
|
|
|
@Override
|
|
|
|
public boolean isGodModeEnabled()
|
|
|
|
{
|
2011-11-25 07:12:21 +01:00
|
|
|
return (super.isGodModeEnabled() && !ess.getSettings().getNoGodWorlds().contains(getLocation().getWorld().getName()))
|
|
|
|
|| (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
2011-09-30 00:09:48 +02:00
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-11-25 07:12:21 +01:00
|
|
|
public boolean isGodModeEnabledRaw()
|
|
|
|
{
|
|
|
|
return super.isGodModeEnabled();
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2012-04-24 12:30:31 +02:00
|
|
|
@Override
|
2011-11-22 03:02:08 +01:00
|
|
|
public String getGroup()
|
|
|
|
{
|
|
|
|
return ess.getPermissionsHandler().getGroup(base);
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-11-22 03:02:08 +01:00
|
|
|
public boolean inGroup(final String group)
|
|
|
|
{
|
|
|
|
return ess.getPermissionsHandler().inGroup(base, group);
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-11-22 03:02:08 +01:00
|
|
|
public boolean canBuild()
|
|
|
|
{
|
2012-02-02 11:43:17 +01:00
|
|
|
if (isOp())
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
2011-11-22 03:02:08 +01:00
|
|
|
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
|
|
|
}
|
2012-01-16 00:50:52 +01:00
|
|
|
|
2011-12-09 00:43:09 +01:00
|
|
|
public long getTeleportRequestTime()
|
|
|
|
{
|
|
|
|
return teleportRequestTime;
|
2012-01-16 00:50:52 +01:00
|
|
|
}
|
2012-03-25 11:44:33 +02:00
|
|
|
|
|
|
|
public boolean isInvSee()
|
|
|
|
{
|
|
|
|
return invSee;
|
|
|
|
}
|
|
|
|
|
2012-03-27 21:14:38 +02:00
|
|
|
public void setInvSee(final boolean set)
|
2012-03-25 11:44:33 +02:00
|
|
|
{
|
|
|
|
invSee = set;
|
|
|
|
}
|
2012-08-28 03:06:11 +02:00
|
|
|
|
2012-08-21 21:02:20 +02:00
|
|
|
public boolean isEnderSee()
|
|
|
|
{
|
|
|
|
return enderSee;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setEnderSee(final boolean set)
|
|
|
|
{
|
|
|
|
enderSee = set;
|
|
|
|
}
|
2012-03-27 21:14:38 +02:00
|
|
|
private transient long teleportInvulnerabilityTimestamp = 0;
|
|
|
|
|
|
|
|
public void enableInvulnerabilityAfterTeleport()
|
|
|
|
{
|
|
|
|
final long time = ess.getSettings().getTeleportInvulnerability();
|
|
|
|
if (time > 0)
|
|
|
|
{
|
|
|
|
teleportInvulnerabilityTimestamp = System.currentTimeMillis() + time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void resetInvulnerabilityAfterTeleport()
|
|
|
|
{
|
|
|
|
if (teleportInvulnerabilityTimestamp != 0
|
|
|
|
&& teleportInvulnerabilityTimestamp < System.currentTimeMillis())
|
|
|
|
{
|
|
|
|
teleportInvulnerabilityTimestamp = 0;
|
|
|
|
}
|
|
|
|
}
|
2012-03-30 22:44:14 +02:00
|
|
|
|
2012-03-27 21:14:38 +02:00
|
|
|
public boolean hasInvulnerabilityAfterTeleport()
|
|
|
|
{
|
|
|
|
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
|
|
|
}
|
2012-05-17 12:25:02 +02:00
|
|
|
|
|
|
|
public boolean isVanished()
|
|
|
|
{
|
|
|
|
return vanished;
|
|
|
|
}
|
2012-08-03 22:57:29 +02:00
|
|
|
|
2012-06-16 14:53:46 +02:00
|
|
|
public void setVanished(final boolean set)
|
2012-05-17 12:25:02 +02:00
|
|
|
{
|
2012-06-16 14:53:46 +02:00
|
|
|
vanished = set;
|
|
|
|
if (set)
|
2012-05-21 07:13:01 +02:00
|
|
|
{
|
2012-06-11 01:17:19 +02:00
|
|
|
for (Player p : ess.getServer().getOnlinePlayers())
|
|
|
|
{
|
|
|
|
if (!ess.getUser(p).isAuthorized("essentials.vanish.see"))
|
|
|
|
{
|
|
|
|
p.hidePlayer(getBase());
|
|
|
|
}
|
|
|
|
}
|
2012-06-11 00:36:10 +02:00
|
|
|
setHidden(true);
|
2012-05-21 07:13:01 +02:00
|
|
|
ess.getVanishedPlayers().add(getName());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-06-11 01:17:19 +02:00
|
|
|
for (Player p : ess.getServer().getOnlinePlayers())
|
|
|
|
{
|
|
|
|
p.showPlayer(getBase());
|
|
|
|
}
|
2012-06-11 00:36:10 +02:00
|
|
|
setHidden(false);
|
2012-05-21 07:13:01 +02:00
|
|
|
ess.getVanishedPlayers().remove(getName());
|
|
|
|
}
|
2012-05-17 12:25:02 +02:00
|
|
|
}
|
2012-06-16 14:53:46 +02:00
|
|
|
|
|
|
|
public void toggleVanished()
|
|
|
|
{
|
|
|
|
final boolean set = !vanished;
|
2012-06-21 12:17:26 +02:00
|
|
|
this.setVanished(set);
|
2012-06-16 14:53:46 +02:00
|
|
|
}
|
2012-08-03 22:57:29 +02:00
|
|
|
|
|
|
|
public boolean checkSignThrottle()
|
|
|
|
{
|
|
|
|
if (isSignThrottled())
|
|
|
|
{
|
2012-06-17 20:28:59 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
updateThrottle();
|
|
|
|
return false;
|
|
|
|
}
|
2012-08-03 22:57:29 +02:00
|
|
|
|
2012-06-17 20:28:59 +02:00
|
|
|
public boolean isSignThrottled()
|
|
|
|
{
|
|
|
|
final long minTime = lastThrottledAction + (1000 / ess.getSettings().getSignUsePerSecond());
|
|
|
|
return (System.currentTimeMillis() < minTime);
|
|
|
|
}
|
2012-08-03 22:57:29 +02:00
|
|
|
|
2012-06-17 20:28:59 +02:00
|
|
|
public void updateThrottle()
|
|
|
|
{
|
|
|
|
lastThrottledAction = System.currentTimeMillis();;
|
|
|
|
}
|
2012-08-31 01:47:53 +02:00
|
|
|
|
|
|
|
public boolean isFlyClickJump()
|
|
|
|
{
|
|
|
|
return rightClickJump;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setRightClickJump(boolean rightClickJump)
|
|
|
|
{
|
|
|
|
this.rightClickJump = rightClickJump;
|
2012-08-31 18:47:35 +02:00
|
|
|
}
|
2012-11-27 18:45:02 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean isIgnoreExempt()
|
|
|
|
{
|
|
|
|
return this.isAuthorized("essentials.chat.ignoreexempt");
|
|
|
|
}
|
2011-07-08 13:29:06 +02:00
|
|
|
}
|