Thread: #118 Item definitions > xml

Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1 #118 Item definitions > xml 
    Sponjebobu

    Jack94's Avatar
    Join Date
    Mar 2009
    Posts
    6,750
    Thanks given
    1,760
    Thanks received
    2,466
    Rep Power
    4752
    Contains the following defs
    • Id
    • Name
    • Examine
    • Price
    • Stackable indicator
    • Noted indicator
    • bonuses
    • tradeable indicator
    • alch values
    • weight


    Link; [Only registered and activated users can see links. ]

    Loader / def class
    Code:
    package server.model.items;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Objects;
    import java.util.logging.Logger;
    
    import server.model.players.Player;
    import server.model.players.content.container.impl.Equipment;
    import server.util.XMLController;
    
    /**
     * 
     * @author Jack
     *
     */
    
    public class ItemDefinitions {
    
    	/**
    	 * Map which contains all item defintion data
    	 */
    	private static HashMap<Integer, ItemDefinitions> definitions = new HashMap<Integer, ItemDefinitions>();
    
    	/**
    	 * Fetches definitions map
    	 * 
    	 * @param id
    	 * @return
    	 */
    	public static ItemDefinitions get(int id) {
    		return definitions.get(id);
    	}
    
    	/**
    	 * Logger
    	 */
    	private static final Logger logger = Logger.getLogger(ItemDefinitions.class.getName());
    
    	/**
    	 * Loads the definitions from XML file
    	 * 
    	 * @throws FileNotFoundException
    	 */
    	@SuppressWarnings({ "unchecked" })
    	public static void loadDefinitions() throws FileNotFoundException {
    		logger.info("Loading item definitions...");
    		List<ItemDefinitions> definitionList = (List<ItemDefinitions>) XMLController.getxStream().fromXML(
    				new FileInputStream("./Data/item_definitions.xml"));
    
    		for (ItemDefinitions defs : definitionList) {
    			definitions.put(defs.getId(), defs);
    		}
    		logger.info("..." + definitions.size() + " item definitions loaded.");
    	}
    
    	/**
    	 * Item id
    	 */
    	private int id;
    
    	/**
    	 * Item name
    	 */
    	private String name;
    
    	/**
    	 * Item description
    	 */
    	private String examine;
    
    	/**
    	 * Item price
    	 */
    	private int price;
    
    	/**
    	 * Stackable indicator
    	 */
    	private boolean stackable = false;
    
    	/**
    	 * Noted indicator
    	 */
    	private boolean noted = false;
    
    	/**
    	 * Item bonuses
    	 */
    	private int[] bonuses = new int[14];
    
    	/**
    	 * Tradeable indicator
    	 */
    	private boolean tradeable = true;
    
    	/**
    	 * Item alch values
    	 */
    	private int[] alchValues = new int[2];
    
    	/**
    	 * Item weight
    	 */
    	private double weight;
    
    	public int getId() {
    		return this.id;
    	}
    
    	public String getName() {
    		return this.name;
    	}
    
    	public String getExamine() {
    		return this.examine;
    	}
    
    	public int getPrice() {
    		return this.price;
    	}
    
    	public boolean isStackable() {
    		return this.stackable;
    	}
    
    	public boolean isNoted() {
    		return this.noted;
    	}
    
    	public int[] getBonuses() {
    		return this.bonuses;
    	}
    
    	public boolean tradeable() {
    		return this.tradeable;
    	}
    
    	public int[] getAlchValues() {
    		return this.alchValues;
    	}
    
    	public double getWeight() {
    		return this.weight;
    	}
    }


    inb4youshouldatleastusejson
    I am not longer an active part of this community
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member

    Join Date
    Dec 2012
    Posts
    3,012
    Thanks given
    897
    Thanks received
    924
    Rep Power
    2525
    Just use an array since you can refer via id
    Reply With Quote  
     

  4. #3  
    ( ͡ ͜ʖ ͡)


    Join Date
    Sep 2014
    Age
    21
    Posts
    2,409
    Thanks given
    1,333
    Thanks received
    1,107
    Rep Power
    5000
    youshouldatleastusejson

    No but really, shame I use json but I'm sure this'll benefit quite a few. Nice release.
    Reply With Quote  
     

  5. #4  
    Registered Member

    Join Date
    Sep 2014
    Posts
    2,114
    Thanks given
    3,020
    Thanks received
    987
    Rep Power
    5000
    Quote Originally Posted by A Mage View Post
    youshouldatleastusejson

    No but really, shame I use json but I'm sure this'll benefit quite a few. Nice release.
    convert it, good release jack!
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  6. #5  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    21
    Posts
    1,328
    Thanks given
    2,608
    Thanks received
    579
    Rep Power
    571
    Quote Originally Posted by A Mage View Post
    youshouldatleastusejson

    No but really, shame I use json but I'm sure this'll benefit quite a few. Nice release.
    Can easily be converted!
    Spoiler for sig too large:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  7. Thankful users:


  8. #6  
    ( ͡ ͜ʖ ͡)


    Join Date
    Sep 2014
    Age
    21
    Posts
    2,409
    Thanks given
    1,333
    Thanks received
    1,107
    Rep Power
    5000
    Quote Originally Posted by hc747 View Post
    Can easily be converted!
    I suppose so.
    Reply With Quote  
     

  9. #7  
    Registered Member
    hc747's Avatar
    Join Date
    Dec 2013
    Age
    21
    Posts
    1,328
    Thanks given
    2,608
    Thanks received
    579
    Rep Power
    571
    JSON: [Only registered and activated users can see links. ]
    Spoiler for sig too large:
    [Only registered and activated users can see links. ]
    [Only registered and activated users can see links. ]
    Reply With Quote  
     

  10. Thankful users:


  11. #8  
    Registered Member
    Join Date
    Jun 2016
    Posts
    248
    Thanks given
    92
    Thanks received
    48
    Rep Power
    66
    How do I apply this into a source?
    Reply With Quote  
     

  12. #9  
    Extreme Donator

    Genesis's Avatar
    Join Date
    Sep 2010
    Posts
    3,768
    Thanks given
    1,478
    Thanks received
    1,924
    Rep Power
    4855
    Quote Originally Posted by A Mage View Post
    youshouldatleastusejson

    No but really, shame I use json but I'm sure this'll benefit quite a few. Nice release.
    Or a relational database.
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]
    • [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]


    1. [Only registered and activated users can see links. ]
    2. [Only registered and activated users can see links. ]
    Reply With Quote  
     

  13. #10  
    Registered Member
    Join Date
    Jan 2016
    Posts
    30
    Thanks given
    0
    Thanks received
    1
    Rep Power
    11
    Quote Originally Posted by Idiot Bird View Post
    Contains the following defs
    • Id
    • Name
    • Examine
    • Price
    • Stackable indicator
    • Noted indicator
    • bonuses
    • tradeable indicator
    • alch values
    • weight


    Link; [Only registered and activated users can see links. ]

    Loader / def class
    Code:
    package server.model.items;
    
    import java.io.FileInputStream;
    import java.io.FileNotFoundException;
    import java.util.HashMap;
    import java.util.List;
    import java.util.Objects;
    import java.util.logging.Logger;
    
    import server.model.players.Player;
    import server.model.players.content.container.impl.Equipment;
    import server.util.XMLController;
    
    /**
     * 
     * @author Jack
     *
     */
    
    public class ItemDefinitions {
    
    	/**
    	 * Map which contains all item defintion data
    	 */
    	private static HashMap<Integer, ItemDefinitions> definitions = new HashMap<Integer, ItemDefinitions>();
    
    	/**
    	 * Fetches definitions map
    	 * 
    	 * @param id
    	 * @return
    	 */
    	public static ItemDefinitions get(int id) {
    		return definitions.get(id);
    	}
    
    	/**
    	 * Logger
    	 */
    	private static final Logger logger = Logger.getLogger(ItemDefinitions.class.getName());
    
    	/**
    	 * Loads the definitions from XML file
    	 * 
    	 * @throws FileNotFoundException
    	 */
    	@SuppressWarnings({ "unchecked" })
    	public static void loadDefinitions() throws FileNotFoundException {
    		logger.info("Loading item definitions...");
    		List<ItemDefinitions> definitionList = (List<ItemDefinitions>) XMLController.getxStream().fromXML(
    				new FileInputStream("./Data/item_definitions.xml"));
    
    		for (ItemDefinitions defs : definitionList) {
    			definitions.put(defs.getId(), defs);
    		}
    		logger.info("..." + definitions.size() + " item definitions loaded.");
    	}
    
    	/**
    	 * Item id
    	 */
    	private int id;
    
    	/**
    	 * Item name
    	 */
    	private String name;
    
    	/**
    	 * Item description
    	 */
    	private String examine;
    
    	/**
    	 * Item price
    	 */
    	private int price;
    
    	/**
    	 * Stackable indicator
    	 */
    	private boolean stackable = false;
    
    	/**
    	 * Noted indicator
    	 */
    	private boolean noted = false;
    
    	/**
    	 * Item bonuses
    	 */
    	private int[] bonuses = new int[14];
    
    	/**
    	 * Tradeable indicator
    	 */
    	private boolean tradeable = true;
    
    	/**
    	 * Item alch values
    	 */
    	private int[] alchValues = new int[2];
    
    	/**
    	 * Item weight
    	 */
    	private double weight;
    
    	public int getId() {
    		return this.id;
    	}
    
    	public String getName() {
    		return this.name;
    	}
    
    	public String getExamine() {
    		return this.examine;
    	}
    
    	public int getPrice() {
    		return this.price;
    	}
    
    	public boolean isStackable() {
    		return this.stackable;
    	}
    
    	public boolean isNoted() {
    		return this.noted;
    	}
    
    	public int[] getBonuses() {
    		return this.bonuses;
    	}
    
    	public boolean tradeable() {
    		return this.tradeable;
    	}
    
    	public int[] getAlchValues() {
    		return this.alchValues;
    	}
    
    	public double getWeight() {
    		return this.weight;
    	}
    }


    inb4youshouldatleastusejson
    Code:
    sep 19, 2016 11:18:09 AM rs2.Server main
    INFO: Initializing RuneScape...
    Sep 19, 2016 11:18:09 AM rs2.abyssalps.model.items.defs.ItemDefinitions init
    INFO: Loading item definitions...
    Exception in thread "main" com.thoughtworks.xstream.converters.ConversionException: itemDef : itemDef
    ---- Debugging information ----
    path                : /list/itemDef 
    message             : itemDef : itemDef 
    required-type       : java.util.ArrayList 
    line number         : 2 
    cause-message       : itemDef : itemDef 
    class               : java.util.List 
    cause-exception     : com.thoughtworks.xstream.alias.CannotResolveClassException
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. #118 Equipment Definitions.xml
    By Dinh in forum Requests
    Replies: 4
    Last Post: 07-31-2016, 06:43 AM
  2. #110 Item Definitions .xml
    By Severus in forum Requests
    Replies: 0
    Last Post: 03-31-2016, 02:29 PM
  3. Replies: 13
    Last Post: 02-20-2016, 12:08 AM
  4. Replies: 7
    Last Post: 11-07-2012, 09:35 PM
  5. [HYPERION] Adding new item definition's
    By AlexMason in forum Tutorials
    Replies: 15
    Last Post: 04-09-2011, 02:23 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •