Guest User

Untitled

a guest
Jan 4th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.23 KB | None | 0 0
  1. package net.madcrazydrumma.auction;
  2.  
  3. import net.minecraft.command.ICommandSender;
  4. import net.minecraft.command.NumberInvalidException;
  5. import net.minecraft.entity.player.EntityPlayer;
  6. import net.minecraft.item.Item;
  7. import net.minecraft.util.ResourceLocation;
  8.  
  9. public class Auction
  10. {
  11. private ICommandSender player;
  12. private String itemID, currentBidder;
  13. private int amount, startPrice, curPrice, increment, duration;
  14.  
  15. public Auction(ICommandSender player, String itemID, int amount, int startPrice, int increment, int duration) {
  16. this.player = player;
  17. this.itemID = itemID;
  18. this.amount = amount;
  19. this.startPrice = startPrice;
  20. this.curPrice = startPrice;
  21. this.increment = increment;
  22. this.duration = duration;
  23. this.currentBidder = "None";
  24. }
  25.  
  26. public EntityPlayer getPlayer() {
  27. return (EntityPlayer)player.getCommandSenderEntity();
  28. }
  29.  
  30. public String getPlayerName() {
  31. return player.getName();
  32. }
  33.  
  34. public Item getItem() {
  35. Item item = null;
  36. try {
  37. item = getItemByText(player, itemID);
  38. } catch (NumberInvalidException e) {
  39. e.printStackTrace();
  40. }
  41. return item;
  42. }
  43.  
  44. public int getAmount() {
  45. return amount;
  46. }
  47.  
  48. public int getStartingPrice() {
  49. return startPrice;
  50. }
  51.  
  52. public int getCurrentPrice() {
  53. return curPrice;
  54. }
  55.  
  56. public void setCurrentPrice(int price) {
  57. this.curPrice = price;
  58. }
  59.  
  60. public void incrementCurrentPrice() {
  61. curPrice += increment;
  62. }
  63.  
  64. public int getIncrement() {
  65. return increment;
  66. }
  67.  
  68. public int getDuration() {
  69. return duration;
  70. }
  71.  
  72. public void decrementDuration() {
  73. duration -= 1;
  74. }
  75.  
  76. public String getCurrentBidder() {
  77. return currentBidder;
  78. }
  79.  
  80. public void setCurrentBidder(String username) {
  81. this.currentBidder = username;
  82. }
  83.  
  84. public static Item getItemByText(ICommandSender sender, String id) throws NumberInvalidException
  85. {
  86. ResourceLocation resourcelocation = new ResourceLocation(id);
  87. Item item = (Item)Item.itemRegistry.getObject(resourcelocation);
  88.  
  89. if (item == null)
  90. {
  91. throw new NumberInvalidException("commands.give.notFound", new Object[] {resourcelocation});
  92. }
  93. else
  94. {
  95. return item;
  96. }
  97. }
  98. }
Add Comment
Please, Sign In to add comment