Merge remote branch 'remotes/origin/master' into release

This commit is contained in:
KHobbits 2012-02-15 19:09:02 +00:00
commit 16a0f44b4d
13 changed files with 161 additions and 94 deletions

View file

@ -17,6 +17,8 @@ import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.plugin.Plugin;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.util.Vector;
@ -857,4 +859,58 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void hidePlayer(Player player)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void showPlayer(Player player)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean canSee(Player player)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addPotionEffect(PotionEffect pe)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addPotionEffect(PotionEffect pe, boolean bln)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean addPotionEffects(Collection<PotionEffect> clctn)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean hasPotionEffect(PotionEffectType pet)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void removePotionEffect(PotionEffectType pet)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Collection<PotionEffect> getActivePotionEffects()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View file

@ -13,6 +13,7 @@ import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.inventory.ItemStack;
@ -38,7 +39,7 @@ public class Trade
{
this(null, null, items, null, ess);
}
public Trade(final int exp, final IEssentials ess)
{
this(null, null, null, exp, ess);
@ -79,9 +80,10 @@ public class Trade
{
throw new ChargeException(_("notEnoughMoney"));
}
if (exp != null && exp > 0
&& SetExpFix.getTotalExperience(user) < exp) {
if (exp != null && exp > 0
&& SetExpFix.getTotalExperience(user) < exp)
{
throw new ChargeException(_("notEnoughExperience"));
}
}
@ -103,9 +105,25 @@ public class Trade
if (dropItems)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
final Location loc = user.getLocation();
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
final int maxStackSize = itemStack.getType().getMaxStackSize();
final int stacks = itemStack.getAmount() / maxStackSize;
final int leftover = itemStack.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
{
final ItemStack stack = itemStack.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = itemStack.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}
}
}
else
@ -173,7 +191,7 @@ public class Trade
{
return itemStack;
}
public Integer getExperience()
{
return exp;

View file

@ -554,4 +554,28 @@ public class FakeWorld implements World
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getTicksPerAnimalSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTicksPerAnimalSpawns(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public long getTicksPerMonsterSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTicksPerMonsterSpawns(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View file

@ -1,17 +1,12 @@
package com.earth2me.essentials.craftbukkit;
import com.earth2me.essentials.craftbukkit.FakeInventory;
import java.util.HashMap;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.entity.Item;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
/*
* This class can be removed when
* https://github.com/Bukkit/CraftBukkit/pull/193
* is accepted to CraftBukkit
* This class can be removed when https://github.com/Bukkit/CraftBukkit/pull/193 is accepted to CraftBukkit
*/
public final class InventoryWorkaround
@ -47,7 +42,7 @@ public final class InventoryWorkaround
{
return firstPartial(cinventory, item, forceDurability, item.getType().getMaxStackSize());
}
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability, final int maxAmount)
{
if (item == null)
@ -93,10 +88,9 @@ public final class InventoryWorkaround
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
/* TODO: some optimization
* - Create a 'firstPartial' with a 'fromIndex'
* - Record the lastPartial per Material
* - Cache firstEmpty result
/*
* TODO: some optimization - Create a 'firstPartial' with a 'fromIndex' - Record the lastPartial per Material -
* Cache firstEmpty result
*/
// combine items
@ -175,7 +169,7 @@ public final class InventoryWorkaround
final int amount = item.getAmount();
final int partialAmount = partialItem.getAmount();
// Check if it fully fits
if (amount + partialAmount <= maxAmount)
{
@ -325,25 +319,4 @@ public final class InventoryWorkaround
}
return leftover.isEmpty();
}
public static Item[] dropItem(final Location loc, final ItemStack itm)
{
final int maxStackSize = itm.getType().getMaxStackSize();
final int stacks = itm.getAmount() / maxStackSize;
final int leftover = itm.getAmount() % maxStackSize;
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
for (int i = 0; i < stacks; i++)
{
final ItemStack stack = itm.clone();
stack.setAmount(maxStackSize);
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
}
if (leftover > 0)
{
final ItemStack stack = itm.clone();
stack.setAmount(leftover);
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
}
return itemStacks;
}
}

View file

@ -291,8 +291,8 @@ sethome-multiple:
# essentials.sethome.multiple.staff
staff: 10
#Set timeout in seconds for players to accept tpa before request is cancelled.
#Set to 0 for no timeout
# Set timeout in seconds for players to accept tpa before request is cancelled.
# Set to 0 for no timeout
tpa-accept-cancellation: 0
############################################################
@ -313,7 +313,7 @@ command-costs:
#example: 1000
# /kit tools costs $1500 PER USE
#kit-tools: 1500
# Set this to a currency symbol you want to use.
currency-symbol: '$'
@ -346,22 +346,22 @@ hide-permissionless-help: true
############################################################
chat:
# If EssentialsChat is installed, this will define how far a player's voice travels, in blocks. Set to 0 to make all chat global.
# Note that users with the "essentials.chat.spy" permission will hear everything, regardless of this setting.
# Users with essentials.chat.shout can override this by prefixing text with an exclamation mark (!)
# Or with essentials.chat.question can override this by prefixing text with a question mark (?)
# You can add command costs for shout/question by adding chat-shout and chat-question to the command costs section."
radius: 0
# Chat formatting can be done in two ways, you can either define a standard format for all chat
# Or you can give a group specific chat format, to give some extra variation.
# If set to the default chat format which "should" be compatible with ichat.
# For more information of chat formatting, check out the wiki: http://ess.khhq.net/wiki/Chat_Formatting
format: '<{DISPLAYNAME}> {MESSAGE}'
#format: '&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}'
group-formats:
# Default: '{WORLDNAME} {DISPLAYNAME}&7:&f {MESSAGE}'
# Admins: '{WORLDNAME} &c[{GROUP}]&f {DISPLAYNAME}&7:&c {MESSAGE}'
@ -400,13 +400,13 @@ protect:
# Which blocks should people be prevented from placing
placement: 10,11,46,327
# Which items should people be prevented from using
usage: 327
# Which blocks should people be prevented from breaking
break:
# Which blocks should not be pushed by pistons
piston:
@ -460,12 +460,12 @@ protect:
mushroom_cow: false
magma_cube: false
snowman: false
# Maximum height the creeper should explode. -1 allows them to explode everywhere.
# Set prevent.creeper-explosion to true, if you want to disable creeper explosions.
creeper:
max-height: -1
# Protect various blocks.
protect:
# Protect all signs
@ -481,7 +481,7 @@ protect:
# Prevent placing blocks above protected rails, this is to stop a potential griefing
prevent-block-on-rails: false
# Store blocks / signs in memory before writing
memstore: false
@ -510,14 +510,14 @@ protect:
# Burn, baby, burn! Should fire damage be disabled?
firedmg: false
# Should the damage after hit by a lightning be disabled?
lightning: false
# Should people with build: false in permissions be allowed to build
# Set true to disable building for those people
build: true
# Should people with build: false in permissions be allowed to use items
# Set true to disable using for those people
use: true
@ -544,7 +544,7 @@ newbies:
# If not, set to ''
#announce-format: ''
announce-format: '&dWelcome {DISPLAYNAME}&d to the server!'
# When we spawn for the first time, which spawnpoint do we use?
# Set to "none" if you want to use the spawn point of the world.
spawnpoint: newbies

View file

@ -5,7 +5,7 @@ main: com.earth2me.essentials.Essentials
version: TeamCity
website: http://tiny.cc/EssentialsCommands
description: Provides an essential, core set of commands for Bukkit.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5]
commands:
afk:
description: Marks you as away-from-keyboard.
@ -120,7 +120,7 @@ commands:
aliases: [mem,memory,egc,emem,ememory]
give:
description: Give a player an item.
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
usage: /<command> <player> <item|numeric> [amount <enchantmentname[:level]> ...]
aliases: [egive]
god:
description: Enables your godly powers.
@ -220,7 +220,7 @@ commands:
aliases: [emute]
near:
description: Lists the players near by or around a player
usage: /<command> [playername] [radius]
usage: /<command> [playername] [radius]
aliases: [nearby,enear,enearby]
nick:
description: Change your nickname or that of another player.

