Search in sources :

Example 66 with ItemStack

use of org.bukkit.inventory.ItemStack in project MyMaid2 by jaoafa.

the class Event_Antijaoium method InvClick.

@EventHandler(priority = EventPriority.HIGHEST)
public void InvClick(InventoryClickEvent event) {
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    Inventory inventory = event.getInventory();
    Inventory clickedinventory = event.getClickedInventory();
    ItemStack[] is = inventory.getContents();
    /*if(Jail.isJail(player)){
			return;
		}*/
    Boolean jaoium = false;
    for (int n = 0; n != is.length; n++) {
        if (is[n] == null) {
            continue;
        }
        ItemStack hand = is[n];
        if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
            PotionMeta potion = (PotionMeta) hand.getItemMeta();
            jaoium = isjaoium(potion.getCustomEffects());
            if (jaoium) {
                inventory.clear(n);
            }
        }
    }
    if (jaoium) {
        inventory.clear();
    }
    if (clickedinventory != null) {
        is = clickedinventory.getContents();
        for (int n = 0; n != is.length; n++) {
            if (is[n] == null) {
                continue;
            }
            ItemStack hand = is[n];
            if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
                PotionMeta potion = (PotionMeta) hand.getItemMeta();
                jaoium = isjaoium(potion.getCustomEffects());
                if (jaoium) {
                    inventory.clear(n);
                }
            }
        }
        if (jaoium) {
            clickedinventory.clear();
        }
    }
    if (jaoium) {
        Bukkit.broadcastMessage("[jaoium_Checker] " + ChatColor.GREEN + "プレイヤー「" + player.getName() + "」からjaoiumと同等の性能を持つアイテムが検出されました。");
        if (!Achievementjao.getAchievement(player, new AchievementType(13))) {
            player.sendMessage("[" + ChatColor.RED + "j" + ChatColor.GOLD + "a" + ChatColor.YELLOW + "o" + ChatColor.GREEN + "S" + ChatColor.AQUA + "u" + ChatColor.BLUE + "p" + ChatColor.DARK_BLUE + "e" + ChatColor.RED + "r" + ChatColor.GOLD + "A" + ChatColor.YELLOW + "c" + ChatColor.GREEN + "h" + ChatColor.AQUA + "i" + ChatColor.BLUE + "e" + ChatColor.DARK_BLUE + "v" + ChatColor.RED + "e" + ChatColor.GOLD + "m" + ChatColor.YELLOW + "e" + ChatColor.GREEN + "n" + ChatColor.AQUA + "t" + ChatColor.RESET + "] " + "実績の解除中に問題が発生しました。もう一度お試しください。");
            return;
        }
    // Jail.JailAdd(player, Bukkit.getOfflinePlayer("jaotan"), "jaoium所持", true);
    }
}
Also used : Player(org.bukkit.entity.Player) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) PotionMeta(org.bukkit.inventory.meta.PotionMeta) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 67 with ItemStack

use of org.bukkit.inventory.ItemStack in project MyMaid2 by jaoafa.

the class Event_Antijaoium method onPotionSplashEvent.

