Special Items

Discussion in 'Plugin Development' started by beaudigi, Jan 21, 2014.

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


    Well this is more a "help" thread; but i am requesting help...:D

    Anyway what I need:

    Plugin: Special Items
    What it DOes; help coders develop special items

    What It needs to have: a explanation of how to rename Items (Eg name boots "greg" or something I know how to do colour codes :D, But metadata is hard :D)

    It also needs to show how this item can be used to gain special items.
    Eg when you rightclick dirt named "george" in the air "I know how to do this rightclick registerer, but not a specific bit of ddrt) it will do something cool :D. If you just rightclick normal dirt, it does nothing

    what I then plan to do is create kits using skript; but with java implantation.

    What I really need to learn is small snipets of:
    How metadata can be used to give items special abilities
    Some special abilities (eg: reistering fall damage, and then applying it to others. As well as this cancelling it)
    settign the damage of something (eg: a iron axe does 5 hearts more)

    Download: Source code :D

    If someone could do this it would help me a lot. Atm all I can do in Java is type /cat and make chat make a red "meow" :D
  2. Offline


    a quick google search will show that these plugin already are made. you didnt make it obvious if you plan to add onto the plugin but considering your lack of knowledge im guessing not please clear that up for me
  3. Offline


    Instead of making a plugin to help you how to do things, how about skip the middle man and help you how to do things.
    Moved to correct section.
  4. Offline


    beaudigi Here's basic code for setting Metadata:
    1. ItemStack stack = new ItemStack(Material.GRASS, 1);
    2. ItemMeta stackMeta = stack.getItemMeta();
    3. stackMeta.setDisplayName(""); // Insert name here!
    4. ArrayList<String> lore = new ArrayList<String>();
    5. lore.add(""); // Insert whatever lore here!
    6. stackMeta.setLore(lore);
    7. stack.setItemMeta(stackMeta);
  5. Offline


    Thanks, but say how to ensure that if the player is wearing boots with that metadata stuff occur. I know heaps of effects; I just dont know how to implanment them :D

    I dont want a plugin; I want help :D

    What I want to do is create items that when theyever they must have that name.
    This way I can then implament this with the pugin Skript
  6. Offline


    Basically something like this then?
    1. @EventHandler
    2. public void onInteractWith(PlayerInteractEvent event) {
    3. if(event.getAction() == Action.RIGHT_CLICK_BLOCK || event.getAction() == Action.RIGHT_CLICK_AIR) {
    4. if(event.getPlayer().getItemInHand().hasItemMeta()) {
    5. if(event.getPlayer().getItemInHand().getItemMeta().getDisplayName().equals("yourItemDisplayName")) {
    6. event.setCancelled(true);
    7. }
    8. if(event.getPlayer().getItemInHand().getItemMeta().getLore().contains("yourLore")) {
    9. event.setCancelled(true);
    10. }
    11. }
    12. }
    13. }
  7. Offline


    Better not use the display name. Because it can be changed by the player using an anvil.
    Stick with he lore to create special items.
    Or at least use only the information in the lore to determine if an item is special.
    So it does not matter if the player changes the items name at some point.
  8. Offline


    Your "Source Code" is not linked.
  9. Offline


    I added that purely to show him how basic usage of checking for metadata would look like, not supposed to be "use it nao in all teh things!" code. =P
  10. Offline


    Ty this
    Ty this really helps; a begginer like me :D

    I dont need to worry about anvils :D As the server is not survival/ plus I could make it use colours codes

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 6, 2016
  11. Offline


    IS it possible to check meta data whilst the player is wearing boots; this is my code atm (stomper)
    1. public void onEntityDamage(EntityDamageEvent event) {
    2. if (!(event.getEntity() instanceof Player))
    3. return;
    4. final Player eventPlayer = (Player) event.getEntity();
    5. if (Material.CHAINMAIL_BOOTS.equals(eventPlayer.getInventory()
    6. if(eventPlayer.getInventory().getItemInHand().hasItemMeta()) {
    7. if(eventPlayer.getInventory().getBoots().getType().getItemMeta().getDisplayName().equals(ChatColor.RED + "Stomper")) {
    8. event.setCancelled(true);
    9. }
    10. if(eventPlayer.getInventory().getBoots().getType().getBootsMeta().getLore().contains("Hold This to Stomp Players")) {
    11. event.setCancelled(true);
    12. event.getCause().equals(DamageCause.FALL))
    13. if(Damage > 4){
    14. event.setDamage(4);
    15. }
    16. for(Entity nearby : eventPlayer.getNearbyEntities(5D, 5D, 5D)){
    17. if(nearby instanceof Player){
    18. Player nearbyPlayer = (Player) nearby;
    20. if(nearbyPlayer.isSneaking()){
    21. nearbyPlayer.damage(3);
    22. } else {
    23. nearbyPlayer.damage(dmg);
  12. Offline


    2. @SuppressWarnings("deprecation")
    3. @EventHandler
    4. public void onEntityDamage(EntityDamageEvent event) {
    5. if (!(event.getEntity() instanceof Player)) return;
    6. Player eventPlayer = (Player) event.getEntity();
    7. if(eventPlayer.getInventory().getBoots().hasItemMeta()) {
    8. if(eventPlayer.getInventory().getBoots().getItemMeta().getDisplayName().equals(ChatColor.RED + "Stomper")) {
    9. event.setCancelled(true);
    10. }
    11. if(eventPlayer.getInventory().getBoots().getItemMeta().getLore().contains("Equip these to stomp on others!")) {
    12. if (event.getCause().equals(DamageCause.FALL)) {
    13. event.setCancelled(true);
    14. for(Entity nearby : eventPlayer.getNearbyEntities(5D, 5D, 5D)){
    15. if(nearby instanceof Player){
    16. Player nearbyPlayer = (Player) nearby;
    17. if(nearbyPlayer.isSneaking()){
    18. nearbyPlayer.damage(3);
    19. } else {
    20. nearbyPlayer.damage(event.getDamage());
    21. }
    22. }
    23. }
    24. }
    25. }
    26. }
    27. }
    28. }

    It is yes, here, your code is a bit messy, I've fixed it up a bit -^
  13. Offline


    Thanks :D
Thread Status:
Not open for further replies.

Share This Page