2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
|
|
|
import com.earth2me.essentials.commands.IEssentialsCommand;
|
2011-05-13 23:39:18 +00: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 21:07:30 +00:00
|
|
|
import java.util.Calendar;
|
|
|
|
import java.util.GregorianCalendar;
|
|
|
|
import org.bukkit.ChatColor;
|
2011-08-23 02:42:32 +00:00
|
|
|
import org.bukkit.Location;
|
2011-04-05 15:57:54 +00: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 21:07:30 +00:00
|
|
|
import org.bukkit.entity.Player;
|
2011-03-30 04:03:21 +00:00
|
|
|
|
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
private boolean justPortaled = false;
|
2011-04-05 15:57:54 +00:00
|
|
|
private CommandSender replyTo = null;
|
2011-08-27 11:59:39 +00:00
|
|
|
private transient User teleportRequester;
|
|
|
|
private transient boolean teleportRequestHere;
|
|
|
|
private transient final Teleport teleport;
|
2011-08-31 10:51:59 +00:00
|
|
|
private transient long lastOnlineActivity;
|
2011-08-27 20:29:57 +00:00
|
|
|
private transient long lastActivity = System.currentTimeMillis();
|
2011-07-18 01:42:21 +00:00
|
|
|
private boolean hidden = false;
|
2011-08-27 11:59:39 +00:00
|
|
|
private transient boolean godStateBeforeAfk;
|
2011-09-02 14:15:57 +00:00
|
|
|
private transient Location afkPosition;
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
User(final Player base, final IEssentials ess)
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
super(base, ess);
|
|
|
|
teleport = new Teleport(this, ess);
|
2011-08-27 11:59:39 +00:00
|
|
|
godStateBeforeAfk = isGodModeEnabled();
|
2011-09-02 14:15:57 +00:00
|
|
|
afkPosition = getLocation();
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
User update(final Player base)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
setBase(base);
|
|
|
|
return this;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final IEssentialsCommand cmd)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-06-26 13:47:28 +00:00
|
|
|
return isAuthorized(cmd, "essentials.");
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
2011-06-26 13:47:28 +00:00
|
|
|
{
|
|
|
|
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final String node)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-31 10:51:59 +00:00
|
|
|
if (base instanceof OfflinePlayer)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
if (isOp())
|
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 21:07:30 +00:00
|
|
|
{
|
2011-03-30 04:03:21 +00:00
|
|
|
return true;
|
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 21:07:30 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
{
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-31 10:51:59 +00:00
|
|
|
return ess.getPermissionsHandler().hasPermission(base, node);
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
public void healCooldown() throws Exception
|
|
|
|
{
|
2011-08-27 11:59:39 +00: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 21:07:30 +00:00
|
|
|
if (getLastHealTimestamp() > 0)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-27 11:59:39 +00: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 21:07:30 +00: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 09:36:25 +00:00
|
|
|
{
|
2011-05-10 19:02:59 +00:00
|
|
|
throw new Exception(Util.format("timeBeforeHeal", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
setLastHealTimestamp(now.getTimeInMillis());
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public void giveMoney(final double value)
|
2011-07-08 11:29:06 +00:00
|
|
|
{
|
|
|
|
giveMoney(value, null);
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void giveMoney(final double value, final CommandSender initiator)
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
if (value == 0)
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
return;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
setMoney(getMoney() + value);
|
2011-07-15 23:33:22 +00:00
|
|
|
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
|
2011-07-08 11:29:06 +00:00
|
|
|
if (initiator != null)
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
2011-07-08 11:29:06 +00:00
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void payUser(final User reciever, final double value) throws Exception
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
if (value == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
if (canAfford(value))
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
setMoney(getMoney() - value);
|
|
|
|
reciever.setMoney(reciever.getMoney() + value);
|
2011-07-15 23:33:22 +00:00
|
|
|
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
|
|
|
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new Exception(Util.i18n("notEnoughMoney"));
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public void takeMoney(final double value)
|
2011-07-08 11:29:06 +00:00
|
|
|
{
|
|
|
|
takeMoney(value, null);
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void takeMoney(final double value, final CommandSender initiator)
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
if (value == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
setMoney(getMoney() - value);
|
2011-07-15 23:33:22 +00:00
|
|
|
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
|
2011-07-08 11:29:06 +00:00
|
|
|
if (initiator != null)
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
2011-07-08 11:29:06 +00:00
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public boolean canAfford(final double cost)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
final double mon = getMoney();
|
2011-06-01 10:40:12 +00:00
|
|
|
return mon >= cost || isAuthorized("essentials.eco.loan");
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
public void dispose()
|
|
|
|
{
|
2011-07-15 23:33:22 +00:00
|
|
|
this.base = new OfflinePlayer(getName(), ess);
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
public boolean getJustPortaled()
|
|
|
|
{
|
|
|
|
return justPortaled;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void setJustPortaled(final boolean value)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
justPortaled = value;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public void setReplyTo(final CommandSender user)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
replyTo = user;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
2011-04-05 15:57:54 +00:00
|
|
|
public CommandSender getReplyTo()
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
return replyTo;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
@Override
|
|
|
|
public int compareTo(final User other)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(other.getDisplayName()));
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
@Override
|
2011-08-27 11:59:39 +00:00
|
|
|
public boolean equals(final Object object)
|
2011-06-01 10:40:12 +00:00
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
if (!(object instanceof User))
|
2011-06-01 10:40:12 +00:00
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName()));
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
@Override
|
|
|
|
public int hashCode()
|
|
|
|
{
|
|
|
|
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public Boolean canSpawnItem(final int itemId)
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-24 04:18:35 +00:00
|
|
|
public Location getHome() throws Exception
|
2011-08-23 02:42:32 +00:00
|
|
|
{
|
|
|
|
return getHome(getHomes().get(0));
|
|
|
|
}
|
|
|
|
|
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 21:07:30 +00:00
|
|
|
public void setHome()
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-23 02:42:32 +00:00
|
|
|
setHome("home", getLocation());
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void setHome(final String name)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-08-23 02:42:32 +00:00
|
|
|
setHome(name, getLocation());
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00: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 21:07:30 +00:00
|
|
|
public void setLastLocation()
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
setLastLocation(getLocation());
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void requestTeleport(final User player, final boolean here)
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
teleportRequester = player;
|
|
|
|
teleportRequestHere = here;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00: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 21:07:30 +00:00
|
|
|
public User getTeleportRequest()
|
2011-04-14 09:36:25 +00: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 21:07:30 +00:00
|
|
|
return teleportRequester;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00: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 21:07:30 +00:00
|
|
|
public boolean isTeleportRequestHere()
|
2011-03-30 04:03:21 +00: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 21:07:30 +00:00
|
|
|
return teleportRequestHere;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00: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 21:07:30 +00:00
|
|
|
public String getNick()
|
2011-04-14 09:36:25 +00:00
|
|
|
{
|
2011-07-15 18:35:09 +00:00
|
|
|
final StringBuilder nickname = new StringBuilder();
|
|
|
|
final String nick = getNickname();
|
|
|
|
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
2011-04-14 09:36:25 +00:00
|
|
|
{
|
2011-07-15 18:35:09 +00:00
|
|
|
nickname.append(getName());
|
2011-04-03 20:21:20 +00: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 21:07:30 +00:00
|
|
|
else
|
2011-04-14 09:36:25 +00:00
|
|
|
{
|
2011-07-15 18:35:09 +00:00
|
|
|
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
2011-04-03 20:39:39 +00: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 21:07:30 +00:00
|
|
|
if (isOp())
|
2011-04-14 09:36:25 +00:00
|
|
|
{
|
2011-05-10 20:40:32 +00:00
|
|
|
try
|
|
|
|
{
|
2011-07-15 18:35:09 +00:00
|
|
|
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
|
|
|
nickname.append("§f");
|
2011-05-10 20:40:32 +00:00
|
|
|
}
|
2011-07-05 22:05:44 +00:00
|
|
|
catch (Exception e)
|
2011-05-10 20:40:32 +00:00
|
|
|
{
|
|
|
|
}
|
2011-04-03 20:21:20 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-07-22 23:43:02 +00:00
|
|
|
if (ess.getSettings().addPrefixSuffix())
|
2011-07-20 16:36:29 +00:00
|
|
|
{
|
2011-08-31 10:51:59 +00:00
|
|
|
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
|
|
|
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-07-22 23:43:02 +00:00
|
|
|
nickname.insert(0, prefix);
|
|
|
|
nickname.append(suffix);
|
|
|
|
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
|
|
|
{
|
|
|
|
nickname.append("§f");
|
|
|
|
}
|
2011-07-20 16:36:29 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-07-15 18:35:09 +00:00
|
|
|
return nickname.toString();
|
2011-04-03 20:21:20 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00: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 21:07:30 +00:00
|
|
|
public Teleport getTeleport()
|
2011-04-14 09:36:25 +00: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 21:07:30 +00:00
|
|
|
return teleport;
|
2011-04-04 01:26:45 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public long getLastOnlineActivity()
|
2011-04-14 09:36:25 +00:00
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
return lastOnlineActivity;
|
2011-05-01 11:04:34 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00: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 21:07:30 +00:00
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
lastOnlineActivity = timestamp;
|
2011-05-01 11:04:34 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-05-13 16:57:45 +00:00
|
|
|
@Override
|
|
|
|
public double getMoney()
|
|
|
|
{
|
2011-07-15 21:39:56 +00:00
|
|
|
if (ess.getPaymentMethod().hasMethod())
|
2011-05-13 16:57:45 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
final Method method = ess.getPaymentMethod().getMethod();
|
2011-07-05 22:05:44 +00:00
|
|
|
if (!method.hasAccount(this.getName()))
|
|
|
|
{
|
2011-05-13 20:41:49 +00:00
|
|
|
throw new Exception();
|
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
2011-05-13 20:41:49 +00:00
|
|
|
return account.balance();
|
2011-05-13 16:57:45 +00:00
|
|
|
}
|
|
|
|
catch (Throwable ex)
|
2011-07-05 22:05:44 +00:00
|
|
|
{
|
2011-05-13 16:57:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.getMoney();
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-05-13 16:57:45 +00:00
|
|
|
@Override
|
2011-08-27 11:59:39 +00:00
|
|
|
public void setMoney(final double value)
|
2011-05-13 16:57:45 +00:00
|
|
|
{
|
2011-07-15 21:39:56 +00:00
|
|
|
if (ess.getPaymentMethod().hasMethod())
|
2011-05-13 16:57:45 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
final Method method = ess.getPaymentMethod().getMethod();
|
2011-07-05 22:05:44 +00:00
|
|
|
if (!method.hasAccount(this.getName()))
|
|
|
|
{
|
2011-05-13 20:41:49 +00:00
|
|
|
throw new Exception();
|
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
2011-05-14 02:16:47 +00:00
|
|
|
account.set(value);
|
2011-05-13 16:57:45 +00:00
|
|
|
}
|
|
|
|
catch (Throwable ex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.setMoney(value);
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-07-05 22:05:44 +00:00
|
|
|
@Override
|
2011-08-27 11:59:39 +00:00
|
|
|
public void setAfk(final boolean set)
|
2011-07-05 22:05:44 +00:00
|
|
|
{
|
2011-07-15 18:13:52 +00:00
|
|
|
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
2011-08-31 10:51:59 +00:00
|
|
|
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
godStateBeforeAfk = isGodModeEnabled();
|
|
|
|
setGodModeEnabled(true);
|
|
|
|
}
|
2011-08-31 10:51:59 +00:00
|
|
|
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
setGodModeEnabled(godStateBeforeAfk);
|
|
|
|
}
|
2011-09-02 14:15:57 +00:00
|
|
|
if (set && !isAfk()) {
|
|
|
|
afkPosition = getLocation();
|
|
|
|
}
|
2011-07-05 22:05:44 +00:00
|
|
|
super.setAfk(set);
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-07-05 22:05:44 +00:00
|
|
|
@Override
|
|
|
|
public boolean toggleAfk()
|
|
|
|
{
|
2011-08-27 11:59:39 +00:00
|
|
|
final boolean now = super.toggleAfk();
|
2011-07-15 18:13:52 +00:00
|
|
|
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
2011-07-05 22:05:44 +00:00
|
|
|
return now;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-07-18 01:42:21 +00:00
|
|
|
public boolean isHidden()
|
|
|
|
{
|
|
|
|
return hidden;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-08-27 11:59:39 +00:00
|
|
|
public void setHidden(final boolean hidden)
|
2011-07-18 01:42:21 +00:00
|
|
|
{
|
|
|
|
this.hidden = hidden;
|
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-09-26 22:37:00 +00:00
|
|
|
//Returns true if status expired during this check
|
|
|
|
public boolean checkJailTimeout(final long currentTime)
|
2011-08-08 12:40:30 +00:00
|
|
|
{
|
|
|
|
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
|
|
|
{
|
|
|
|
setJailTimeout(0);
|
|
|
|
setJailed(false);
|
|
|
|
sendMessage(Util.i18n("haveBeenReleased"));
|
|
|
|
setJail(null);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
getTeleport().back();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
}
|
2011-09-26 22:37:00 +00:00
|
|
|
return true;
|
2011-08-08 12:40:30 +00:00
|
|
|
}
|
2011-09-26 22:37:00 +00:00
|
|
|
return false;
|
2011-08-08 12:40:30 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-09-26 22:37:00 +00:00
|
|
|
//Returns true if status expired during this check
|
|
|
|
public boolean checkMuteTimeout(final long currentTime)
|
2011-08-08 12:40:30 +00:00
|
|
|
{
|
|
|
|
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
|
|
|
{
|
|
|
|
setMuteTimeout(0);
|
|
|
|
sendMessage(Util.i18n("canTalkAgain"));
|
|
|
|
setMuted(false);
|
2011-09-26 22:37:00 +00:00
|
|
|
return true;
|
2011-08-08 12:40:30 +00:00
|
|
|
}
|
2011-09-26 22:37:00 +00:00
|
|
|
return false;
|
2011-08-08 12:40:30 +00:00
|
|
|
}
|
2011-08-23 02:42:32 +00:00
|
|
|
|
2011-09-26 22:37:00 +00:00
|
|
|
//Returns true if status expired during this check
|
|
|
|
public boolean checkBanTimeout(final long currentTime)
|
2011-08-08 12:40:30 +00:00
|
|
|
{
|
2011-09-07 20:34:53 +00:00
|
|
|
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
2011-08-08 12:40:30 +00:00
|
|
|
{
|
|
|
|
setBanTimeout(0);
|
2011-09-07 20:34:53 +00:00
|
|
|
setBanned(false);
|
2011-09-26 22:37:00 +00:00
|
|
|
return true;
|
2011-08-08 12:40:30 +00:00
|
|
|
}
|
2011-09-26 22:37:00 +00:00
|
|
|
return false;
|
2011-08-08 12:40:30 +00:00
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
|
2011-09-01 13:29:45 +00:00
|
|
|
public void updateActivity(final boolean broadcast)
|
2011-08-27 11:59:39 +00:00
|
|
|
{
|
|
|
|
if (isAfk())
|
|
|
|
{
|
|
|
|
setAfk(false);
|
2011-09-02 14:15:57 +00:00
|
|
|
if (broadcast && !isHidden())
|
2011-09-01 13:29:45 +00:00
|
|
|
{
|
2011-09-02 14:15:57 +00:00
|
|
|
ess.broadcastMessage(this, Util.format("userIsNotAway", getDisplayName()));
|
2011-09-01 13:29:45 +00:00
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
}
|
|
|
|
lastActivity = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void checkActivity()
|
|
|
|
{
|
|
|
|
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
|
|
|
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
|
2011-09-02 14:15:57 +00:00
|
|
|
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
2011-08-27 11:59:39 +00:00
|
|
|
{
|
2011-08-31 10:51:59 +00:00
|
|
|
final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
|
2011-08-27 11:59:39 +00:00
|
|
|
kickPlayer(kickReason);
|
|
|
|
|
|
|
|
|
|
|
|
for (Player player : ess.getServer().getOnlinePlayers())
|
|
|
|
{
|
|
|
|
final User user = ess.getUser(player);
|
|
|
|
if (user.isAuthorized("essentials.kick.notify"))
|
|
|
|
{
|
|
|
|
player.sendMessage(Util.format("playerKicked", Console.NAME, getName(), kickReason));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
final long autoafk = ess.getSettings().getAutoAfk();
|
2011-09-29 21:54:48 +00:00
|
|
|
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
2011-08-27 11:59:39 +00:00
|
|
|
{
|
|
|
|
setAfk(true);
|
2011-09-02 14:15:57 +00:00
|
|
|
if (!isHidden()) {
|
|
|
|
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
|
|
|
|
}
|
2011-08-27 11:59:39 +00:00
|
|
|
}
|
|
|
|
}
|
2011-09-02 14:15:57 +00:00
|
|
|
|
|
|
|
public Location getAfkPosition()
|
|
|
|
{
|
|
|
|
return afkPosition;
|
|
|
|
}
|
2011-09-22 08:46:23 +00:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean toggleGodModeEnabled()
|
|
|
|
{
|
|
|
|
if (!isGodModeEnabled()) {
|
|
|
|
setFoodLevel(20);
|
|
|
|
}
|
|
|
|
return super.toggleGodModeEnabled();
|
|
|
|
}
|
2011-07-08 11:29:06 +00:00
|
|
|
}
|