@EventHandler
public void onPotionSplashEvent(PotionSplashEvent event) {
    if (!(event.getEntity().getShooter() instanceof Player)) {
        return;
    }
    Player player = (Player) event.getEntity().getShooter();
    Inventory inventory = player.getInventory();
    Inventory enderchestinventory = player.getEnderChest();
    ItemStack[] is = inventory.getContents();
    Boolean jaoium = false;
    for (int n = 0; n != is.length; n++) {
        if (is[n] == null) {
            continue;
        }
        ItemStack hand = is[n];
        if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
            PotionMeta potion = (PotionMeta) hand.getItemMeta();
            jaoium = isjaoium(potion.getCustomEffects());
            if (jaoium) {
                inventory.clear(n);
            }
        }
    }
    if (jaoium) {
        inventory.clear();
    }
    if (enderchestinventory != null) {
        is = enderchestinventory.getContents();
        for (int n = 0; n != is.length; n++) {
            if (is[n] == null) {
                continue;
            }
            ItemStack hand = is[n];
            if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
                PotionMeta potion = (PotionMeta) hand.getItemMeta();
                jaoium = isjaoium(potion.getCustomEffects());
                if (jaoium) {
                    inventory.clear(n);
                }
            }
        }
        if (jaoium) {
            enderchestinventory.clear();
        }
    }
    if (jaoium) {
        if (!Achievementjao.getAchievement(player, new AchievementType(13))) {
            player.sendMessage("[" + ChatColor.RED + "j" + ChatColor.GOLD + "a" + ChatColor.YELLOW + "o" + ChatColor.GREEN + "S" + ChatColor.AQUA + "u" + ChatColor.BLUE + "p" + ChatColor.DARK_BLUE + "e" + ChatColor.RED + "r" + ChatColor.GOLD + "A" + ChatColor.YELLOW + "c" + ChatColor.GREEN + "h" + ChatColor.AQUA + "i" + ChatColor.BLUE + "e" + ChatColor.DARK_BLUE + "v" + ChatColor.RED + "e" + ChatColor.GOLD + "m" + ChatColor.YELLOW + "e" + ChatColor.GREEN + "n" + ChatColor.AQUA + "t" + ChatColor.RESET + "] " + "実績の解除中に問題が発生しました。もう一度お試しください。");
            return;
        }
        Bukkit.broadcastMessage("[jaoium_Checker] " + ChatColor.GREEN + "プレイヤー「" + player.getName() + "」からjaoiumと同等の性能を持つアイテムが検出されました。");
        // Jail.JailAdd(player, Bukkit.getOfflinePlayer("jaotan"), "jaoium所持", true);
        event.setCancelled(true);
    }
}
Also used : Player(org.bukkit.entity.Player) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) PotionMeta(org.bukkit.inventory.meta.PotionMeta) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 68 with ItemStack

use of org.bukkit.inventory.ItemStack in project MyMaid2 by jaoafa.

the class Event_Antijaoium method onPlayerItemHeldEvent.

@EventHandler(ignoreCancelled = true)
public void onPlayerItemHeldEvent(PlayerItemHeldEvent event) {
    Player player = event.getPlayer();
    Inventory inventory = player.getInventory();
    Inventory enderchestinventory = player.getEnderChest();
    ItemStack[] is = inventory.getContents();
    Boolean jaoium = false;
    for (int n = 0; n != is.length; n++) {
        if (is[n] == null) {
            continue;
        }
        ItemStack hand = is[n];
        if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
            PotionMeta potion = (PotionMeta) hand.getItemMeta();
            jaoium = isjaoium(potion.getCustomEffects());
            if (jaoium) {
                inventory.clear(n);
            }
        }
    }
    if (jaoium) {
        inventory.clear();
    }
    if (enderchestinventory != null) {
        is = enderchestinventory.getContents();
        for (int n = 0; n != is.length; n++) {
            if (is[n] == null) {
                continue;
            }
            ItemStack hand = is[n];
            if (hand.getType() == Material.SPLASH_POTION || hand.getType() == Material.LINGERING_POTION) {
                PotionMeta potion = (PotionMeta) hand.getItemMeta();
                jaoium = isjaoium(potion.getCustomEffects());
                if (jaoium) {
                    inventory.clear(n);
                }
            }
        }
        if (jaoium) {
            enderchestinventory.clear();
        }
    }
    if (jaoium) {
        Bukkit.broadcastMessage("[jaoium_Checker] " + ChatColor.GREEN + "プレイヤー「" + player.getName() + "」からjaoiumと同等の性能を持つアイテムが検出されました。");
        if (!Achievementjao.getAchievement(player, new AchievementType(13))) {
            player.sendMessage("[" + ChatColor.RED + "j" + ChatColor.GOLD + "a" + ChatColor.YELLOW + "o" + ChatColor.GREEN + "S" + ChatColor.AQUA + "u" + ChatColor.BLUE + "p" + ChatColor.DARK_BLUE + "e" + ChatColor.RED + "r" + ChatColor.GOLD + "A" + ChatColor.YELLOW + "c" + ChatColor.GREEN + "h" + ChatColor.AQUA + "i" + ChatColor.BLUE + "e" + ChatColor.DARK_BLUE + "v" + ChatColor.RED + "e" + ChatColor.GOLD + "m" + ChatColor.YELLOW + "e" + ChatColor.GREEN + "n" + ChatColor.AQUA + "t" + ChatColor.RESET + "] " + "実績の解除中に問題が発生しました。もう一度お試しください。");
            return;
        }
    // Jail.JailAdd(player, Bukkit.getOfflinePlayer("jaotan"), "jaoium所持", true);
    }
}
Also used : Player(org.bukkit.entity.Player) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) PotionMeta(org.bukkit.inventory.meta.PotionMeta) ItemStack(org.bukkit.inventory.ItemStack) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 69 with ItemStack

