Esempio n. 1
0
  public void rebuild() {
    for (String locale : Locale.getLocales()) {
      if (!localeMeta.containsKey(locale)) localeMeta.put(locale, getLocaleMeta("en_GB"));
    }
    for (String locale : Locale.getLocales()) {
      List<String> lines = getTooltipLines(locale);
      ItemMeta meta = getLocaleMeta(locale);
      meta.setDisplayName(lines.get(0));
      lines.remove(0);
      meta.setLore(lines);
      setLocaleMeta(locale, meta);
      // item.setItemMeta(meta);
    }

    for (Player player : Bukkit.getOnlinePlayers()) {
      Iterator<ItemStack> it = player.getInventory().iterator();
      String locale = Locale.getPlayerLocale(player);
      while (it.hasNext()) {
        ItemStack item = it.next();
        if (ItemManager.toRPGItem(item) != null) updateItem(item, locale, false);
      }
      for (ItemStack item : player.getInventory().getArmorContents()) {
        if (ItemManager.toRPGItem(item) != null) updateItem(item, locale, false);
      }
    }
    resetRecipe(true);
  }
 /** Tests if an added item is contained in the list. */
 public void testAdd() {
   final ItemManager manager = new ItemManager();
   final ExpirableItem item = new ExpirableItem();
   manager.add(item);
   final boolean isItemInList = manager.getAllItems().contains(item);
   assertTrue("The item added cannot be found in the list", isItemInList);
 }
  /** Tests the removal of items. */
  public void testRemove() {
    final ItemManager manager = new ItemManager();
    final ExpirableItem item = new ExpirableItem();
    manager.add(item);
    manager.remove(item);

    final boolean isItemInList = manager.getAllItems().contains(item);
    assertFalse("The manager still knows the removed item", isItemInList);
  }
  /** Tests replacement of all items. */
  public void testReplaceAll() {
    final ItemManager manager = new ItemManager();
    final ExpirableItem oldItem = new ExpirableItem();
    manager.add(oldItem);

    final Collection col = new ArrayList();
    final ExpirableItem newItem = new ExpirableItem();
    newItem.setName("NewItem");
    col.add(newItem);
    manager.replaceAll(col);

    assertFalse("Manager still knows old item", manager.getAllItems().contains(oldItem));
    assertTrue("Manager does not know new item", manager.getAllItems().contains(newItem));
  }
Esempio n. 5
0
 private void saveItem() {
   mItem.setTitle(mTitle.getText().toString());
   mItem.setDetails(mDetails.getText().toString());
   // date is already set
   mItem.setAutodelete(mAutoDelete.isChecked());
   ItemManager.get(getActivity()).saveItem(mItem);
 }
Esempio n. 6
0
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Long itemId = null;

    Bundle args = getArguments();
    if (args != null && args.containsKey(ARG_ITEM_ID)) {
      itemId = (Long) args.getSerializable(ARG_ITEM_ID);
    }

    if (itemId != null) {
      ItemManager mgr = ItemManager.get(getActivity());
      mItem = mgr.getItem(itemId);
    }

    if (mItem == null) {
      mItem = new Item();
    }
  }
Esempio n. 7
0
 public void giveArmor(Player p, String i) {
   if (im.checkArmor(p, i)) {
     if (i.equalsIgnoreCase(Main.CHAIN)) {
       p.getInventory().setArmorContents(CHAIN_ARMOR);
     } else if (i.equalsIgnoreCase(Main.DIAMOND)) {
       p.getInventory().setArmorContents(DIAMOND_ARMOR);
     } else if (i.equalsIgnoreCase(Main.LEATHER)) {
       p.getInventory().setArmorContents(LEATHER_ARMOR);
     } else if (i.equalsIgnoreCase(Main.GOLD)) {
       p.getInventory().setArmorContents(GOLD_ARMOR);
     } else if (i.equalsIgnoreCase(Main.IRON)) {
       p.getInventory().setArmorContents(IRON_ARMOR);
     }
     p.sendMessage(Main.prefix + "You have got a " + ChatColor.AQUA + i + ChatColor.GOLD + " set");
   } else {
     p.sendMessage(Main.prefix + ChatColor.RED + "You haven't bought this kit yet!");
   }
 }
Esempio n. 8
0
 public static void updateItem(
     ItemStack item, String locale, RPGMetadata rpgMeta, boolean updateDurability) {
   RPGItem rItem = ItemManager.toRPGItem(item);
   if (rItem == null) return;
   item.setType(rItem.item.getType());
   ItemMeta meta = rItem.getLocaleMeta(locale);
   if (!(meta instanceof LeatherArmorMeta) && updateDurability) {
     item.setDurability(rItem.item.getDurability());
   }
   List<String> lore = meta.getLore();
   rItem.addExtra(rpgMeta, item, lore);
   lore.set(0, meta.getLore().get(0) + rpgMeta.toMCString());
   meta.setLore(lore);
   Map<Enchantment, Integer> enchantments = null;
   if (enchantmentSupport) enchantments = item.getEnchantments();
   item.setItemMeta(meta);
   if (enchantmentSupport) item.addEnchantments(enchantments);
 }
