Config Help

Discussion in 'Plugin Development' started by Glass_Eater84, Aug 14, 2014.

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

    Glass_Eater84

    Hey,

    I am trying to make a config where you can change the block/item in which the plugin will use. Also I want them to be able to control what hotbar slot it goes in. Any help would be much appreciated!

    Best regards,
    Glass
     
  2. Offline

    MCMatters

  3. Offline

    Skionz

    I'm also wondering something similar to this, is there any nice way to get items from the config without using getId() since ids are gone in the next update?
     
  4. Offline

    xTigerRebornx

    Skionz Material has methods to convert to/from Strings, you can store those, as well as other aspects of ItemMeta.
    Also, both ItemStack and ItemMeta are ConfigurationSerializable, meaning you can directly set them into configs.
     
  5. Offline

    Glass_Eater84

    MCMatters
    xTigerRebornx
    I know but how would I set it up like
    Code:java
    1. getConfig()

    then what would I have to do?
     
  6. Offline

    xTigerRebornx

    Glass_Eater84 Depends on what you want to store. Simply the Material? Material, Lore, Name? For Material, its as simple as setting/getting a String. Lore, its setting a String List and getting it. Name, also a String.
     
  7. Offline

    Glass_Eater84

    xTigerRebornx
    I want to get the item and the name. As of now it is blazepowder but I want them to be able to change it.

    bump

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

    Gater12

    Glass_Eater84
    Store material, name, and hotbar slot in the config.

    Then construct the ItemStack with that information from the config.
     
  9. Offline

    Glass_Eater84

  10. Offline

    Glass_Eater84

    Didn't work :/
    I am trying to work it into this code.
    Code:java
    1. public class Main extends JavaPlugin implements Listener{
    2. ArrayList<String> disco = new ArrayList<String>();
    3. String prefix = ChatColor.GRAY + "[" + ChatColor.RED + "DiscoArmour" + ChatColor.GRAY + "]" + ChatColor.GOLD + " ";
    4.  
    5. @EventHandler
    6. public void noDrop(PlayerDropItemEvent e){e.setCancelled(true);
    7.  
    8. }
    9.  
    10. @SuppressWarnings("deprecation")
    11. @EventHandler
    12. public void onPlayerJoin(PlayerJoinEvent event){
    13. Player p = event.getPlayer();
    14. ItemStack blaze = new ItemStack(Material.BLAZE_POWDER);
    15. ItemMeta im = blaze.getItemMeta();
    16. im.setDisplayName("§a§lDisco Armour");
    17. blaze.setItemMeta(im);
    18. p.getInventory().addItem(blaze);
    19. p.updateInventory();
    20.  
    21. }
    22. @EventHandler
    23. public void onPlayerQuit(PlayerQuitEvent event){
    24. Player p = event.getPlayer();
    25. p.getInventory().remove(Material.BLAZE_POWDER);
    26. disco.remove(p.getName());
    27.  
    28. }
    29. @SuppressWarnings("deprecation")
    30. @EventHandler(priority=EventPriority.HIGH)
    31. public void onPlayerUse(PlayerInteractEvent event){
    32. Player o = event.getPlayer();
    33.  
    34. Action a = event.getAction();
    35. if(a == Action.RIGHT_CLICK_AIR){
    36. if(o.getItemInHand().getType() == Material.BLAZE_POWDER && o.hasPermission("use.Test")){
    37. if(o.getItemInHand().getItemMeta().getDisplayName().equals("§a§lTest")){


    want to make it so it doesn't have to be blaze powder and they can customize the lore, and item.
     
Thread Status:
Not open for further replies.

Share This Page