api: rename Item to TileItem and add Item value class

Item was actually the renderable Item and is being misused for
ItemContainer items
This commit is contained in:
Adam
2019-07-23 10:59:01 -04:00
parent 3700876cf8
commit 2ffe3affbc
6 changed files with 60 additions and 26 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* Copyright (c) 2019, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -24,23 +24,11 @@
*/
package net.runelite.api;
/**
* Represents an item inside an {@link ItemContainer}.
*/
public interface Item extends Renderable
{
/**
* Gets the items ID.
*
* @return the ID of the item
* @see ItemID
*/
int getId();
import lombok.Value;
/**
* Gets the items quantity.
*
* @return the items quantity
*/
int getQuantity();
@Value
public class Item
{
private final int id;
private final int quantity;
}

View File

@@ -130,7 +130,7 @@ public interface Tile
*
* @return the ground items
*/
List<Item> getGroundItems();
List<TileItem> getGroundItems();
/**
* Return the tile under this one, if this tile is a bridge

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2016-2017, Adam <Adam@sigterm.info>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.runelite.api;
/**
* Represents an item inside an {@link ItemLayer}.
*/
public interface TileItem extends Renderable
{
/**
* Gets the items ID.
*
* @return the ID of the item
* @see ItemID
*/
int getId();
/**
* Gets the items quantity.
*
* @return the items quantity
*/
int getQuantity();
}

View File

@@ -25,7 +25,7 @@
package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Item;
import net.runelite.api.TileItem;
import net.runelite.api.Tile;
/**
@@ -36,5 +36,5 @@ import net.runelite.api.Tile;
public class ItemDespawned
{
private final Tile tile;
private final Item item;
private final TileItem item;
}

View File

@@ -25,7 +25,7 @@
package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Item;
import net.runelite.api.TileItem;
import net.runelite.api.Tile;
/**
@@ -34,7 +34,7 @@ import net.runelite.api.Tile;
@Value
public class ItemQuantityChanged
{
private final Item item;
private final TileItem item;
private final Tile tile;
private final int oldQuantity;
private final int newQuantity;

View File

@@ -25,7 +25,7 @@
package net.runelite.api.events;
import lombok.Value;
import net.runelite.api.Item;
import net.runelite.api.TileItem;
import net.runelite.api.Tile;
/**
@@ -36,5 +36,5 @@ import net.runelite.api.Tile;
public class ItemSpawned
{
private final Tile tile;
private final Item item;
private final TileItem item;
}