2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.commands;
|
|
|
|
|
|
|
|
import org.bukkit.Location;
|
|
|
|
import org.bukkit.Server;
|
|
|
|
import com.earth2me.essentials.User;
|
|
|
|
import com.earth2me.essentials.Mob;
|
|
|
|
import com.earth2me.essentials.Mob.MobException;
|
|
|
|
import com.earth2me.essentials.TargetBlock;
|
2011-05-11 22:42:48 +00:00
|
|
|
import com.earth2me.essentials.Util;
|
2011-07-28 00:15:47 +00:00
|
|
|
import java.util.Random;
|
2011-04-03 16:32:33 +00:00
|
|
|
import org.bukkit.DyeColor;
|
2011-04-04 02:58:41 +00:00
|
|
|
import org.bukkit.block.Block;
|
2011-08-27 18:39:54 +00:00
|
|
|
import org.bukkit.entity.Creeper;
|
2011-06-23 12:10:27 +00:00
|
|
|
import org.bukkit.entity.Entity;
|
2011-08-27 18:39:54 +00:00
|
|
|
import org.bukkit.entity.Sheep;
|
|
|
|
import org.bukkit.entity.Slime;
|
|
|
|
import org.bukkit.entity.Wolf;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
public class Commandspawnmob extends EssentialsCommand
|
|
|
|
{
|
|
|
|
public Commandspawnmob()
|
|
|
|
{
|
|
|
|
super("spawnmob");
|
|
|
|
}
|
|
|
|
|
|
|
|
@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 run(Server server, User user, String commandLabel, String[] args) throws Exception
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
|
|
|
if (args.length < 1)
|
|
|
|
{
|
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
|
|
|
throw new NotEnoughArgumentsException();
|
|
|
|
//TODO: user.sendMessage("§7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf");
|
2011-03-19 22:39:51 +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
|
|
|
|
2011-04-04 02:58:41 +00:00
|
|
|
String[] mountparts = args[0].split(",");
|
|
|
|
String[] parts = mountparts[0].split(":");
|
|
|
|
String mobType = parts[0];
|
2011-08-19 11:06:35 +00:00
|
|
|
mobType = mobType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mobType);
|
2011-04-04 02:58:41 +00:00
|
|
|
String mobData = null;
|
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 (parts.length == 2)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
mobData = parts[1];
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2011-04-04 02:58:41 +00:00
|
|
|
String mountType = null;
|
|
|
|
String mountData = null;
|
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 (mountparts.length > 1)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
parts = mountparts[1].split(":");
|
|
|
|
mountType = parts[0];
|
2011-08-19 11:06:35 +00:00
|
|
|
mountType = mountType.equalsIgnoreCase("PigZombie") ? "PigZombie" : Util.capitalCase(mountType);
|
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 (parts.length == 2)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
mountData = parts[1];
|
|
|
|
}
|
2011-03-19 22:39:51 +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
|
|
|
|
2011-07-07 17:22:57 +00:00
|
|
|
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|
|
|
|
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
|
|
|
|
{
|
2011-08-27 21:14:49 +00:00
|
|
|
throw new Exception(Util.i18n("unableToSpawnMob"));
|
2011-07-07 17:22:57 +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
|
|
|
|
2011-06-23 12:10:27 +00:00
|
|
|
Entity spawnedMob = null;
|
2011-04-04 02:58:41 +00:00
|
|
|
Mob mob = null;
|
2011-06-23 12:10:27 +00:00
|
|
|
Entity spawnedMount = null;
|
2011-04-04 02:58:41 +00:00
|
|
|
Mob mobMount = null;
|
|
|
|
|
|
|
|
mob = Mob.fromName(mobType);
|
2011-03-19 22:39:51 +00:00
|
|
|
if (mob == null)
|
|
|
|
{
|
2011-08-27 21:14:49 +00:00
|
|
|
throw new Exception(Util.i18n("invalidMob"));
|
2011-03-19 22:39:51 +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
|
|
|
int[] ignore =
|
|
|
|
{
|
|
|
|
8, 9
|
|
|
|
};
|
2011-08-23 18:47:50 +00:00
|
|
|
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
|
|
|
|
if(block == null) {
|
|
|
|
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Location loc = block.getLocation();
|
2011-08-21 16:08:32 +00:00
|
|
|
Location sloc = Util.getSafeDestination(loc);
|
2011-06-27 09:46:57 +00:00
|
|
|
try
|
|
|
|
{
|
2011-08-21 16:08:32 +00:00
|
|
|
spawnedMob = mob.spawn(user, server, sloc);
|
2011-06-27 09:46:57 +00:00
|
|
|
}
|
|
|
|
catch (MobException e)
|
|
|
|
{
|
|
|
|
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
|
|
|
return;
|
|
|
|
}
|
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-04-04 02:58:41 +00:00
|
|
|
if (mountType != null)
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
mobMount = Mob.fromName(mountType);
|
|
|
|
if (mobMount == null)
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-05-11 22:42:48 +00:00
|
|
|
user.sendMessage(Util.i18n("invalidMob"));
|
2011-03-19 22:39:51 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
try
|
|
|
|
{
|
2011-06-27 09:46:57 +00:00
|
|
|
spawnedMount = mobMount.spawn(user, server, loc);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
catch (MobException e)
|
|
|
|
{
|
2011-05-11 22:42:48 +00:00
|
|
|
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
2011-03-19 22:39:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-06-23 12:10:27 +00:00
|
|
|
spawnedMob.setPassenger(spawnedMount);
|
2011-04-03 16:32:33 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (mobData != null)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
changeMobData(mob.name, spawnedMob, mobData, user);
|
2011-04-03 17:10:19 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (spawnedMount != null && mountData != null)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
changeMobData(mobMount.name, spawnedMount, mountData, user);
|
2011-04-03 17:10:19 +00:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
if (args.length == 2)
|
|
|
|
{
|
|
|
|
int mobCount = Integer.parseInt(args[1]);
|
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
|
|
|
int serverLimit = ess.getSettings().getSpawnMobLimit();
|
|
|
|
if (mobCount > serverLimit)
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
|
|
|
mobCount = serverLimit;
|
2011-05-11 22:42:48 +00:00
|
|
|
user.sendMessage(Util.i18n("mobSpawnLimit"));
|
2011-03-19 22:39:51 +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
|
|
|
|
2011-03-19 22:39:51 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
for (int i = 1; i < mobCount; i++)
|
|
|
|
{
|
2011-06-27 09:46:57 +00:00
|
|
|
spawnedMob = mob.spawn(user, server, loc);
|
2011-04-04 02:58:41 +00:00
|
|
|
if (mobMount != null)
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
2011-06-27 09:46:57 +00:00
|
|
|
spawnedMount = mobMount.spawn(user, server, loc);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
catch (MobException e)
|
|
|
|
{
|
2011-05-11 22:42:48 +00:00
|
|
|
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
2011-03-19 22:39:51 +00:00
|
|
|
return;
|
|
|
|
}
|
2011-06-23 12:10:27 +00:00
|
|
|
spawnedMob.setPassenger(spawnedMount);
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if (mobData != null)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
changeMobData(mob.name, spawnedMob, mobData, 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
|
|
|
if (spawnedMount != null && mountData != null)
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
changeMobData(mobMount.name, spawnedMount, mountData, user);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
}
|
2011-07-22 23:10:22 +00:00
|
|
|
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + " " + Util.i18n("spawned"));
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
catch (MobException e1)
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
throw new Exception(Util.i18n("unableToSpawnMob"), e1);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
catch (NumberFormatException e2)
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
throw new Exception(Util.i18n("numberRequired"), e2);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
catch (NullPointerException np)
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
throw new Exception(Util.i18n("soloMob"), np);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-05-11 22:42:48 +00:00
|
|
|
user.sendMessage(mob.name + " " + Util.i18n("spawned"));
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-23 12:10:27 +00:00
|
|
|
private void changeMobData(String type, Entity spawned, String data, User user) 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
|
|
|
{
|
|
|
|
if ("Slime".equalsIgnoreCase(type))
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
try
|
|
|
|
{
|
2011-08-27 18:39:54 +00:00
|
|
|
((Slime)spawned).setSize(Integer.parseInt(data));
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
throw new Exception(Util.i18n("slimeMalformedSize"), e);
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if ("Sheep".equalsIgnoreCase(type))
|
|
|
|
{
|
2011-04-04 02:58:41 +00:00
|
|
|
try
|
|
|
|
{
|
2011-07-28 00:15:47 +00:00
|
|
|
if (data.equalsIgnoreCase("random"))
|
|
|
|
{
|
2011-08-19 11:06:35 +00:00
|
|
|
Random rand = new Random();
|
2011-08-27 18:39:54 +00:00
|
|
|
((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
2011-07-28 00:15:47 +00:00
|
|
|
}
|
2011-08-19 11:06:35 +00:00
|
|
|
else
|
|
|
|
{
|
2011-08-27 18:39:54 +00:00
|
|
|
((Sheep)spawned).setColor(DyeColor.valueOf(data.toUpperCase()));
|
2011-07-28 00:15:47 +00:00
|
|
|
}
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
2011-06-01 10:40:12 +00:00
|
|
|
throw new Exception(Util.i18n("sheepMalformedColor"), e);
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
|
|
|
|
{
|
2011-08-27 18:39:54 +00:00
|
|
|
Wolf wolf = ((Wolf)spawned);
|
2011-06-28 22:32:30 +00:00
|
|
|
wolf.setTamed(true);
|
2011-08-27 18:39:54 +00:00
|
|
|
wolf.setOwner(user);
|
2011-04-21 09:45:59 +00:00
|
|
|
wolf.setSitting(true);
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
This is a big refactoring of the user class and more.
Many commands have been cleaned.
File changes:
- all user data has been moved from users.yml to userdata folder
- all files in userdata folder are lower case
Both changes should be done automatically.
Class changes:
- Moved all user data functions to UserData class
- Moved all user teleport functions to Teleport class
- Moved the user list to Essentials class
- Less static functions for better testing
- EssentialsCommand now has ess Property (Essentials class)
- New NotEnoughArgumentsException, that will show command description and syntax
New commands:
- /seen, shows the last login or logout
- /tempban, temporarily ban someone
- /tjail and mute, temporarily option added
Other changes:
- ban reason is saved
- don't show "You have xxx mail" on login, if user doesn't have essentials.mail permission
- time will be parsed: years, months (mo), weeks, days, hours, minutes (m), seconds, these can be shortened and combined, example: 2 days 5h 30m
git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1300 e251c2fe-e539-e718-e476-b85c1f46cddb
2011-05-01 21:07:30 +00:00
|
|
|
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("angry"))
|
|
|
|
{
|
2011-08-27 18:39:54 +00:00
|
|
|
((Wolf)spawned).setAngry(true);
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
2011-07-07 17:22:57 +00:00
|
|
|
if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered"))
|
|
|
|
{
|
2011-08-27 18:39:54 +00:00
|
|
|
((Creeper)spawned).setPowered(true);
|
2011-04-21 17:03:44 +00:00
|
|
|
}
|
2011-04-04 02:58:41 +00:00
|
|
|
}
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|