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 @Override
public void onDisable() public void onDisable()
{ {
Economy.setEss(null);
Trade.closeLog(); Trade.closeLog();
} }

View File

@ -28,6 +28,8 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class Util public class Util
@ -221,6 +223,7 @@ public class Util
// The player can stand inside these materials // The player can stand inside these materials
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>(); private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
static { static {
AIR_MATERIALS.add(Material.AIR.getId()); AIR_MATERIALS.add(Material.AIR.getId());
@ -256,7 +259,21 @@ public class Util
AIR_MATERIALS.add(Material.MELON_STEM.getId()); AIR_MATERIALS.add(Material.MELON_STEM.getId());
AIR_MATERIALS.add(Material.VINE.getId()); AIR_MATERIALS.add(Material.VINE.getId());
//TODO: Add 1.9 materials //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 public static Location getSafeDestination(final Location loc) throws Exception

View File

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

View File

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

View File

@ -1,13 +1,10 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import com.earth2me.essentials.TargetBlock;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.TreeType; import org.bukkit.TreeType;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util; import com.earth2me.essentials.Util;
import org.bukkit.Material;
import org.bukkit.block.Block;
public class Commandtree extends EssentialsCommand public class Commandtree extends EssentialsCommand
@ -20,7 +17,7 @@ public class Commandtree extends EssentialsCommand
@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
{ {
Object tree = new Object(); TreeType tree;
if (args.length < 1) if (args.length < 1)
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
@ -46,9 +43,9 @@ public class Commandtree extends EssentialsCommand
{ {
8, 9 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 Location safeLocation = Util.getSafeDestination(loc);
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree); final boolean success = user.getWorld().generateTree(safeLocation, tree);
if (success) if (success)
{ {
user.sendMessage(Util.i18n("treeSpawned")); 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.InventoryWorkaround;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import net.minecraft.server.InventoryPlayer; import net.minecraft.server.InventoryPlayer;
import org.bukkit.Material;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer; import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
import org.bukkit.inventory.ItemStack; 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 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); 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); item.setAmount(item.getType().getMaxStackSize()*9*4);
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle())); final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
inv.clear(); inv.clear();

View File

@ -79,7 +79,7 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo
{ {
u.setGeoLocation(sb.toString()); 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()) for (Player player : event.getPlayer().getServer().getOnlinePlayers())
{ {

View File

@ -142,11 +142,6 @@ groups:
g:bukkit_admin: g:bukkit_admin:
permissions: permissions:
- bPermissions.admin
- bPermissions.demote.admin
- bPermissions.gui
- bPermissions.iplock.lock
- bPermissions.promote.admin
- bukkit.broadcast - bukkit.broadcast
- bukkit.broadcast.admin - bukkit.broadcast.admin
- bukkit.command - 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: groups:
Default: Default:
default: true default: true

View File

@ -881,6 +881,7 @@ public class WorldDataHolder {
Map<String, Object> root = new HashMap<String, Object>(); Map<String, Object> root = new HashMap<String, Object>();
Map<String, Object> groupsMap = new HashMap<String, Object>(); Map<String, Object> groupsMap = new HashMap<String, Object>();
root.put("groups", groupsMap); root.put("groups", groupsMap);
for (String groupKey : ph.groups.keySet()) { for (String groupKey : ph.groups.keySet()) {
Group group = ph.groups.get(groupKey); Group group = ph.groups.get(groupKey);
@ -910,10 +911,24 @@ public class WorldDataHolder {
opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK); opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
final Yaml yaml = new Yaml(opt); final Yaml yaml = new Yaml(opt);
try { 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 (UnsupportedEncodingException ex) {
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
} } catch (IOException e) {
}
} }
// Update the LastModified time. // Update the LastModified time.