Merge branch 'refs/heads/master' into release

This commit is contained in:
snowleo 2011-11-15 22:52:42 +01:00
commit 16be86953f
10 changed files with 70 additions and 32 deletions

View File

@ -221,6 +221,7 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public void onDisable()
{
Economy.setEss(null);
Trade.closeLog();
}

View File

@ -28,6 +28,8 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class Util
@ -221,6 +223,7 @@ public class Util
// The player can stand inside these materials
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
static {
AIR_MATERIALS.add(Material.AIR.getId());
@ -256,7 +259,21 @@ public class Util
AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId());
//TODO: Add 1.9 materials
for (Integer integer : AIR_MATERIALS)
{
AIR_MATERIALS_TARGET.add(integer.byteValue());
}
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
}
public static Location getTarget(final LivingEntity entity) throws Exception {
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
if (block == null) {
throw new Exception("Not targeting a block");
}
return block.getLocation();
}
public static Location getSafeDestination(final Location loc) throws Exception

View File

@ -1,6 +1,5 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.Server;
import org.bukkit.TreeType;
import com.earth2me.essentials.User;
@ -31,14 +30,10 @@ public class Commandbigtree extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
final int[] ignore =
{
8, 9
};
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(Util.i18n("bigTreeSuccess"));

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import com.earth2me.essentials.Trade;
import org.bukkit.Server;
import com.earth2me.essentials.User;
@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand
}
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
User p = user.getTeleportRequest();
if (p == null)
final User target = user.getTeleportRequest();
if (target == null
|| target.getBase() instanceof OfflinePlayer
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
{
throw new Exception(Util.i18n("noPendingRequest"));
}
Trade charge = new Trade(this.getName(), ess);
final Trade charge = new Trade(this.getName(), ess);
if (user.isTeleportRequestHere())
{
charge.isAffordableFor(user);
}
else
{
charge.isAffordableFor(p);
charge.isAffordableFor(target);
}
user.sendMessage(Util.i18n("requestAccepted"));
p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
if (user.isTeleportRequestHere())
{
user.getTeleport().teleport(p, charge);
user.getTeleport().teleport(target, charge);
}
else
{
p.getTeleport().teleport(user, charge);
target.getTeleport().teleport(user, charge);
}
user.requestTeleport(null, false);
}

View File

@ -1,13 +1,10 @@
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
@ -20,7 +17,7 @@ public class Commandtree extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
Object tree = new Object();
TreeType tree;
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
@ -46,9 +43,9 @@ public class Commandtree extends EssentialsCommand
{
8, 9
};
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
final Location loc = Util.getTarget(user);
final Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success)
{
user.sendMessage(Util.i18n("treeSpawned"));

View File

@ -4,7 +4,9 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import net.minecraft.server.InventoryPlayer;
import org.bukkit.Material;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.inventory.ItemStack;
@ -27,6 +29,11 @@ public class SignFree extends EssentialsSign
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
final ItemStack item = getItemStack(sign.getLine(1), 1, ess);
if (item.getType() == Material.AIR)
{
throw new SignException(Util.format("cantSpawnItem", "Air"));
}
item.setAmount(item.getType().getMaxStackSize()*9*4);
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
inv.clear();

View File

@ -79,7 +79,7 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo
{
u.setGeoLocation(sb.toString());
}
if (config.getBoolean("show-on-login", true))
if (config.getBoolean("show-on-login", true) && !u.isHidden())
{
for (Player player : event.getPlayer().getServer().getOnlinePlayers())
{

View File

@ -142,11 +142,6 @@ groups:
g:bukkit_admin:
permissions:
- bPermissions.admin
- bPermissions.demote.admin
- bPermissions.gui
- bPermissions.iplock.lock
- bPermissions.promote.admin
- bukkit.broadcast
- bukkit.broadcast.admin
- bukkit.command

View File

@ -1,3 +1,11 @@
# Group inheritance
# any inherited groups prefixed with a g: are global groups
# These groups are defined in the globalgroups.yml
# and can be inherited in any worlds groups/users.yml.
#
# Groups without the g: prefix are groups local to this world
# and defined in the this groups.yml file.
groups:
Default:
default: true

View File

@ -881,6 +881,7 @@ public class WorldDataHolder {
Map<String, Object> root = new HashMap<String, Object>();
Map<String, Object> groupsMap = new HashMap<String, Object>();
root.put("groups", groupsMap);
for (String groupKey : ph.groups.keySet()) {
Group group = ph.groups.get(groupKey);
@ -910,10 +911,24 @@ public class WorldDataHolder {
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
final Yaml yaml = new Yaml(opt);
try {
yaml.dump(root, new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8"));
OutputStreamWriter out = new OutputStreamWriter(new FileOutputStream(groupsFile), "UTF-8");
String newLine = System.getProperty("line.separator");
out.write("# Group inheritance" + newLine);
out.write("# any inherited groups prefixed with a g: are global groups" + newLine);
out.write("# These groups are defined in the globalgroups.yml" + newLine);
out.write("# and can be inherited in any worlds groups/users.yml." + newLine);
out.write("#" + newLine);
out.write("# Groups without the g: prefix are groups local to this world" + newLine);
out.write("# and defined in the this groups.yml file." + newLine);
out.write(newLine);
yaml.dump(root, out);
} catch (UnsupportedEncodingException ex) {
} catch (FileNotFoundException ex) {
}
} catch (IOException e) {
}
}
// Update the LastModified time.