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
|
|
|
package com.earth2me.essentials;
|
|
|
|
|
2013-07-13 15:14:39 +00:00
|
|
|
import net.ess3.api.IEssentials;
|
|
|
|
import net.ess3.api.IUser;
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.DateUtil;
|
|
|
|
import com.earth2me.essentials.utils.LocationUtil;
|
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.Location;
|
2011-12-06 12:41:29 +00:00
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
2011-12-07 01:12:36 +00:00
|
|
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
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
|
|
|
|
|
|
|
|
2013-07-13 16:52:08 +00:00
|
|
|
public class Teleport implements net.ess3.api.ITeleport
|
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
private final IUser teleportOwner;
|
2011-06-01 10:40:12 +00:00
|
|
|
private final IEssentials ess;
|
2013-06-08 18:34:14 +00:00
|
|
|
private TimedTeleport timedTeleport;
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2011-06-01 10:40:12 +00:00
|
|
|
public Teleport(IUser user, IEssentials ess)
|
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
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
this.teleportOwner = user;
|
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
|
|
|
this.ess = ess;
|
|
|
|
}
|
2013-04-21 23:11:13 +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 void cooldown(boolean check) throws Exception
|
|
|
|
{
|
2012-06-10 20:55:48 +00:00
|
|
|
final Calendar time = new GregorianCalendar();
|
2013-06-08 18:34:14 +00:00
|
|
|
if (teleportOwner.getLastTeleportTimestamp() > 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
|
|
|
{
|
2012-06-10 20:55:48 +00:00
|
|
|
// Take the current time, and remove the delay from it.
|
|
|
|
final double cooldown = ess.getSettings().getTeleportCooldown();
|
|
|
|
final Calendar earliestTime = new GregorianCalendar();
|
|
|
|
earliestTime.add(Calendar.SECOND, -(int)cooldown);
|
|
|
|
earliestTime.add(Calendar.MILLISECOND, -(int)((cooldown * 1000.0) % 1000.0));
|
2013-06-08 18:34:14 +00:00
|
|
|
// This value contains the most recent time a teleportPlayer could have been used that would allow another use.
|
2012-06-10 20:55:48 +00:00
|
|
|
final long earliestLong = earliestTime.getTimeInMillis();
|
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
// When was the last teleportPlayer used?
|
|
|
|
final Long lastTime = teleportOwner.getLastTeleportTimestamp();
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2012-06-10 20:55:48 +00:00
|
|
|
if (lastTime > time.getTimeInMillis())
|
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
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
// This is to make sure time didn't get messed up on last teleportPlayer use.
|
2012-06-10 20:55:48 +00:00
|
|
|
// If this happens, let's give the user the benifit of the doubt.
|
2013-06-08 18:34:14 +00:00
|
|
|
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
2012-06-10 20:55:48 +00:00
|
|
|
return;
|
|
|
|
}
|
2013-06-08 18:34:14 +00:00
|
|
|
else if (lastTime > earliestLong && !teleportOwner.isAuthorized("essentials.teleport.cooldown.bypass"))
|
2012-06-10 20:55:48 +00:00
|
|
|
{
|
|
|
|
time.setTimeInMillis(lastTime);
|
2012-06-16 15:46:40 +00:00
|
|
|
time.add(Calendar.SECOND, (int)cooldown);
|
|
|
|
time.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
2013-06-08 21:31:19 +00:00
|
|
|
throw new Exception(_("timeBeforeTeleport", DateUtil.formatDateDiff(time.getTimeInMillis())));
|
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 justCheck is set, don't update lastTeleport; we're just checking
|
|
|
|
if (!check)
|
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
teleportOwner.setLastTeleportTimestamp(time.getTimeInMillis());
|
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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
private void warnUser(final IUser user, final double delay)
|
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
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
Calendar c = new GregorianCalendar();
|
|
|
|
c.add(Calendar.SECOND, (int)delay);
|
|
|
|
c.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
2013-06-08 21:31:19 +00:00
|
|
|
user.sendMessage(_("dontMoveMessage", DateUtil.formatDateDiff(c.getTimeInMillis())));
|
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
|
|
|
}
|
2012-09-29 22:48:59 +00:00
|
|
|
|
2012-09-29 22:41:12 +00:00
|
|
|
//The now function is used when you want to skip tp delay when teleporting someone to a location or player.
|
2013-04-30 16:25:25 +00:00
|
|
|
@Override
|
2012-09-29 22:41:12 +00:00
|
|
|
public void now(Location loc, boolean cooldown, TeleportCause cause) throws Exception
|
|
|
|
{
|
|
|
|
if (cooldown)
|
|
|
|
{
|
|
|
|
cooldown(false);
|
|
|
|
}
|
2013-06-08 20:40:02 +00:00
|
|
|
now(teleportOwner, new LocationTarget(loc), cause);
|
2012-09-29 22:41:12 +00:00
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
@Override
|
2012-09-29 22:41:12 +00:00
|
|
|
public void now(Player entity, boolean cooldown, TeleportCause cause) throws Exception
|
|
|
|
{
|
|
|
|
if (cooldown)
|
|
|
|
{
|
|
|
|
cooldown(false);
|
|
|
|
}
|
2013-06-08 20:40:02 +00:00
|
|
|
now(teleportOwner, new PlayerTarget(entity), cause);
|
2012-09-29 22:41:12 +00:00
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 20:40:02 +00:00
|
|
|
protected void now(IUser teleportee, ITarget target, TeleportCause cause) throws Exception
|
2012-09-29 22:41:12 +00:00
|
|
|
{
|
|
|
|
cancel(false);
|
2013-06-08 18:34:14 +00:00
|
|
|
teleportee.setLastLocation();
|
2013-08-11 15:37:21 +00:00
|
|
|
teleportee.requestTeleport(null, false);
|
2013-08-11 21:42:29 +00:00
|
|
|
teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, target.getLocation()), cause);
|
2012-09-29 22:41:12 +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
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
//The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player.
|
2012-09-30 17:12:36 +00:00
|
|
|
//This method is nolonger used internally and will be removed.
|
|
|
|
@Deprecated
|
|
|
|
public void teleport(Location loc, Trade chargeFor) throws Exception
|
|
|
|
{
|
|
|
|
teleport(loc, chargeFor, TeleportCause.PLUGIN);
|
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
@Override
|
2011-12-07 01:12:36 +00:00
|
|
|
public void teleport(Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
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
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
teleport(teleportOwner, new LocationTarget(loc), chargeFor, cause);
|
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
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
@Override
|
2012-09-08 13:30:11 +00:00
|
|
|
public void teleport(Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
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
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
teleport(teleportOwner, new PlayerTarget(entity), chargeFor, cause);
|
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
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
@Override
|
|
|
|
public void teleportPlayer(IUser teleportee, Location loc, Trade chargeFor, TeleportCause cause) throws Exception
|
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
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
2013-06-08 18:34:14 +00:00
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
@Override
|
|
|
|
public void teleportPlayer(IUser teleportee, Player entity, Trade chargeFor, TeleportCause cause) throws Exception
|
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
teleport(teleportee, new PlayerTarget(entity), chargeFor, cause);
|
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
|
|
|
}
|
|
|
|
|
2013-06-08 20:40:02 +00:00
|
|
|
private void teleport(IUser teleportee, ITarget target, Trade chargeFor, TeleportCause cause) throws Exception
|
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
|
|
|
{
|
2012-09-29 22:34:46 +00:00
|
|
|
double delay = ess.getSettings().getTeleportDelay();
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2012-09-29 22:34:46 +00:00
|
|
|
if (chargeFor != null)
|
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
chargeFor.isAffordableFor(teleportOwner);
|
2012-09-29 22:34:46 +00:00
|
|
|
}
|
|
|
|
cooldown(true);
|
2013-06-08 18:34:14 +00:00
|
|
|
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass")
|
|
|
|
|| teleportee.isAuthorized("essentials.teleport.timer.bypass"))
|
2011-07-02 11:12:10 +00:00
|
|
|
{
|
|
|
|
cooldown(false);
|
2013-06-08 18:34:14 +00:00
|
|
|
now(teleportee, target, cause);
|
2012-09-29 22:34:46 +00:00
|
|
|
if (chargeFor != null)
|
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
chargeFor.charge(teleportOwner);
|
2012-09-29 22:34:46 +00:00
|
|
|
}
|
|
|
|
return;
|
2011-07-02 11:12:10 +00:00
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2012-09-29 22:34:46 +00:00
|
|
|
cancel(false);
|
2013-06-08 18:34:14 +00:00
|
|
|
warnUser(teleportee, delay);
|
|
|
|
initTimer((long)(delay * 1000.0), teleportee, target, chargeFor, cause, 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
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2012-09-29 22:33:32 +00:00
|
|
|
//The respawn function is a wrapper used to handle tp fallback, on /jail and /home
|
2013-06-08 18:34:14 +00:00
|
|
|
@Override
|
2012-09-29 22:33:32 +00:00
|
|
|
public void respawn(final Trade chargeFor, TeleportCause cause) throws Exception
|
2012-12-09 17:32:02 +00:00
|
|
|
{
|
|
|
|
double delay = ess.getSettings().getTeleportDelay();
|
|
|
|
if (chargeFor != null)
|
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
chargeFor.isAffordableFor(teleportOwner);
|
2012-12-09 17:32:02 +00:00
|
|
|
}
|
|
|
|
cooldown(true);
|
2013-06-08 18:34:14 +00:00
|
|
|
if (delay <= 0 || teleportOwner.isAuthorized("essentials.teleport.timer.bypass"))
|
2012-12-09 17:32:02 +00:00
|
|
|
{
|
|
|
|
cooldown(false);
|
2013-06-08 18:34:14 +00:00
|
|
|
respawnNow(teleportOwner, cause);
|
2012-12-09 17:32:02 +00:00
|
|
|
if (chargeFor != null)
|
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
chargeFor.charge(teleportOwner);
|
2012-12-09 17:32:02 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2012-12-09 17:32:02 +00:00
|
|
|
cancel(false);
|
2013-06-08 18:34:14 +00:00
|
|
|
warnUser(teleportOwner, delay);
|
|
|
|
initTimer((long)(delay * 1000.0), teleportOwner, null, chargeFor, cause, true);
|
2012-12-09 17:32:02 +00:00
|
|
|
}
|
2013-04-21 23:11:13 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
protected void respawnNow(IUser teleportee, TeleportCause cause) throws Exception
|
2012-09-29 22:33:32 +00:00
|
|
|
{
|
2013-06-08 18:34:14 +00:00
|
|
|
final Player player = teleportee.getBase();
|
2012-12-09 17:10:12 +00:00
|
|
|
Location bed = player.getBedSpawnLocation();
|
2013-02-01 02:59:40 +00:00
|
|
|
if (bed != null)
|
2012-12-09 17:10:12 +00:00
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
now(teleportee, new LocationTarget(bed), cause);
|
2012-12-09 17:10:12 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-12-29 06:43:26 +00:00
|
|
|
if (ess.getSettings().isDebug())
|
|
|
|
{
|
|
|
|
ess.getLogger().info("Could not find bed spawn, forcing respawn event.");
|
|
|
|
}
|
2012-12-09 17:10:12 +00:00
|
|
|
final PlayerRespawnEvent pre = new PlayerRespawnEvent(player, player.getWorld().getSpawnLocation(), false);
|
|
|
|
ess.getServer().getPluginManager().callEvent(pre);
|
2013-06-08 20:40:02 +00:00
|
|
|
now(teleportee, new LocationTarget(pre.getRespawnLocation()), cause);
|
2012-12-09 17:10:12 +00:00
|
|
|
}
|
2012-09-29 22:33:32 +00:00
|
|
|
}
|
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
//The warp function is a wrapper used to teleportPlayer a player to a /warp
|
|
|
|
@Override
|
|
|
|
public void warp(IUser teleportee, String warp, Trade chargeFor, TeleportCause cause) throws Exception
|
2012-09-29 22:33:32 +00:00
|
|
|
{
|
|
|
|
Location loc = ess.getWarps().getWarp(warp);
|
2013-06-08 18:34:14 +00:00
|
|
|
teleportee.sendMessage(_("warpingTo", warp));
|
2013-06-08 20:40:02 +00:00
|
|
|
teleport(teleportee, new LocationTarget(loc), chargeFor, cause);
|
2012-09-29 22:33:32 +00:00
|
|
|
}
|
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
//The back function is a wrapper used to teleportPlayer a player /back to their previous location.
|
|
|
|
@Override
|
2011-06-13 13:05:31 +00:00
|
|
|
public void back(Trade chargeFor) throws Exception
|
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
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
teleport(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), chargeFor, TeleportCause.COMMAND);
|
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
|
|
|
}
|
|
|
|
|
2012-09-29 22:33:32 +00:00
|
|
|
//This function is used to throw a user back after a jail sentence
|
2013-06-08 18:34:14 +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 back() throws Exception
|
|
|
|
{
|
2013-06-08 20:40:02 +00:00
|
|
|
now(teleportOwner, new LocationTarget(teleportOwner.getLastLocation()), TeleportCause.COMMAND);
|
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
|
|
|
}
|
2012-05-21 23:41:03 +00:00
|
|
|
|
2013-06-08 18:34:14 +00:00
|
|
|
//If we need to cancelTimer a pending teleportPlayer call this method
|
|
|
|
private void cancel(boolean notifyUser)
|
|
|
|
{
|
|
|
|
if (timedTeleport != null)
|
|
|
|
{
|
|
|
|
timedTeleport.cancelTimer(notifyUser);
|
|
|
|
timedTeleport = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-06-08 20:40:02 +00:00
|
|
|
private void initTimer(long delay, IUser teleportUser, ITarget target, Trade chargeFor, TeleportCause cause, boolean respawn)
|
2013-06-08 18:34:14 +00:00
|
|
|
{
|
|
|
|
timedTeleport = new TimedTeleport(teleportOwner, ess, this, delay, teleportUser, target, chargeFor, cause, respawn);
|
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
|
|
|
}
|
|
|
|
}
|