CB#1501 B#1037

New spawnmob options: cow:baby sheep:baby chicken:baby pig:baby
This commit is contained in:
snowleo 2011-11-25 05:49:57 +01:00
parent 31b9e792bd
commit 613cb57fdb
7 changed files with 49 additions and 14 deletions

View File

@ -56,7 +56,7 @@ import org.bukkit.scheduler.BukkitScheduler;
public class Essentials extends JavaPlugin implements IEssentials public class Essentials extends JavaPlugin implements IEssentials
{ {
public static final int BUKKIT_VERSION = 1467; public static final int BUKKIT_VERSION = 1501;
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings; private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);

View File

@ -3,6 +3,8 @@ package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import java.util.List; import java.util.List;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Material;
import org.bukkit.entity.Animals;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason; import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
@ -49,6 +51,17 @@ public class EssentialsEntityListener extends EntityListener
} }
} }
} }
if (eDefend instanceof Animals && eAttack instanceof Player)
{
User player = ess.getUser(eAttack);
ItemStack hand = player.getItemInHand();
if (hand != null && hand.getType() == Material.MILK_BUCKET) {
((Animals)eDefend).setAge(-24000);
player.setItemInHand(new ItemStack(Material.BUCKET, hand.getAmount()));
player.updateInventory();
event.setCancelled(true);
}
}
} }
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled()) if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{ {

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import java.io.File;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import org.bukkit.*; import org.bukkit.*;
@ -514,5 +515,11 @@ public class FakeWorld implements World
public int getSeaLevel() public int getSeaLevel()
{ {
throw new UnsupportedOperationException("Not supported yet."); throw new UnsupportedOperationException("Not supported yet.");
} }
@Override
public File getWorldFolder()
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

View File

@ -20,7 +20,7 @@ public class Commandspawnmob extends EssentialsCommand
{ {
super("spawnmob"); super("spawnmob");
} }
@Override @Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{ {
@ -29,8 +29,8 @@ public class Commandspawnmob extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
//TODO: user.sendMessage("§7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf"); //TODO: user.sendMessage("§7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf");
} }
String[] mountparts = args[0].split(","); String[] mountparts = args[0].split(",");
String[] parts = mountparts[0].split(":"); String[] parts = mountparts[0].split(":");
String mobType = parts[0]; String mobType = parts[0];
@ -50,24 +50,24 @@ public class Commandspawnmob extends EssentialsCommand
mountData = parts[1]; mountData = parts[1];
} }
} }
Entity spawnedMob = null; Entity spawnedMob = null;
Mob mob = null; Mob mob = null;
Entity spawnedMount = null; Entity spawnedMount = null;
Mob mobMount = null; Mob mobMount = null;
mob = Mob.fromName(mobType); mob = Mob.fromName(mobType);
if (mob == null) if (mob == null)
{ {
throw new Exception(_("invalidMob")); throw new Exception(_("invalidMob"));
} }
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH))) if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
{ {
throw new Exception(_("unableToSpawnMob")); throw new Exception(_("unableToSpawnMob"));
} }
final Block block = Util.getTarget(user).getBlock(); final Block block = Util.getTarget(user).getBlock();
if (block == null) if (block == null)
{ {
@ -83,7 +83,7 @@ public class Commandspawnmob extends EssentialsCommand
{ {
throw new Exception(_("unableToSpawnMob")); throw new Exception(_("unableToSpawnMob"));
} }
if (mountType != null) if (mountType != null)
{ {
mobMount = Mob.fromName(mountType); mobMount = Mob.fromName(mountType);
@ -92,7 +92,7 @@ public class Commandspawnmob extends EssentialsCommand
user.sendMessage(_("invalidMob")); user.sendMessage(_("invalidMob"));
return; return;
} }
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase(Locale.ENGLISH))) if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase(Locale.ENGLISH)))
{ {
throw new Exception(_("unableToSpawnMob")); throw new Exception(_("unableToSpawnMob"));
@ -124,7 +124,7 @@ public class Commandspawnmob extends EssentialsCommand
mobCount = serverLimit; mobCount = serverLimit;
user.sendMessage(_("mobSpawnLimit")); user.sendMessage(_("mobSpawnLimit"));
} }
try try
{ {
for (int i = 1; i < mobCount; i++) for (int i = 1; i < mobCount; i++)
@ -171,7 +171,7 @@ public class Commandspawnmob extends EssentialsCommand
user.sendMessage(mob.name + " " + _("spawned")); user.sendMessage(mob.name + " " + _("spawned"));
} }
} }
private void changeMobData(String type, Entity spawned, String data, User user) throws Exception private void changeMobData(String type, Entity spawned, String data, User user) throws Exception
{ {
if ("Slime".equalsIgnoreCase(type)) if ("Slime".equalsIgnoreCase(type))
@ -185,6 +185,15 @@ public class Commandspawnmob extends EssentialsCommand
throw new Exception(_("slimeMalformedSize"), e); throw new Exception(_("slimeMalformedSize"), e);
} }
} }
if (("Sheep".equalsIgnoreCase(type)
|| "Cow".equalsIgnoreCase(type)
|| "Chicken".equalsIgnoreCase(type)
|| "Pig".equalsIgnoreCase(type))
&& data.equalsIgnoreCase("baby"))
{
((Animals)spawned).setAge(-24000);
return;
}
if ("Sheep".equalsIgnoreCase(type)) if ("Sheep".equalsIgnoreCase(type))
{ {
try try

View File

@ -586,4 +586,10 @@ public class FakeServer implements Server
{ {
return "Essentials Fake-Server"; return "Essentials Fake-Server";
} }
@Override
public File getWorldContainer()
{
throw new UnsupportedOperationException("Not supported yet.");
}
} }

Binary file not shown.

Binary file not shown.