2011-03-30 04:03:21 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-06-13 13:05:11 +00:00
|
|
|
import com.earth2me.essentials.Trade;
|
2011-11-18 17:42:26 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2011-03-30 04:03:21 +00:00
|
|
|
import java.util.List;
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
|
|
|
import org.bukkit.World;
|
|
|
|
|
|
|
|
|
|
|
|
public class Commandworld extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandworld()
|
|
|
|
{
|
|
|
|
super("world");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-10-11 00:03:38 +00:00
|
|
|
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
|
|
|
World world;
|
|
|
|
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
2011-10-11 00:03:38 +00:00
|
|
|
World nether = null;
|
2011-11-21 01:55:26 +00:00
|
|
|
|
2011-10-11 00:03:38 +00:00
|
|
|
final List<World> worlds = server.getWorlds();
|
|
|
|
|
|
|
|
for (World world2 : worlds)
|
|
|
|
{
|
|
|
|
if (world2.getEnvironment() == World.Environment.NETHER)
|
2011-04-21 11:48:07 +00:00
|
|
|
{
|
2011-10-11 00:03:38 +00:00
|
|
|
nether = world2;
|
|
|
|
break;
|
2011-04-21 11:48:07 +00:00
|
|
|
}
|
|
|
|
}
|
2011-10-11 00:03:38 +00:00
|
|
|
if (nether == null)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
2011-04-21 11:48:07 +00:00
|
|
|
world = user.getWorld() == nether ? worlds.get(0) : nether;
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
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
|
|
|
world = ess.getWorld(getFinalArg(args, 0));
|
|
|
|
if (world == null)
|
2011-03-30 04:03:21 +00:00
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
user.sendMessage(_("invalidWorld"));
|
|
|
|
user.sendMessage(_("possibleWorlds", server.getWorlds().size() - 1));
|
|
|
|
user.sendMessage(_("typeWorldName"));
|
2011-08-30 07:46:31 +00:00
|
|
|
throw new NoChargeException();
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-03 17:13:42 +00:00
|
|
|
if (ess.getSettings().getIsWorldTeleportPermissions())
|
|
|
|
{
|
|
|
|
if (!user.isAuthorized("essentials.world." + world.getName()))
|
|
|
|
{
|
|
|
|
user.sendMessage(_("invalidWorld")); //TODO: Make a "world teleport denied" translation
|
|
|
|
throw new NoChargeException();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-30 04:03:21 +00:00
|
|
|
double factor;
|
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 (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
|
|
|
|
{
|
2011-10-11 00:03:38 +00:00
|
|
|
factor = 8.0;
|
2011-04-16 05:52:58 +00:00
|
|
|
}
|
2011-10-11 00:03:38 +00:00
|
|
|
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
{
|
2011-10-11 00:03:38 +00:00
|
|
|
factor = 1.0 / 8.0;
|
2011-04-16 05:52:58 +00:00
|
|
|
}
|
2011-11-21 01:55:26 +00:00
|
|
|
else
|
|
|
|
{
|
2011-04-16 05:52:58 +00:00
|
|
|
factor = 1.0;
|
|
|
|
}
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2011-10-11 00:03:38 +00:00
|
|
|
final Location loc = user.getLocation();
|
|
|
|
final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
2011-03-30 04:03:21 +00:00
|
|
|
|
2011-10-11 00:03:38 +00:00
|
|
|
final Trade charge = new Trade(this.getName(), ess);
|
2011-05-22 18:53:23 +00:00
|
|
|
charge.isAffordableFor(user);
|
2011-10-11 00:03:38 +00:00
|
|
|
user.getTeleport().teleport(target, charge);
|
2011-08-30 07:46:31 +00:00
|
|
|
throw new NoChargeException();
|
2011-03-30 04:03:21 +00:00
|
|
|
}
|
|
|
|
}
|