View file

@ -654,4 +654,16 @@ public class FakeServer implements Server
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTicksPerAnimalSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTicksPerMonsterSpawns()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View file

@ -7,8 +7,6 @@ import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;

View file

@ -5,6 +5,6 @@ main: com.earth2me.essentials.chat.EssentialsChat
version: TeamCity
website: http://tiny.cc/EssentialsCommands
description: Provides chat control features for Essentials. Requires Permissions.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, Okamosy]
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits, md_5, Okamosy]
depend: [Essentials]
#softdepend: [Factions]

View file

@ -7,16 +7,15 @@ import java.util.Map;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public class EssentialsHelp extends PlayerListener
public class EssentialsHelp implements Listener
{
private transient Player chatUser;
private final transient Server server;
@ -39,8 +38,7 @@ public class EssentialsHelp extends PlayerListener
public void registerEvents()
{
final PluginManager pluginManager = server.getPluginManager();
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Low, plugin);
pluginManager.registerEvents(this, plugin);
}
public void onCommand(final CommandSender sender)
@ -155,18 +153,17 @@ public class EssentialsHelp extends PlayerListener
ircBot = new IrcBot(player, "Ess_" + player.getName(), UsernameUtil.createUsername(player));
}
@Override
@EventHandler
public void onPlayerChat(final PlayerChatEvent event)
{
if (event.getPlayer() == chatUser)
{
final boolean success = sendChatMessage(event.getPlayer(), event.getMessage());
event.setCancelled(success);
return;
}
}
@Override
@EventHandler
public void onPlayerQuit(final PlayerQuitEvent event)
{
closeConnection();

View file

@ -7,18 +7,15 @@ import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.CustomEventListener;
import org.bukkit.event.Event;
import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
public class UpdateProcess extends PlayerListener
public class UpdateProcess implements Listener
{
private transient Player currentPlayer;
private final transient Plugin plugin;
@ -34,21 +31,7 @@ public class UpdateProcess extends PlayerListener
public void registerEvents()
{
final PluginManager pluginManager = plugin.getServer().getPluginManager();
pluginManager.registerEvent(Type.PLAYER_QUIT, this, Priority.Low, plugin);
pluginManager.registerEvent(Type.PLAYER_CHAT, this, Priority.Lowest, plugin);
pluginManager.registerEvent(Type.PLAYER_JOIN, this, Priority.Normal, plugin);
pluginManager.registerEvent(Type.CUSTOM_EVENT, new CustomEventListener()
{
@Override
public void onCustomEvent(final Event event)
{
if (event instanceof InstallationFinishedEvent)
{
UpdateProcess.this.currentPlayer = null;
}
}
}, Priority.Normal, plugin);
plugin.getServer().getPluginManager().registerEvents(this, plugin);
}
public boolean selfUpdate()
@ -110,7 +93,13 @@ public class UpdateProcess extends PlayerListener
return false;
}
@Override
@EventHandler
public void onInstallationFinished(final InstallationFinishedEvent event)
{
UpdateProcess.this.currentPlayer = null;
}
@EventHandler(priority = EventPriority.LOWEST)
public void onPlayerChat(final PlayerChatEvent event)
{
if (event.getPlayer() == currentPlayer)
@ -130,7 +119,7 @@ public class UpdateProcess extends PlayerListener
}
}
@Override
@EventHandler
public void onPlayerJoin(final PlayerJoinEvent event)
{
final Player player = event.getPlayer();

Binary file not shown.

Binary file not shown.