Permalink
Browse files

Added new behaviour for tamertool (Tameable and Ageable), as well as …

…for spawnmob,

added tame and sit spawnmob flags
  • Loading branch information...
1 parent b2eaf13 commit ba33a22ddd3a4d925524ca06ebb07c76f4ace2db @GuntherDW committed Mar 22, 2012
@@ -267,10 +267,10 @@ public boolean help(CommandSender sender, String command, String[] args)
for (Map.Entry<String, Method> entry : commh.getCommandMap().entrySet()) {
// Method commandMethod = commh.getCommandMap().get(cname);
// aCommand annotation = commandMethod.getAnnotation(aCommand.class);
- if (plugin.getCommand(entry.getKey()) == null) {
+ /* if (plugin.getCommand(entry.getKey()) == null) {
System.out.println("Nullpointer for " + entry.getKey());
continue;
- }
+ } */
if (addCommandToList(sender, entry.getValue())) {
// Fuck minecraft's font :<
@@ -997,6 +997,8 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
String victim = ap.getString("p", null);
int catType = ap.getInteger("ct", -1);
int age = ap.getInteger("a", -1);
+ boolean sitting = ap.getBoolean("sit", false);
+ boolean tame = ap.getBoolean("tame", false);
String[] args = ap.getUnusedArgs();
String mobName;
@@ -1071,12 +1073,12 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
if (health > 0)
lent.setHealth(health);
- if (lent instanceof Animals && age != -1) {
- ((Animals) lent).setAge(age);
+ if (lent instanceof Ageable && age != -1) {
+ ((Ageable) lent).setAge(age);
if(ap.isflagUsed("l"))
- ((Animals) lent).setAgeLock(true);
+ ((Ageable) lent).setAgeLock(true);
else
- ((Animals) lent).setAgeLock(agelock);
+ ((Ageable) lent).setAgeLock(agelock);
}
@@ -1087,17 +1089,34 @@ public boolean spawnMob(CommandSender sender, String command, String[] realargs)
if (lent instanceof Creeper && powered)
((Creeper) lent).setPowered(powered);
- if(lent instanceof Ocelot && catType != -1) {
- Ocelot.Type ocelotType = Ocelot.Type.getType(catType);
- if(ocelotType != null) {
- ((Ocelot) lent).setCatType(ocelotType);
- if(ocelotType != Ocelot.Type.WILD_OCELOT)
- ((Ocelot) lent).setOwner(victimplayer);
- } else {
- sender.sendMessage(ChatColor.YELLOW + "Ocelot type not valid!");
- return true;
+ if (lent instanceof Ocelot) {
+
+ if(sitting)
+ ((Ocelot) lent).setSitting(sitting);
+
+ if(catType != -1) {
+ Ocelot.Type ocelotType = Ocelot.Type.getType(catType);
+ if(ocelotType != null) {
+ ((Ocelot) lent).setCatType(ocelotType);
+ if(ocelotType != Ocelot.Type.WILD_OCELOT)
+ ((Ocelot) lent).setOwner(victimplayer);
+ } else {
+ sender.sendMessage(ChatColor.YELLOW + "Ocelot type not valid!");
+ return true;
+ }
}
+ }
+ if (lent instanceof Wolf) {
+ if(sitting)
+ ((Wolf) lent).setSitting(sitting);
+ }
+
+ if(lent instanceof Tameable) {
+ if (tame) {
+ ((Tameable) lent).setOwner(victimplayer);
+ ((Tameable) lent).setTamed(true);
+ }
}
if (lent instanceof Sheep && shoven || sheepcolor != null) {
@@ -514,7 +514,8 @@ public void onPlayerJoin(PlayerJoinEvent event) {
p.sendMessage(m);
}
- event.setJoinMessage(ChatColor.YELLOW + displayName + ChatColor.YELLOW +" joined the game.");
+ // event.setJoinMessage(ChatColor.YELLOW + displayName + ChatColor.YELLOW +" joined the game.");
+ event.setJoinMessage(ChatColor.GREEN + " + " + displayName + ChatColor.DARK_GRAY + " / joined the game.");
if (lp.isInvisible()) { // Invisible players do not send out a "joined" message
event.setJoinMessage(null);
@@ -527,10 +528,6 @@ public void onPlayerJoin(PlayerJoinEvent event) {
play.hidePlayer(p);
}
}
-
- if(plugin.getConfigHandler().enableVanish) {
- //p.hidePlayer();
- }
}
if (plugin.getConfigHandler().enableCUI) {
@@ -606,7 +603,8 @@ public void onPlayerQuit(PlayerQuitEvent event) {
// if (plugin.hasNick(name)) {
- event.setQuitMessage(ChatColor.YELLOW + player.getDisplayName() + ChatColor.YELLOW + " left the game.");
+ // event.setQuitMessage(ChatColor.YELLOW + player.getDisplayName() + ChatColor.YELLOW + " left the game.");
+ event.setQuitMessage(ChatColor.DARK_GRAY + " - " + player.getDisplayName() + ChatColor.DARK_GRAY + " / left the game.");
// }
if (lp.isInvisible()) { // Invisible players do not send out a "left" message
@@ -887,10 +885,10 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if (plugin.getConfigHandler().enabletamertool) {
if (player.getItemInHand() != null) {
- if (entity instanceof Wolf && player.getItemInHand().getTypeId() == plugin.getConfigHandler().tamertoolid) {
+ if (entity instanceof Tameable && player.getItemInHand().getTypeId() == plugin.getConfigHandler().tamertoolid) {
if (plugin.getTamerTool().getTamers().containsKey(player)) {
event.setCancelled(true);
- plugin.getTamerTool().handleEvent(player, (Wolf) entity);
+ plugin.getTamerTool().handleEvent(player, (Tameable) entity);
return;
}
} else if (entity instanceof Animals) {
@@ -964,6 +962,19 @@ public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
player.sendMessage(ChatColor.BLUE + "type : " + ChatColor.YELLOW + cname);
player.sendMessage(ChatColor.BLUE + "health : " + ChatColor.YELLOW + lent.getHealth());
}
+ } else if(entity instanceof Ageable) { // Villagers?
+ if (player.getItemInHand().getTypeId() == plugin.getConfigHandler().tamertoolid) {
+ LivingEntity lent = (LivingEntity) entity;
+ EntityType type = EntityType.fromName(lent.getClass().getCanonicalName().split("Craft")[1]);
+ Ageable a = (Ageable) lent;
+ String cname = type.getName().toLowerCase();
+
+ player.sendMessage(ChatColor.BLUE + "Creature info : ");
+ player.sendMessage(ChatColor.BLUE + "type : " + ChatColor.YELLOW + cname);
+ player.sendMessage(ChatColor.BLUE + "health : " + ChatColor.YELLOW + lent.getHealth());
+ player.sendMessage(ChatColor.BLUE + "age : " + ChatColor.YELLOW + a.getAge() + (a.getAgeLock()? ChatColor.RED+" L":""));
+
+ }
}
}
}
Oops, something went wrong.

0 comments on commit ba33a22

Please sign in to comment.