Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package net.madcrazydrumma.auction;
- import net.minecraft.command.ICommandSender;
- import net.minecraft.command.NumberInvalidException;
- import net.minecraft.entity.player.EntityPlayer;
- import net.minecraft.item.Item;
- import net.minecraft.util.ResourceLocation;
- public class Auction
- {
- private ICommandSender player;
- private String itemID, currentBidder;
- private int amount, startPrice, curPrice, increment, duration;
- public Auction(ICommandSender player, String itemID, int amount, int startPrice, int increment, int duration) {
- this.player = player;
- this.itemID = itemID;
- this.amount = amount;
- this.startPrice = startPrice;
- this.curPrice = startPrice;
- this.increment = increment;
- this.duration = duration;
- this.currentBidder = "None";
- }
- public EntityPlayer getPlayer() {
- return (EntityPlayer)player.getCommandSenderEntity();
- }
- public String getPlayerName() {
- return player.getName();
- }
- public Item getItem() {
- Item item = null;
- try {
- item = getItemByText(player, itemID);
- } catch (NumberInvalidException e) {
- e.printStackTrace();
- }
- return item;
- }
- public int getAmount() {
- return amount;
- }
- public int getStartingPrice() {
- return startPrice;
- }
- public int getCurrentPrice() {
- return curPrice;
- }
- public void setCurrentPrice(int price) {
- this.curPrice = price;
- }
- public void incrementCurrentPrice() {
- curPrice += increment;
- }
- public int getIncrement() {
- return increment;
- }
- public int getDuration() {
- return duration;
- }
- public void decrementDuration() {
- duration -= 1;
- }
- public String getCurrentBidder() {
- return currentBidder;
- }
- public void setCurrentBidder(String username) {
- this.currentBidder = username;
- }
- public static Item getItemByText(ICommandSender sender, String id) throws NumberInvalidException
- {
- ResourceLocation resourcelocation = new ResourceLocation(id);
- Item item = (Item)Item.itemRegistry.getObject(resourcelocation);
- if (item == null)
- {
- throw new NumberInvalidException("commands.give.notFound", new Object[] {resourcelocation});
- }
- else
- {
- return item;
- }
- }
- }
Add Comment
Please, Sign In to add comment