Advertisement
Guest User

Untitled

a guest
Jan 4th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.48 KB | None | 0 0
  1. package net.madcrazydrumma.event;
  2.  
  3. import net.madcrazydrumma.CasinoMod;
  4. import net.minecraft.server.MinecraftServer;
  5. import net.minecraft.util.ChatComponentText;
  6. import net.minecraft.util.EnumChatFormatting;
  7. import net.minecraftforge.fml.common.Mod;
  8. import net.minecraftforge.fml.common.eventhandler.EventPriority;
  9. import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
  10. import net.minecraftforge.fml.common.gameevent.TickEvent.Phase;
  11. import net.minecraftforge.fml.common.gameevent.TickEvent.ServerTickEvent;
  12.  
  13. public class TickEventHandler
  14. {
  15. private final String AUCTION_PREFIX = EnumChatFormatting.WHITE + "[" + EnumChatFormatting.GOLD + "Auction" + EnumChatFormatting.WHITE + "] - ";
  16.  
  17. int counter = 0;
  18.  
  19. @SubscribeEvent
  20. public void serverTickEvent(ServerTickEvent event) {
  21. if(event.phase == Phase.END) {
  22. if(CasinoMod.PUBLIC_AUCTION != null) {
  23. int duration = CasinoMod.PUBLIC_AUCTION.getDuration();
  24.  
  25. if(duration == 5) {
  26. MinecraftServer.getServer().addChatMessage(new ChatComponentText(AUCTION_PREFIX + "The auction is ending soon!"));
  27. }
  28.  
  29. if(counter++ % 20 == 0) {
  30. if(duration <= 0) {
  31. CasinoMod.PUBLIC_AUCTION = null;
  32. MinecraftServer.getServer().addChatMessage(new ChatComponentText(AUCTION_PREFIX + "Auction has ended..."));
  33. //give items to players or return original items :)
  34. } else {
  35. CasinoMod.PUBLIC_AUCTION.decrementDuration();
  36. }
  37. } else {
  38. counter++;
  39. }
  40. }
  41. }
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement