mirror of
https://github.com/essentials/Essentials.git
synced 2025-01-18 05:48:33 +01:00
Moved all dependency on craftbukkit to one package in the main jar. The rest is now clean bukkit code. Also cleaned PlayerExtension class.
This commit is contained in:
parent
7c23f67545
commit
390ef73897
@ -66,7 +66,7 @@ endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.craftbukkit-1.0.0-SNAPSHOT.jar=..\\lib\\craftbukkit-1.0.0-SNAPSHOT.jar
|
||||
file.reference.craftbukkit-1.0.0-SNAPSHOT.jar=../lib/craftbukkit-1.0.0-SNAPSHOT.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
|
@ -1,12 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import lombok.Delegate;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.IInventory;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -17,21 +13,19 @@ import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
public class PlayerExtension implements Player
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
@Delegate(types =
|
||||
{
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
})
|
||||
protected Player base;
|
||||
|
||||
public PlayerExtension(final Player base, final IEssentials ess)
|
||||
|
||||
public PlayerExtension(final Player base)
|
||||
{
|
||||
this.base = base;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
@ -41,44 +35,4 @@ public class PlayerExtension implements Player
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
|
||||
public void showInventory(final IInventory inventory)
|
||||
{
|
||||
getHandle().a(inventory);
|
||||
}
|
||||
|
||||
public void showInventory(final CraftInventoryPlayer inventory)
|
||||
{
|
||||
showInventory((IInventory)inventory.getInventory());
|
||||
}
|
||||
|
||||
public TargetBlock getTarget()
|
||||
{
|
||||
return new TargetBlock(getBase());
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public EntityPlayer getHandle()
|
||||
{
|
||||
return getCraftPlayer().getHandle();
|
||||
}
|
||||
|
||||
public CraftPlayer getCraftPlayer()
|
||||
{
|
||||
return (CraftPlayer)base;
|
||||
}
|
||||
}
|
||||
|
@ -1,31 +1,20 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
|
||||
public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private boolean enabled = false;
|
||||
private int timer = -1;
|
||||
private final transient IEssentials ess;
|
||||
private transient boolean enabled = false;
|
||||
private transient int timer = -1;
|
||||
|
||||
public TNTExplodeListener(IEssentials ess)
|
||||
public TNTExplodeListener(final IEssentials ess)
|
||||
{
|
||||
super();
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@ -55,33 +44,7 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@ -515,4 +515,19 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
}
|
||||
|
@ -11,12 +11,14 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsConf config;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
super(base);
|
||||
this.ess = ess;
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
|
@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
@ -25,8 +27,8 @@ public class Commandspawner extends EssentialsCommand
|
||||
//TODO: user.sendMessage("§7Mobs: Zombie PigZombie Skeleton Slime Chicken Pig Monster Spider Creeper Ghast Squid Giant Cow Sheep Wolf");
|
||||
}
|
||||
|
||||
final Block target = user.getTarget().getTargetBlock();
|
||||
if (target.getType() != Material.MOB_SPAWNER)
|
||||
final Location target = Util.getTarget(user);
|
||||
if (target == null || target.getBlock().getType() != Material.MOB_SPAWNER)
|
||||
{
|
||||
throw new Exception(_("mobSpawnTarget"));
|
||||
}
|
||||
@ -42,7 +44,7 @@ public class Commandspawner extends EssentialsCommand
|
||||
user.sendMessage(_("invalidMob"));
|
||||
return;
|
||||
}
|
||||
((CreatureSpawner)target.getState()).setCreatureType(mob.getType());
|
||||
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
|
||||
user.sendMessage(_("setSpawner", mob.name));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
|
@ -0,0 +1,51 @@
|
||||
package com.earth2me.essentials.craftbukkit;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
|
||||
|
||||
public class FakeExplosion
|
||||
{
|
||||
public static void createExplosion(final EntityExplodeEvent event, final Server server, final Player[] players)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)server).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package com.earth2me.essentials.craftbukkit;
|
||||
|
||||
import com.earth2me.essentials.InventoryWorkaround;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.IInventory;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class ShowInventory
|
||||
{
|
||||
public static void showEmptyInventory(final Player player)
|
||||
{
|
||||
try
|
||||
{
|
||||
final EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
|
||||
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(((CraftPlayer)player).getHandle()));
|
||||
inv.clear();
|
||||
entityPlayer.a((IInventory)inv.getInventory());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void showFilledInventory(final Player player, final ItemStack stack)
|
||||
{
|
||||
try
|
||||
{
|
||||
final EntityPlayer entityPlayer = ((CraftPlayer)player).getHandle();
|
||||
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(((CraftPlayer)player).getHandle()));
|
||||
inv.clear();
|
||||
InventoryWorkaround.addItem(inv, true, stack);
|
||||
entityPlayer.a((IInventory)inv.getInventory());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
@ -2,8 +2,7 @@ package com.earth2me.essentials.signs;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import com.earth2me.essentials.craftbukkit.ShowInventory;
|
||||
|
||||
|
||||
public class SignDisposal extends EssentialsSign
|
||||
@ -16,9 +15,7 @@ public class SignDisposal extends EssentialsSign
|
||||
@Override
|
||||
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess)
|
||||
{
|
||||
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
|
||||
inv.clear();
|
||||
player.showInventory(inv);
|
||||
ShowInventory.showEmptyInventory(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,10 @@ package com.earth2me.essentials.signs;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.InventoryWorkaround;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import com.earth2me.essentials.craftbukkit.ShowInventory;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@ -35,10 +33,7 @@ public class SignFree extends EssentialsSign
|
||||
}
|
||||
|
||||
item.setAmount(item.getType().getMaxStackSize() * 9 * 4);
|
||||
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
|
||||
inv.clear();
|
||||
InventoryWorkaround.addItem(inv, true, item);
|
||||
player.showInventory(inv);
|
||||
ShowInventory.showFilledInventory(player, item);
|
||||
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), sign.getBlock().getLocation(), ess);
|
||||
return true;
|
||||
}
|
||||
|
@ -63,16 +63,16 @@ dist.jar=${dist.dir}/original-EssentialsProtect.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.bukkit-1.0.0-R1-SNAPSHOT.jar=../lib/bukkit-1.0.0-R1-SNAPSHOT.jar
|
||||
file.reference.c3p0-0.9.1.2.jar=..\\lib\\c3p0-0.9.1.2.jar
|
||||
file.reference.craftbukkit-1.0.0-SNAPSHOT.jar=..\\lib\\craftbukkit-1.0.0-SNAPSHOT.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${file.reference.craftbukkit-1.0.0-SNAPSHOT.jar}:\
|
||||
${file.reference.c3p0-0.9.1.2.jar}
|
||||
${file.reference.c3p0-0.9.1.2.jar}:\
|
||||
${file.reference.bukkit-1.0.0-R1-SNAPSHOT.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
@ -2,19 +2,11 @@ package com.earth2me.essentials.protect;
|
||||
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.HashSet;
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
||||
@ -204,40 +196,7 @@ public class EssentialsProtectEntityListener extends EntityListener
|
||||
|| prot.getSettingBool(ProtectConfig.prevent_creeper_blockdmg)
|
||||
|| (maxHeight >= 0 && event.getLocation().getBlockY() > maxHeight)))
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final Set<ChunkPosition> blocksUnderPlayers = new HashSet<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(
|
||||
new ChunkPosition(
|
||||
player.getLocation().getBlockX(),
|
||||
player.getLocation().getBlockY() - 1,
|
||||
player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
ChunkPosition cp;
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0D, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension,
|
||||
new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0f, set));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user