2011-03-30 06:03:21 +02:00
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
|
|
|
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;
|
|
|
|
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;
|
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
|
|
|
{
|
|
|
|
private boolean justPortaled = false;
|
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;
|
|
|
|
private transient final Teleport teleport;
|
2011-08-27 15:30:56 +02:00
|
|
|
private transient long lastOnlineActivity = System.currentTimeMillis();;
|
2011-08-27 13:59:39 +02:00
|
|
|
private transient long lastActivity;
|
2011-07-18 03:42:21 +02:00
|
|
|
private boolean hidden = false;
|
2011-08-27 13:59:39 +02:00
|
|
|
private transient boolean godStateBeforeAfk;
|
2011-08-23 04:42:32 +02: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);
|
2011-08-27 13:59:39 +02:00
|
|
|
godStateBeforeAfk = isGodModeEnabled();
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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;
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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.");
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public boolean isAuthorized(final String node)
|
2011-03-30 06:03:21 +02: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 23:07:30 +02:00
|
|
|
{
|
2011-03-30 06:03:21 +02: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 23:07:30 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-06-07 00:24:39 +02:00
|
|
|
return ess.getPermissionsHandler().hasPermission(this, node);
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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-05-10 21:02:59 +02:00
|
|
|
throw new Exception(Util.format("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
|
|
|
}
|
2011-08-23 04:42:32 +02: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);
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
{
|
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 (value == 0)
|
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);
|
2011-07-16 01:33:22 +02:00
|
|
|
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
|
2011-07-08 13:29:06 +02:00
|
|
|
if (initiator != null)
|
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
2011-07-08 13:29:06 +02:00
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
{
|
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 (value == 0)
|
|
|
|
{
|
|
|
|
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);
|
2011-07-16 01:33:22 +02:00
|
|
|
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
|
|
|
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
throw new Exception(Util.i18n("notEnoughMoney"));
|
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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);
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
{
|
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 (value == 0)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
setMoney(getMoney() - value);
|
2011-07-16 01:33:22 +02:00
|
|
|
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
|
2011-07-08 13:29:06 +02:00
|
|
|
if (initiator != null)
|
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
2011-07-08 13:29:06 +02:00
|
|
|
}
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public boolean canAfford(final double cost)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
final double mon = getMoney();
|
2011-06-01 12:40:12 +02:00
|
|
|
return mon >= cost || isAuthorized("essentials.eco.loan");
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-03-30 06:03:21 +02:00
|
|
|
public boolean getJustPortaled()
|
|
|
|
{
|
|
|
|
return justPortaled;
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void setJustPortaled(final boolean value)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
|
|
|
justPortaled = value;
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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;
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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;
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
@Override
|
|
|
|
public int compareTo(final User other)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-08-27 13:59:39 +02:00
|
|
|
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(other.getDisplayName()));
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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-08-27 13:59:39 +02:00
|
|
|
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName()));
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-06-01 12:40:12 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-06-01 12:40:12 +02:00
|
|
|
@Override
|
|
|
|
public int hashCode()
|
|
|
|
{
|
|
|
|
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02: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));
|
|
|
|
}
|
|
|
|
|
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 setHome()
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-08-23 04:42:32 +02:00
|
|
|
setHome("home", getLocation());
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-27 13:59:39 +02:00
|
|
|
public void setHome(final String name)
|
2011-03-30 06:03:21 +02:00
|
|
|
{
|
2011-08-23 04:42:32 +02:00
|
|
|
setHome(name, getLocation());
|
2011-03-30 06:03:21 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
{
|
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
|
|
|
}
|
2011-08-23 04:42:32 +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
|
|
|
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
|
|
|
}
|
2011-08-23 04:42:32 +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
|
|
|
public boolean isTeleportRequestHere()
|
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
|
|
|
}
|
2011-08-23 04:42:32 +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
|
|
|
public String getNick()
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2011-07-15 20:35:09 +02: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 11:36:25 +02:00
|
|
|
{
|
2011-07-15 20:35:09 +02:00
|
|
|
nickname.append(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
|
|
|
{
|
2011-07-15 20:35:09 +02:00
|
|
|
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
2011-04-03 22:39:39 +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
|
|
|
if (isOp())
|
2011-04-14 11:36:25 +02:00
|
|
|
{
|
2011-05-10 22:40:32 +02:00
|
|
|
try
|
|
|
|
{
|
2011-07-15 20:35:09 +02:00
|
|
|
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
|
|
|
nickname.append("§f");
|
2011-05-10 22:40:32 +02:00
|
|
|
}
|
2011-07-06 00:05:44 +02:00
|
|
|
catch (Exception e)
|
2011-05-10 22:40:32 +02:00
|
|
|
{
|
|
|
|
}
|
2011-04-03 22:21:20 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-07-23 01:43:02 +02:00
|
|
|
if (ess.getSettings().addPrefixSuffix())
|
2011-07-20 18:36:29 +02:00
|
|
|
{
|
2011-07-23 01:43:02 +02:00
|
|
|
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
|
|
|
final String suffix = ess.getPermissionsHandler().getSuffix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-07-23 01:43:02 +02: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 18:36:29 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-07-15 20:35:09 +02:00
|
|
|
return nickname.toString();
|
2011-04-03 22:21:20 +02:00
|
|
|
}
|
2011-08-23 04:42:32 +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
|
|
|
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
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02: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
|
|
|
}
|
2011-08-23 04:42:32 +02: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();
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
super.setMoney(value);
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
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-08-27 13:59:39 +02:00
|
|
|
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
|
|
|
godStateBeforeAfk = isGodModeEnabled();
|
|
|
|
setGodModeEnabled(true);
|
|
|
|
}
|
|
|
|
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers()) {
|
|
|
|
setGodModeEnabled(godStateBeforeAfk);
|
|
|
|
}
|
2011-07-06 00:05:44 +02:00
|
|
|
super.setAfk(set);
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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;
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-07-18 03:42:21 +02:00
|
|
|
public boolean isHidden()
|
|
|
|
{
|
|
|
|
return hidden;
|
|
|
|
}
|
2011-08-23 04:42:32 +02: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;
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-08 14:40:30 +02:00
|
|
|
public void checkJailTimeout(final long currentTime)
|
|
|
|
{
|
|
|
|
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
|
|
|
{
|
|
|
|
setJailTimeout(0);
|
|
|
|
setJailed(false);
|
|
|
|
sendMessage(Util.i18n("haveBeenReleased"));
|
|
|
|
setJail(null);
|
|
|
|
try
|
|
|
|
{
|
|
|
|
getTeleport().back();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-08 14:40:30 +02:00
|
|
|
public void checkMuteTimeout(final long currentTime)
|
|
|
|
{
|
|
|
|
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
|
|
|
{
|
|
|
|
setMuteTimeout(0);
|
|
|
|
sendMessage(Util.i18n("canTalkAgain"));
|
|
|
|
setMuted(false);
|
|
|
|
}
|
|
|
|
}
|
2011-08-23 04:42:32 +02:00
|
|
|
|
2011-08-08 14:40:30 +02:00
|
|
|
public void checkBanTimeout(final long currentTime)
|
|
|
|
{
|
|
|
|
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && ess.getBans().isNameBanned(getName()))
|
|
|
|
{
|
|
|
|
setBanTimeout(0);
|
|
|
|
ess.getBans().unbanByName(getName());
|
|
|
|
}
|
|
|
|
}
|
2011-08-27 13:59:39 +02:00
|
|
|
|
|
|
|
public void updateActivity()
|
|
|
|
{
|
|
|
|
if (isAfk())
|
|
|
|
{
|
|
|
|
setAfk(false);
|
|
|
|
ess.broadcastMessage(getName(), Util.format("userIsNotAway", getDisplayName()));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
lastActivity = System.currentTimeMillis();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void checkActivity()
|
|
|
|
{
|
|
|
|
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
|
|
|
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
|
|
|
|
&& !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
|
|
|
{
|
2011-08-27 16:56:45 +02:00
|
|
|
final String kickReason = Util.format("autoAfkKickReason", autoafkkick/60.0);
|
2011-08-27 13:59:39 +02: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-08-27 15:30:56 +02:00
|
|
|
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
2011-08-27 13:59:39 +02:00
|
|
|
{
|
|
|
|
setAfk(true);
|
|
|
|
ess.broadcastMessage(getName(), Util.format("userIsAway", getDisplayName()));
|
|
|
|
}
|
|
|
|
}
|
2011-07-08 13:29:06 +02:00
|
|
|
}
|