/** @unimplemented FIXME */
  public static Container callInventoryOpenEvent(EntityPlayer player, Container container) {
    // if (player.craftingInventory != player.inventory) { // fire INVENTORY_CLOSE if one already
    // open
    //    player.netServerHandler.handleContainerClose(new
    // Packet101CloseWindow(player.activeContainer.windowId));
    // }

    BukkitServer server = (BukkitServer) Bukkit.getServer();
    BukkitPlayer craftPlayer = (BukkitPlayer) getBukkitEntity(player);
    // player.craftingInventory.(container, craftPlayer);
    int i = 0;
    InventoryBasic inv = new InventoryBasic("", container.getInventory().size());
    for (Object j : container.inventoryItemStacks) {
      net.minecraft.src.ItemStack v = (net.minecraft.src.ItemStack) j;
      inv.setInventorySlotContents(i, v);
      i++;
    }
    InventoryOpenEvent event =
        new InventoryOpenEvent(
            new BukkitInventoryView(
                (HumanEntity) getBukkitEntity(player), new BukkitInventory(inv), container));
    server.getPluginManager().callEvent(event);

    if (event.isCancelled()) {
      container.setPlayerIsPresent(craftPlayer.getHandle(), false);
      return null;
    }

    return container;
  }
  public static PlayerDeathEvent callPlayerDeathEvent(
      EntityPlayer victim, List<org.bukkit.inventory.ItemStack> drops, String deathMessage) {
    BukkitPlayer entity = (BukkitPlayer) getBukkitEntity(victim);
    PlayerDeathEvent event =
        new PlayerDeathEvent(entity, drops, victim.experienceValue, 0, deathMessage);
    org.bukkit.World world = entity.getWorld();
    Bukkit.getServer().getPluginManager().callEvent(event);

    /*victim.keepLevel = event.getKeepLevel();
    victim.newLevel = event.getNewLevel();
    victim.newTotalExp = event.getNewTotalExp();
    victim.expToDrop = event.getDroppedExp();
    victim.newExp = event.getNewExp();*/

    for (org.bukkit.inventory.ItemStack stack : event.getDrops()) {
      if (stack == null || stack.getType() == Material.AIR) continue;

      if (stack instanceof BukkitItemStack) {
        // Use the internal item to preserve possible data.
        victim.dropItemWithOffset(stack.getTypeId(), stack.getAmount(), 0.0F);
      } else {
        world.dropItemNaturally(entity.getLocation(), stack);
      }
    }

    return event;
  }
Ejemplo n.º 3
0
 @Override
 public boolean isOp() {
   if (isConsole) return true;
   return realPlayer.isOp();
 }
Ejemplo n.º 4
0
 @Override
 public void recalculatePermissions() {
   if (isConsole) cons.recalculatePermissions();
   else realPlayer.recalculatePermissions();
 }
Ejemplo n.º 5
0
 @Override
 public Set<PermissionAttachmentInfo> getEffectivePermissions() {
   if (isConsole) return cons.getEffectivePermissions();
   else return realPlayer.getEffectivePermissions();
 }
Ejemplo n.º 6
0
 @Override
 public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
   return isConsole ? cons.addAttachment(plugin, ticks) : realPlayer.addAttachment(plugin, ticks);
 }
Ejemplo n.º 7
0
 @Override
 public void removeAttachment(PermissionAttachment attachment) {
   if (isConsole) cons.removeAttachment(attachment);
   else realPlayer.removeAttachment(attachment);
 }
Ejemplo n.º 8
0
 @Override
 public boolean hasPermission(Permission perm) {
   return isConsole ? cons.hasPermission(perm) : realPlayer.hasPermission(perm);
 }
Ejemplo n.º 9
0
 @Override
 public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
   return isConsole
       ? cons.addAttachment(plugin, name, value, ticks)
       : realPlayer.addAttachment(plugin, name, value, ticks);
 }
Ejemplo n.º 10
0
 @Override
 public boolean isPermissionSet(Permission perm) {
   return isConsole ? cons.isPermissionSet(perm) : realPlayer.isPermissionSet(perm);
 }
Ejemplo n.º 11
0
 @Override
 public boolean hasPermission(String name) {
   return isConsole ? cons.hasPermission(name) : realPlayer.hasPermission(name);
 }
Ejemplo n.º 12
0
 @Override
 public boolean isPermissionSet(String name) {
   return isConsole ? cons.isPermissionSet(name) : realPlayer.isPermissionSet(name);
 }
Ejemplo n.º 13
0
 @Override
 public String getName() {
   if (isConsole) return cons.getName();
   return realPlayer.getName();
 }
Ejemplo n.º 14
0
 @Override
 public Server getServer() {
   if (isConsole) return cons.getServer();
   return realPlayer.getServer();
 }
Ejemplo n.º 15
0
 @Override
 public void sendMessage(String[] messages) {
   if (isConsole) cons.sendMessage(messages);
   else realPlayer.sendMessage(messages);
 }
Ejemplo n.º 16
0
 @Override
 public void setOp(boolean value) {
   if (isConsole) throw new IllegalArgumentException("Can't change op status of console!");
   realPlayer.setOp(value);
 }