use of org.bukkit.inventory.ItemStack in project MyMaid2 by jaoafa.

the class Cmd_AFK method setAFK_True.

/**
 * プレイヤーをAFKにする
 *
 * @param player 設定するプレイヤー
 * @author mine_book000
 */
public static void setAFK_True(Player player) {
    if (getHeadICE(player)) {
        PlayerInventory playerinv = player.getInventory();
        head.put(player.getName(), playerinv.getHelmet());
        player.getInventory().setHelmet(new ItemStack(Material.ICE));
        player.updateInventory();
    }
    Bukkit.broadcastMessage(ChatColor.DARK_GRAY + player.getName() + " is afk!");
    DiscordSend(player.getName() + " is afk!");
    if (!Achievementjao.getAchievement(player, new AchievementType(11))) {
        player.sendMessage("[" + ChatColor.RED + "j" + ChatColor.GOLD + "a" + ChatColor.YELLOW + "o" + ChatColor.GREEN + "S" + ChatColor.AQUA + "u" + ChatColor.BLUE + "p" + ChatColor.DARK_BLUE + "e" + ChatColor.RED + "r" + ChatColor.GOLD + "A" + ChatColor.YELLOW + "c" + ChatColor.GREEN + "h" + ChatColor.AQUA + "i" + ChatColor.BLUE + "e" + ChatColor.DARK_BLUE + "v" + ChatColor.RED + "e" + ChatColor.GOLD + "m" + ChatColor.YELLOW + "e" + ChatColor.GREEN + "n" + ChatColor.AQUA + "t" + ChatColor.RESET + "] " + "実績の解除中に問題が発生しました。もう一度お試しください。");
        return;
    }
    String listname = player.getPlayerListName().replaceAll(player.getName(), ChatColor.DARK_GRAY + player.getName());
    player.setPlayerListName(listname);
    TitleAPI.sendTitle(player, 0, 99999999, 0, ChatColor.RED + "AFK NOW!", ChatColor.BLUE + "" + ChatColor.BOLD + "When you are back, please enter the command '/afk' or Move.");
    try {
        BukkitTask task = new Task_AFKING(JavaPlugin(), player).runTaskTimer(JavaPlugin(), 0L, 5L);
        Cmd_AFK.afking.put(player.getName(), task);
    } catch (java.lang.NoClassDefFoundError e) {
        BugReporter(e);
        Cmd_AFK.afking.put(player.getName(), null);
    }
}
Also used : Task_AFKING(com.jaoafa.MyMaid2.Task.Task_AFKING) AchievementType(com.jaoafa.jaoSuperAchievement.jaoAchievement.AchievementType) BukkitTask(org.bukkit.scheduler.BukkitTask) PlayerInventory(org.bukkit.inventory.PlayerInventory) ItemStack(org.bukkit.inventory.ItemStack)

Example 70 with ItemStack

use of org.bukkit.inventory.ItemStack in project BKCommonLib by bergerhealer.

the class ItemMaterialTest method testEQIgnoreAmount.

private static void testEQIgnoreAmount(ItemStack item) {
    ItemStack a = ItemUtil.cloneItem(item);
    ItemStack b = ItemUtil.cloneItem(item);
    a.setAmount(1);
    b.setAmount(2);
    assertTrue(ItemUtil.equalsIgnoreAmount(a, b));
}
Also used : ItemStack(org.bukkit.inventory.ItemStack)

Aggregations

ItemStack (org.bukkit.inventory.ItemStack)1420 Player (org.bukkit.entity.Player)270 EventHandler (org.bukkit.event.EventHandler)197 ItemMeta (org.bukkit.inventory.meta.ItemMeta)192 ArrayList (java.util.ArrayList)151 Inventory (org.bukkit.inventory.Inventory)127 Material (org.bukkit.Material)103 Location (org.bukkit.Location)96 PlayerInventory (org.bukkit.inventory.PlayerInventory)84 Entity (org.bukkit.entity.Entity)67 Block (org.bukkit.block.Block)54 LivingEntity (org.bukkit.entity.LivingEntity)51 TagCompound (de.keyle.knbt.TagCompound)47 HashMap (java.util.HashMap)47 Map (java.util.Map)46 Vector (org.bukkit.util.Vector)44 Enchantment (org.bukkit.enchantments.Enchantment)41 SkullMeta (org.bukkit.inventory.meta.SkullMeta)41 Mage (com.elmakers.mine.bukkit.api.magic.Mage)39 Test (org.junit.Test)38