mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 18:14:38 +02:00
More tab fixes
This commit is contained in:
@@ -48,41 +48,41 @@ public class SpawnMob
|
||||
return Util.joinList(availableList);
|
||||
}
|
||||
|
||||
public static List<String> mobParts(final String mobString)
|
||||
{
|
||||
String[] mobParts = comma.split(mobString);
|
||||
public static List<String> mobParts(final String mobString)
|
||||
{
|
||||
String[] mobParts = comma.split(mobString);
|
||||
|
||||
List<String> mobs = new ArrayList<String>();
|
||||
List<String> mobs = new ArrayList<String>();
|
||||
|
||||
for (String mobPart : mobParts)
|
||||
{
|
||||
String[] mobDatas = colon.split(mobPart);
|
||||
mobs.add(mobDatas[0]);
|
||||
}
|
||||
for (String mobPart : mobParts)
|
||||
{
|
||||
String[] mobDatas = colon.split(mobPart);
|
||||
mobs.add(mobDatas[0]);
|
||||
}
|
||||
|
||||
return mobs;
|
||||
}
|
||||
return mobs;
|
||||
}
|
||||
|
||||
public static List<String> mobData(final String mobString)
|
||||
{
|
||||
String[] mobParts = comma.split(mobString);
|
||||
public static List<String> mobData(final String mobString)
|
||||
{
|
||||
String[] mobParts = comma.split(mobString);
|
||||
|
||||
List<String> mobData = new ArrayList<String>();
|
||||
List<String> mobData = new ArrayList<String>();
|
||||
|
||||
for (String mobPart : mobParts)
|
||||
{
|
||||
String[] mobDatas = colon.split(mobPart);
|
||||
if(mobDatas.length == 1)
|
||||
{
|
||||
mobData.add(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
mobData.add(mobDatas[1]);
|
||||
}
|
||||
}
|
||||
return mobData;
|
||||
}
|
||||
for (String mobPart : mobParts)
|
||||
{
|
||||
String[] mobDatas = colon.split(mobPart);
|
||||
if (mobDatas.length == 1)
|
||||
{
|
||||
mobData.add(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
mobData.add(mobDatas[1]);
|
||||
}
|
||||
}
|
||||
return mobData;
|
||||
}
|
||||
|
||||
// This method spawns a mob where the user is looking, owned by user
|
||||
public static void spawnmob(final IEssentials ess, final Server server, final IUser user, final List<String> parts, final List<String> data, int mobCount) throws Exception
|
||||
@@ -112,11 +112,11 @@ public class SpawnMob
|
||||
{
|
||||
final Location sloc = LocationUtil.getSafeDestination(loc);
|
||||
|
||||
for (int i = 0; i < parts.size(); i++)
|
||||
{
|
||||
EntityType mob = LivingEntities.fromName(parts.get(i));
|
||||
checkSpawnable(ess, sender, mob);
|
||||
}
|
||||
for (int i = 0; i < parts.size(); i++)
|
||||
{
|
||||
EntityType mob = LivingEntities.fromName(parts.get(i));
|
||||
checkSpawnable(ess, sender, mob);
|
||||
}
|
||||
|
||||
ISettings settings = ess.getSettings();
|
||||
int serverLimit = settings.getData().getCommands().getSpawnmob().getLimit();
|
||||
@@ -127,7 +127,7 @@ public class SpawnMob
|
||||
sender.sendMessage(_("mobSpawnLimit"));
|
||||
}
|
||||
|
||||
EntityType mob = LivingEntities.fromName(parts.get(0));
|
||||
EntityType mob = LivingEntities.fromName(parts.get(0));
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < mobCount; i++)
|
||||
@@ -152,40 +152,40 @@ public class SpawnMob
|
||||
|
||||
private static void spawnMob(final IEssentials ess, final Server server, final CommandSender sender, final IUser target, final Location sloc, final List<String> parts, final List<String> data) throws Exception
|
||||
{
|
||||
EntityType mob;
|
||||
Entity spawnedMob = null;
|
||||
Entity spawnedMount;
|
||||
final World spawningWorld = sloc.getWorld();
|
||||
EntityType mob;
|
||||
Entity spawnedMob = null;
|
||||
Entity spawnedMount;
|
||||
final World spawningWorld = sloc.getWorld();
|
||||
|
||||
for (int i = 0; i < parts.size(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
mob = EntityType.fromName(parts.get(i));
|
||||
spawnedMob = spawningWorld.spawn(sloc, (Class<? extends LivingEntity>)mob.getEntityClass());
|
||||
for (int i = 0; i < parts.size(); i++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
mob = EntityType.fromName(parts.get(i));
|
||||
spawnedMob = spawningWorld.spawn(sloc, (Class<? extends LivingEntity>) mob.getEntityClass());
|
||||
|
||||
if (data.get(i) != null)
|
||||
{
|
||||
changeMobData(mob, spawnedMob, data.get(i), target);
|
||||
}
|
||||
}
|
||||
if (data.get(i) != null)
|
||||
{
|
||||
changeMobData(mob, spawnedMob, data.get(i), target);
|
||||
}
|
||||
}
|
||||
|
||||
int next = (i + 1);
|
||||
if (next < parts.size())
|
||||
{
|
||||
EntityType mMob = EntityType.fromName(parts.get(next));
|
||||
spawnedMount = spawningWorld.spawn(sloc, (Class<? extends LivingEntity>)mMob.getEntityClass());
|
||||
int next = (i + 1);
|
||||
if (next < parts.size())
|
||||
{
|
||||
EntityType mMob = EntityType.fromName(parts.get(next));
|
||||
spawnedMount = spawningWorld.spawn(sloc, (Class<? extends LivingEntity>) mMob.getEntityClass());
|
||||
|
||||
if(data.get(next) != null)
|
||||
{
|
||||
changeMobData(mMob, spawnedMount, data.get(next), target);
|
||||
}
|
||||
if (data.get(next) != null)
|
||||
{
|
||||
changeMobData(mMob, spawnedMount, data.get(next), target);
|
||||
}
|
||||
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
|
||||
spawnedMob = spawnedMount;
|
||||
}
|
||||
}
|
||||
spawnedMob = spawnedMount;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void checkSpawnable(IEssentials ess, CommandSender sender, EntityType mob) throws Exception
|
||||
@@ -195,7 +195,7 @@ public class SpawnMob
|
||||
throw new Exception(_("invalidMob"));
|
||||
}
|
||||
|
||||
if (!Permissions.SPAWNMOB.isAuthorized((User)sender, mob.getName()))
|
||||
if (!Permissions.SPAWNMOB.isAuthorized((User) sender, mob.getName()))
|
||||
{
|
||||
throw new Exception(_("noPermToSpawnMob"));
|
||||
}
|
||||
@@ -209,7 +209,7 @@ public class SpawnMob
|
||||
{
|
||||
try
|
||||
{
|
||||
((Slime)spawned).setSize(Integer.parseInt(data));
|
||||
((Slime) spawned).setSize(Integer.parseInt(data));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
@@ -218,7 +218,7 @@ public class SpawnMob
|
||||
}
|
||||
if (spawned instanceof Ageable && data.contains("baby"))
|
||||
{
|
||||
((Ageable)spawned).setBaby();
|
||||
((Ageable) spawned).setBaby();
|
||||
data = data.replace("baby", "");
|
||||
}
|
||||
if (spawned instanceof Colorable)
|
||||
@@ -229,11 +229,11 @@ public class SpawnMob
|
||||
if (color.equals("RANDOM"))
|
||||
{
|
||||
final Random rand = new Random();
|
||||
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
((Colorable) spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
((Colorable)spawned).setColor(DyeColor.valueOf(color));
|
||||
((Colorable) spawned).setColor(DyeColor.valueOf(color));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -243,32 +243,32 @@ public class SpawnMob
|
||||
}
|
||||
if (spawned instanceof Tameable && data.contains("tamed") && target != null)
|
||||
{
|
||||
final Tameable tameable = ((Tameable)spawned);
|
||||
final Tameable tameable = ((Tameable) spawned);
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(target.getPlayer());
|
||||
data = data.replace("tamed", "");
|
||||
data = data.replace("tamed", "");
|
||||
}
|
||||
if (type == EntityType.WOLF && data.contains("angry"))
|
||||
{
|
||||
((Wolf)spawned).setAngry(true);
|
||||
((Wolf) spawned).setAngry(true);
|
||||
}
|
||||
if (type == EntityType.CREEPER && data.contains("powered"))
|
||||
{
|
||||
((Creeper)spawned).setPowered(true);
|
||||
((Creeper) spawned).setPowered(true);
|
||||
}
|
||||
if (type == EntityType.OCELOT)
|
||||
{
|
||||
if (data.contains("siamese") || data.contains("white"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
|
||||
((Ocelot) spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
|
||||
}
|
||||
else if (data.contains("red") || data.contains("orange") || data.contains("tabby"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
|
||||
((Ocelot) spawned).setCatType(Ocelot.Type.RED_CAT);
|
||||
}
|
||||
else if (data.contains("black") || data.contains("tuxedo"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
|
||||
((Ocelot) spawned).setCatType(Ocelot.Type.BLACK_CAT);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.VILLAGER)
|
||||
@@ -277,31 +277,31 @@ public class SpawnMob
|
||||
{
|
||||
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
((Villager)spawned).setProfession(prof);
|
||||
((Villager) spawned).setProfession(prof);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (spawned instanceof Zombie)
|
||||
{
|
||||
if (data.contains("villager"))
|
||||
{
|
||||
((Zombie)spawned).setVillager(true);
|
||||
}
|
||||
if (data.contains("baby"))
|
||||
{
|
||||
((Zombie)spawned).setBaby(true);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.SKELETON)
|
||||
{
|
||||
if (data.contains("wither"))
|
||||
{
|
||||
((Skeleton)spawned).setSkeletonType(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.EXPERIENCE_ORB)
|
||||
{
|
||||
((ExperienceOrb)spawned).setExperience(Integer.parseInt(data));
|
||||
}
|
||||
if (spawned instanceof Zombie)
|
||||
{
|
||||
if (data.contains("villager"))
|
||||
{
|
||||
((Zombie) spawned).setVillager(true);
|
||||
}
|
||||
if (data.contains("baby"))
|
||||
{
|
||||
((Zombie) spawned).setBaby(true);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.SKELETON)
|
||||
{
|
||||
if (data.contains("wither"))
|
||||
{
|
||||
((Skeleton) spawned).setSkeletonType(Skeleton.SkeletonType.WITHER);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.EXPERIENCE_ORB)
|
||||
{
|
||||
((ExperienceOrb) spawned).setExperience(Integer.parseInt(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
|
||||
List<String> mobParts = SpawnMob.mobParts(args[0]);
|
||||
List<String> mobData = SpawnMob.mobData(args[0]);
|
||||
List<String> mobData = SpawnMob.mobData(args[0]);
|
||||
|
||||
int mobCount = 1;
|
||||
if (args.length >= 2)
|
||||
|
@@ -32,8 +32,8 @@ public class SignSpawnmob extends EssentialsSign
|
||||
charge.isAffordableFor(player);
|
||||
try
|
||||
{
|
||||
List<String> mobParts = SpawnMob.mobParts(sign.getLine(2));
|
||||
List<String> mobData = SpawnMob.mobData(sign.getLine(2));
|
||||
List<String> mobParts = SpawnMob.mobParts(sign.getLine(2));
|
||||
List<String> mobData = SpawnMob.mobData(sign.getLine(2));
|
||||
SpawnMob.spawnmob(ess, ess.getServer(), player, player, mobParts, mobData, Integer.parseInt(sign.getLine(1)));
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
Reference in New Issue
Block a user