Some progress

This commit is contained in:
Sam 2016-12-13 22:39:38 +00:00
parent 99b69bd8c8
commit 33ac4f49fd
4 changed files with 69 additions and 15 deletions

View File

@ -4,6 +4,12 @@ import org.bukkit.inventory.ItemStack;
import mineplex.core.common.util.UtilMath;
/**
* Represents an item that can be contained in a chest inside the Gem Hunters
* world.
*
* @author Sam
*/
public class LootItem
{
@ -12,7 +18,7 @@ public class LootItem
private int _maxAmount;
private double _probability;
private String _metadata;
public LootItem(ItemStack itemStack, int minAmount, int maxAmount, double probability, String metadata)
{
_itemStack = itemStack;
@ -21,32 +27,66 @@ public class LootItem
_probability = probability;
_metadata = metadata;
}
/**
* Returns the Minecraft {@link ItemStack} bound to this
* {@link LootItem}.<br>
* The {@link ItemStack} returned will have an amount/size between the
* minAmount and maxAmount integers (set within the constuctor's parameters)
* inclusively.
*
* @return
*/
public ItemStack getItemStack()
{
_itemStack.setAmount(_minAmount + UtilMath.r(_maxAmount - _minAmount + 1));
return _itemStack;
}
/**
* The minimum amount or size an {@link ItemStack} of this {@link LootItem}
* can have.
*
* @return
*/
public int getMinAmount()
{
return _minAmount;
}
/**
* The maximum amount or size an {@link ItemStack} of this {@link LootItem}
* can have.
*
* @return
*/
public int getMaxAmount()
{
return _maxAmount;
}
/**
* The double value of the item's probability of being chosen to when
* picking an individual chest's loot.
*
* @return
*/
public double getProbability()
{
return _probability;
}
/**
* Any metadata bound to a {@link LootItem}. Useful for determining if an
* item has a particular <i>skill</i> or <i>ability</i> attached to it which
* you can use in code.
*
* @return
*/
public String getMetadata()
{
return _metadata;
}
}

View File

@ -61,7 +61,7 @@ public class LootModule extends MiniPlugin
}
public void updateChestLoot()
{
{
try
{
Map<String, List<List<Object>>> map = _sheets.getCellValues(CHEST_LOOT_SHEET);
@ -178,12 +178,12 @@ public class LootModule extends MiniPlugin
int sizeMultiplier = 1;
BlockState state = block.getState();
//TODO fix double chests
// TODO fix double chests
if (state instanceof DoubleChest)
{
sizeMultiplier = 2;
}
Chest chest = (Chest) state;
Inventory inventory = chest.getBlockInventory();

View File

@ -7,6 +7,12 @@ import mineplex.core.common.Rank;
import mineplex.core.common.util.F;
import mineplex.gemhunters.loot.LootModule;
/**
* An ADMIN command that allows users to retrieve the latest data from the
* google sheet and update all locally cached loot tables.
*
* @author Sam
*/
public class UpdateLootCommand extends CommandBase<LootModule>
{
@ -20,13 +26,13 @@ public class UpdateLootCommand extends CommandBase<LootModule>
{
if (args.length > 1)
{
//TODO send redis message
// TODO send redis message
}
caller.sendMessage(F.main(Plugin.getName(), "Updating loot tables asynchronusly..."));
Plugin.runAsync(() -> Plugin.updateChestLoot());
caller.sendMessage(F.main(Plugin.getName(), "Finished!"));
}

View File

@ -0,0 +1,8 @@
package mineplex.gemhunters.worldevent;
public enum WorldEventState
{
}