Item Effects and NoDrop.

Discussion in 'Plugin Development' started by ZONEcold, Jul 20, 2014.

Thread Status:
Not open for further replies.
  1. Offline


    Ive been working on a project lately (Please dont judge me ive only JUST gotten into Bukkit Plugin development :p) But I just want to make something simple. Say I have a item and I click a player (If PvP is on it will hurt them) Now I want THAT player that I clicked to freeze, if not freeze for something simpilar make it easier by giving them the effect of SLOWNESS for unlimited time and really powerful. I want that player that got frozen to also recieve a message, e.g. "You have been frozen" Ive been looking around on tutorials and stuff but I cant seem to find one. Another thing that may be useful for this is to have the item that freezes players not be allowed to be dropped. Say I spawn the item in with a command and I dont want it to drop although I dont want the item respawned with that command either only when they die they are allowed to spawn the item back in (Also when they die it shouldnt drop either) If you can help me with this OR provide really helpful Bukkit Plugin Tutorials that would be great!

    Thanks guys :)
  2. Offline


    I assume that you can write a simple plugin (there are tons of tutorials about it) and I'll give you hints for the specific problems:
    1 Freeze/Slow: You have to add a Listener, you can listen about the EntityDamageByEntityEvent then, if the routine checks are ok (both players are Player and online, not null ecc) you'll use addPotionEffect to the damagee only if the item used by the damager is the item you want. Another solution is adding a special effect to the item you want to slow (you can easily search "custom effects on item").

    2 Prevent Dropping: You have to listen about the PlayerDropItemEvent and, if the item is the one you are monitoring you can simply cancel the event. Also, to prevent players from spawn multiple items (1 for life ) you have to add a new command.
    Then, in the command execute use a simple Set of player names(UUID is better) for store the name of the command sender and for remove him from the Set you can simply listen to PlayerDeathEvent.
    Other small devices are for example the delete of the item from the player inventory on his death to prevent him from drop it ecc...
  3. Offline


    If you also want the item to 'not' drop on death, use the ItemSpawnEvent and cancel that
  4. Offline


  5. Offline


    ZONEcold The only problem is to identify the item. Using itemnames can be dangerous, because e.g. renaming the item with an anvil will destroy it, which was the reason for me to usually store stuff in lore.

    You can even hide stuff in the lore by using the colorchar. ("§a§b$cLORE" would be "LORE")
    The only downside is, if many plugins use this method, they might deny each other.
  6. Offline


Thread Status:
Not open for further replies.

Share This Page