Can anyone let me know why this code doesn't give me speed when I move with the helmet on?

  • Thread starter Thread starter /u/LiamIsntMe
  • Start date Start date

/u/LiamIsntMe

Guest
Member
(For context, I created a custom item called the Retro-Encabulating Visor)



Listener:

public class Events implements Listener { @EventHandler public static void onPlayerMove(PlayerMoveEvent event) { Player player = event.getPlayer(); ItemStack retroVisor = ItemManager.RETRO_ENCABULATING_VISOR; if (player.getInventory().getHelmet() == retroVisor) { player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 999999, 3)); } if (player.getInventory().getHelmet() == null || player.getInventory().getHelmet() != ItemManager.RETRO_ENCABULATING_VISOR) { player.removePotionEffect(PotionEffectType.SPEED); } } }

ItemManager:

public class ItemManager { public static ItemStack RETRO_ENCABULATING_VISOR; public static void init() { createVisor(); } private static void createVisor() { ItemStack skull = new ItemStack(Material.PLAYER_HEAD, 1); SkullMeta skullMeta = (SkullMeta) skull.getItemMeta(); skullMeta.setOwningPlayer(Bukkit.getOfflinePlayer("mrekk1003")); skullMeta.setDisplayName("§dRetro-Encabulating Visor"); List<String> lore = new ArrayList<>(); lore.add("§7Lets you run at super-duper high"); lore.add("§7speeds when worn."); lore.add("\n"); lore.add("§8Satirical technobabble they said!"); lore.add("§8A non-existent machine they said!"); lore.add("\n"); lore.add("§d§lMYTHIC VISOR"); skullMeta.setLore(lore); skullMeta.setUnbreakable(true); skullMeta.addItemFlags(ItemFlag.HIDE_UNBREAKABLE); skull.setItemMeta(skullMeta); RETRO_ENCABULATING_VISOR = skull; } }

Commands:

public class Commands implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command cmd, @NotNull String label, @NotNull String[] args) { if (!(sender instanceof Player)) { sender.sendMessage("Only players may use this command."); return true; } Player player = (Player) sender; if (cmd.getName().equalsIgnoreCase("i")) { if (args.length <= 2) { if (args[0].equals("RETRO_ENCABULATING_VISOR")) { player.getInventory().addItem(ItemManager.RETRO_ENCABULATING_VISOR); } } else { player.sendMessage("§cNot a valid item."); } } return true; } }

When I run the /i command, it gives me the item all fine, but when I put it on it doesn't give me the speed effect that it should be giving me from the listener.

submitted by /u/LiamIsntMe
[link] [comments]

Continue reading...

free plugins
minecraft paid for free
spigotmc
SpigotMC
free minecraft paid plugins
free minecraft plugins
aac free
ewg free
Minecraft Premium Plugins
ewg free download
litebans free
epicworldgenerator free
free schematics
leaked schematics minecraft
schematics
schematics leaked
schematics free
minecraft schematics free
paid minecraft schematics free
paid minecraft schematics for free
free cracked plugins
free cracked minecraft plugins
plugins
featherboard download
featherboard plugin download
antiaura download
minecraft plugins
xenforo leaked
xenforo for free
xenforo addons
 
Top