Esempio n. 9
0
 /** @param args */
 public static void main(String[] args) {
   Barcode.Test();
   Item.Test();
   Product.Test();
   StorageUnit.Test();
   ProductContainer.Test();
   ProductGroup.Test();
   ProductList.Test();
   ItemList.Test();
   ProductContainerList.Test();
   ItemFilter.Test();
   ProductFilter.Test();
   ItemManager.Test();
   ProductManager.Test();
   //		Size.Test();
   StorageUnitManager.Test();
   System.out.println("All tests passed.");
 }
Esempio n. 10
0
 public void resetRecipe(boolean removeOld) {
   if (removeOld) {
     Iterator<Recipe> it = Bukkit.recipeIterator();
     while (it.hasNext()) {
       Recipe recipe = it.next();
       RPGItem rpgitem = ItemManager.toRPGItem(recipe.getResult());
       if (rpgitem == null) continue;
       if (rpgitem.getID() == getID()) {
         it.remove();
       }
     }
   }
   if (hasRecipe) {
     Set<ItemStack> iSet = new HashSet<ItemStack>();
     for (ItemStack m : recipe) {
       iSet.add(m);
     }
     ItemStack[] iList = iSet.toArray(new ItemStack[iSet.size()]);
     item.setItemMeta(getLocaleMeta("en_GB"));
     ShapedRecipe shapedRecipe = new ShapedRecipe(item);
     int i = 0;
     Map<ItemStack, Character> iMap = new HashMap<ItemStack, Character>();
     for (ItemStack m : iList) {
       iMap.put(m, (char) (65 + i));
       i++;
     }
     iMap.put(null, ' ');
     StringBuilder out = new StringBuilder();
     for (ItemStack m : recipe) {
       out.append(iMap.get(m));
     }
     String shape = out.toString();
     shapedRecipe.shape(shape.substring(0, 3), shape.substring(3, 6), shape.substring(6, 9));
     for (Entry<ItemStack, Character> e : iMap.entrySet()) {
       if (e.getKey() != null) {
         shapedRecipe.setIngredient(
             e.getValue(), e.getKey().getType(), e.getKey().getDurability());
       }
     }
     Bukkit.addRecipe(shapedRecipe);
   }
 }
Esempio n. 11
0
 private void deleteItem() {
   ItemManager.get(getActivity()).deleteItem(mItem);
 }
 /** Tests if supply list is not null. */
 public void testGetSupplyList() {
   final ItemManager manager = new ItemManager();
   final List supply = manager.getAllItems();
   assertNotNull("getSupplyList() returns null", supply);
 }
Esempio n. 13
0
  // uh, this needs refactoring
  private void createPlayer(ShipConfig prevShip) {
    Vector2 pos = myGalaxyFiller.getPlayerSpawnPos(this);
    myCam.setPos(pos);

    Pilot pilot;
    if (myCmp.getOptions().controlType == GameOptions.CONTROL_MOUSE) {
      myBeaconHandler.init(this, pos);
      pilot =
          new AiPilot(
              new BeaconDestProvider(), true, Fraction.LAANI, false, "you", Const.AI_DET_DIST);
    } else {
      pilot = new UiControlledPilot(myScreens.mainScreen);
    }

    ShipConfig shipConfig;
    if (DebugOptions.GOD_MODE) {
      shipConfig = myPlayerSpawnConfig.godShipConfig;
    } else if (prevShip != null) {
      shipConfig = prevShip;
    } else {
      shipConfig = myPlayerSpawnConfig.shipConfig;
    }

    float money =
        myRespawnMoney != 0 ? myRespawnMoney : myTutorialManager != null ? 200 : shipConfig.money;

    HullConfig hull = myRespawnHull != null ? myRespawnHull : shipConfig.hull;

    String itemsStr = !myRespawnItems.isEmpty() ? "" : shipConfig.items;

    boolean giveAmmo = prevShip == null && myRespawnItems.isEmpty();
    myHero =
        myShipBuilder
            .buildNewFar(
                this,
                new Vector2(pos),
                null,
                0,
                0,
                pilot,
                itemsStr,
                hull,
                null,
                true,
                money,
                null,
                giveAmmo)
            .toObj(this);

    ItemContainer ic = myHero.getItemContainer();
    if (!myRespawnItems.isEmpty()) {
      for (int i1 = 0, sz = myRespawnItems.size(); i1 < sz; i1++) {
        SolItem item = myRespawnItems.get(i1);
        ic.add(item);
      }
    } else if (DebugOptions.GOD_MODE) {
      myItemManager.addAllGuns(ic);
    } else if (myTutorialManager != null) {
      for (int i = 0; i < 50; i++) {
        if (ic.groupCount() > 1.5f * Const.ITEM_GROUPS_PER_PAGE) break;
        SolItem it = myItemManager.random();
        if (!(it instanceof GunItem) && it.getIcon(this) != null && ic.canAdd(it)) {
          ic.add(it.copy());
        }
      }
    }
    ic.seenAll();
    AiPilot.reEquip(this, myHero);

    myObjectManager.addObjDelayed(myHero);
    myObjectManager.resetDelays();
  }