Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.YourMCAdmin.LLPogo;
- //import org.bukkit.Bukkit;
- //import org.bukkit.Material;
- //import org.bukkit.entity.Player;
- //import org.bukkit.event.EventHandler;
- //import org.bukkit.event.Listener;
- //import org.bukkit.event.player.PlayerItemHeldEvent;
- //import org.bukkit.inventory.ItemStack;
- //import org.bukkit.plugin.java.JavaPlugin;
- //import org.bukkit.potion.PotionEffect;
- ////import org.bukkit.potion.PotionEffect;
- ////import org.bukkit.potion.PotionEffectType;
- //import org.bukkit.potion.PotionEffectType;
- //
- //public class main extends JavaPlugin implements Listener {
- //
- // @Override
- // public void onEnable()
- // {
- // getLogger().info("LegitLand Pogo has been enabled.");
- // getConfig().options().copyDefaults(true);
- // saveDefaultConfig();
- // Bukkit.getServer().getPluginManager().registerEvents(this, this);
- // }
- //
- // public void onDisable() {};
- //
- //
- //// @EventHandler
- //// public void onPlayerItemHeld(PlayerItemHeldEvent e)
- //// {
- //// Player player = e.getPlayer();
- //// //ItemStack item = player.getItemInHand();
- //// ItemStack newItem;
- //// newItem = player.getInventory().getItem(e.getNewSlot());
- //// player.sendMessage("Item switched");
- //// getLogger().info("Item switched");
- //// if(newItem != null){
- //// if(newItem.getType() == Material.STICK) {
- //// player.sendMessage("Stick found");
- //// getLogger().info("Stick found");
- //// }else if(newItem.getType() != Material.STICK){
- //// player.sendMessage("Not a stick silly");
- //// getLogger().info("Not a stick.");
- //// }
- ////
- ////// if (player.getInventory().getItemInHand().getItemMeta().getLore().contains("pogo")){
- ////// player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 72000, 3));
- ////// player.sendMessage("Pogo activate");
- //////
- ////// } else {
- ////// player.removePotionEffect(PotionEffectType.JUMP);
- ////// }
- ////
- //// }
- //// }
- import org.bukkit.Bukkit;
- import org.bukkit.Material;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.potion.*;
- import org.bukkit.inventory.*;
- import org.bukkit.entity.*;
- import org.bukkit.event.player.PlayerItemHeldEvent;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- public class main extends JavaPlugin implements Listener {
- public void onEnable() {
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- ;
- }
- public void onDisable() {
- }
- @EventHandler
- public void onJoin(PlayerItemHeldEvent event) {
- Player p = event.getPlayer();
- ItemStack item = p.getInventory().getItem(event.getNewSlot());
- if(item != null) { // <--- I put it here because if it's null it "doesn't exist".
- if (item.getType() == Material.GOLD_SWORD) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0));
- } else if (item.getType() != Material.GOLD_SWORD) {
- p.removePotionEffect(PotionEffectType.INVISIBILITY);
- }
- if (item.getType() == Material.IRON_SWORD) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 999999, 0));
- } else if (item.getType() != Material.IRON_SWORD) {
- p.removePotionEffect(PotionEffectType.ABSORPTION);
- }
- if (item.getType() == Material.BOW) {
- p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 999999, 0));
- } else if (item.getType() != Material.BOW) {
- p.removePotionEffect(PotionEffectType.NIGHT_VISION);
- }
- } else {
- p.removePotionEffect(PotionEffectType.ABSORPTION);
- p.removePotionEffect(PotionEffectType.INVISIBILITY);
- p.removePotionEffect(PotionEffectType.NIGHT_VISION);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement