mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-12 09:35:26 +02:00
Merge remote branch 'remotes/origin/master' into release
This commit is contained in:
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
|
||||
@@ -81,7 +82,8 @@ public class Trade
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp) {
|
||||
&& 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
|
||||
|
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
@@ -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
|
||||
@@ -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
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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.
|
||||
|
@@ -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.");
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
|
@@ -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]
|
@@ -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();
|
||||
|
@@ -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();
|
||||
|
BIN
lib/bukkit.jar
BIN
lib/bukkit.jar
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user