2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-03-19 22:39:51 +00:00
|
|
|
import com.earth2me.essentials.Mob;
|
2012-11-11 18:55:02 +00:00
|
|
|
import com.earth2me.essentials.SpawnMob;
|
2011-11-18 17:42:26 +00:00
|
|
|
import com.earth2me.essentials.User;
|
2013-06-08 21:31:19 +00:00
|
|
|
import com.earth2me.essentials.utils.StringUtil;
|
2013-03-22 21:24:11 +00:00
|
|
|
import java.util.List;
|
2011-11-18 17:42:26 +00:00
|
|
|
import org.bukkit.Server;
|
2012-11-11 18:55:02 +00:00
|
|
|
import org.bukkit.command.CommandSender;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
public class Commandspawnmob extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandspawnmob()
|
|
|
|
{
|
|
|
|
super("spawnmob");
|
|
|
|
}
|
2013-04-30 00:37:39 +00:00
|
|
|
|
2011-03-19 22:39:51 +00:00
|
|
|
@Override
|
2011-12-01 13:42:39 +00:00
|
|
|
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
2012-11-11 18:55:02 +00:00
|
|
|
final String mobList = SpawnMob.mobList(user);
|
|
|
|
throw new NotEnoughArgumentsException(_("mobsAvailable", mobList));
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2013-03-22 21:24:11 +00:00
|
|
|
|
|
|
|
List<String> mobParts = SpawnMob.mobParts(args[0]);
|
|
|
|
List<String> mobData = SpawnMob.mobData(args[0]);
|
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
int mobCount = 1;
|
|
|
|
if (args.length >= 2)
|
2011-11-27 18:59:06 +00:00
|
|
|
{
|
2012-11-11 18:55:02 +00:00
|
|
|
mobCount = Integer.parseInt(args[1]);
|
2011-11-27 18:59:06 +00:00
|
|
|
}
|
2013-04-30 00:37:39 +00:00
|
|
|
|
|
|
|
if (mobParts.size() > 1 && !user.isAuthorized("essentials.spawnmob.stack"))
|
|
|
|
{
|
|
|
|
throw new Exception(_("cannotStackMob"));
|
|
|
|
}
|
|
|
|
|
2011-12-07 01:10:24 +00:00
|
|
|
if (args.length >= 3)
|
|
|
|
{
|
2013-03-20 01:04:35 +00:00
|
|
|
final User target = getPlayer(ess.getServer(), user, args, 2);
|
2013-07-07 12:02:40 +00:00
|
|
|
SpawnMob.spawnmob(ess, server, user.getBase(), target, mobParts, mobData, mobCount);
|
2012-11-11 18:55:02 +00:00
|
|
|
return;
|
2011-04-03 17:10:19 +00:00
|
|
|
}
|
2013-04-30 00:37:39 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
SpawnMob.spawnmob(ess, server, user, mobParts, mobData, mobCount);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2013-04-30 00:37:39 +00:00
|
|
|
|
2012-11-11 18:55:02 +00:00
|
|
|
@Override
|
|
|
|
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) 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-11-11 18:55:02 +00:00
|
|
|
if (args.length < 3)
|
2011-07-07 17:22:57 +00:00
|
|
|
{
|
2013-06-08 21:31:19 +00:00
|
|
|
final String mobList = StringUtil.joinList(Mob.getMobList());
|
2012-11-11 18:55:02 +00:00
|
|
|
throw new NotEnoughArgumentsException(_("mobsAvailable", mobList));
|
2012-03-22 18:00:13 +00:00
|
|
|
}
|
2013-04-30 00:37:39 +00:00
|
|
|
|
2013-03-22 21:24:11 +00:00
|
|
|
List<String> mobParts = SpawnMob.mobParts(args[0]);
|
|
|
|
List<String> mobData = SpawnMob.mobData(args[0]);
|
2012-11-11 18:55:02 +00:00
|
|
|
int mobCount = Integer.parseInt(args[1]);
|
2013-04-30 00:37:39 +00:00
|
|
|
|
2013-03-20 01:04:35 +00:00
|
|
|
final User target = getPlayer(ess.getServer(), args, 2, true, false);
|
2013-03-22 21:24:11 +00:00
|
|
|
SpawnMob.spawnmob(ess, server, sender, target, mobParts, mobData, mobCount);
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|