Fixing trade sign messages

Unifying tree/spawnmob code for block selection
Adding TL notes
This commit is contained in:
KHobbits 2011-08-21 17:08:32 +01:00
parent 5a1ea77019
commit 040e2bee86
8 changed files with 23 additions and 58 deletions

View file

@ -1,10 +1,13 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.Location;
import org.bukkit.Server;
import org.bukkit.TreeType;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class Commandtree extends EssentialsCommand
@ -38,32 +41,14 @@ public class Commandtree extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
double x = user.getLocation().getX();
double y = user.getLocation().getY();
double z = user.getLocation().getZ();
// offset tree in direction player is facing
int r = (int)user.getCorrectedYaw();
if (r < 68 || r > 292) // north
final int[] ignore =
{
x -= 3.0D;
}
else if (r > 112 && r < 248) // south
{
x += 3.0D;
}
if (r > 22 && r < 158) // east
{
z -= 3.0D;
}
else if (r > 202 && r < 338) // west
{
z += 3.0D;
}
Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
8, 9
};
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
if (success)
{
charge(user);