Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. package de.cubenetwork.lokykun.cubestats.tables;
  2.  
  3. import java.util.HashMap;
  4.  
  5. import de.cubenetwork.lokykun.cubestats.CubeStatsPlugin;
  6.  
  7. public class ItemUseTable {
  8.  
  9.     public int[] block;
  10.     public int[] item;
  11.     public int hand;
  12.  
  13.     public ItemUseTable(CubeStatsPlugin plugin) {
  14.  
  15.  
  16.         // Array größe defenieren
  17.         block = new int[94];
  18.         item = new int[2002];
  19.         hand = 0;
  20.  
  21.  
  22.     }
  23.  
  24.    
  25.     /**
  26.      * Addiert block hinzu
  27.      *
  28.      * @param block
  29.      */
  30.     public void setInTable(int itemID) {
  31.        
  32.         if (itemID == 0){
  33.             this.hand++;
  34.         }else if (itemID >= 256){
  35.             this.item[itemID-256]++;
  36.         }else{
  37.             this.block[itemID-1]++;
  38.         }
  39.  
  40.     }
  41.    
  42.     /**
  43.      * gibt den inhalt des Tabels als HashMap zurück
  44.      * @return HashMap<Integer, Integer>
  45.      */
  46.     public HashMap<Integer, Integer> getHashMap(){
  47.         HashMap<Integer, Integer> table = new HashMap<Integer, Integer>();
  48.        
  49.         if (hand > 0){
  50.             table.put(0, hand);
  51.         }
  52.        
  53.         for (int i = 0; i < block.length; i++) {
  54.             if (block[i] > 0){
  55.                 table.put(i+1, block[i]);
  56.             }
  57.         }
  58.         for (int i = 0; i < item.length; i++) {
  59.             if (item[i] > 0){
  60.                 table.put(i+256, item[i]);
  61.             }
  62.         }
  63.         return table;
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement