Guest User

mc0230

a guest
Jun 23rd, 2011
195
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.93 KB | None | 0 0
  1. package com.gemo.FalseBook.IC.ICs.selftriggered;
  2.  
  3. import com.gemo.FalseBook.IC.FalseBookICBlockListener;
  4. import com.gemo.FalseBook.IC.FalseBookICCore;
  5. import com.gemo.FalseBook.IC.ICs.BaseIC;
  6. import java.util.ArrayList;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.Material;
  9. import org.bukkit.Server;
  10. import org.bukkit.World;
  11. import org.bukkit.block.Block;
  12. import org.bukkit.block.Sign;
  13. import org.bukkit.entity.Player;
  14. import org.bukkit.event.block.SignChangeEvent;
  15.  
  16. public class MC0230 extends BaseIC
  17. {
  18. private boolean selfStatus = false;
  19. private int val1 = -1; private int val2 = -1;
  20.  
  21. public MC0230(FalseBookICCore plugin, int x, int y, int z, String worldName)
  22. {
  23. super(plugin, x, y, z);
  24. this.Name = "IS IT DAY";
  25. this.MCName = "[MC0230]";
  26. this.MCGroup = "selftriggered";
  27. World w = plugin.getServer().getWorld(worldName);
  28. if (w.getBlockAt(x, y, z).getType().equals(Material.WALL_SIGN))
  29. {
  30. this.signBlock = ((Sign)w.getBlockAt(x, y, z).getState());
  31.  
  32. if (!BaseIC.validateIC(this.MCName, this.signBlock.getLine(1)))
  33. return;
  34. if (!FalseBookICBlockListener.getSensorList().contains(this))
  35. FalseBookICBlockListener.getSensorList().add(this);
  36. }
  37. }
  38.  
  39. public MC0230(FalseBookICCore plugin, SignChangeEvent event, boolean creation)
  40. {
  41. super(plugin, event, creation);
  42.  
  43. this.Name = "IS IT DAY";
  44. this.MCName = "[MC0230]";
  45. this.MCGroup = "selftriggered";
  46. if (creation)
  47. {
  48. if (!event.getBlock().getType().equals(Material.WALL_SIGN))
  49. {
  50. cancelCreation(event, ChatColor.RED + "There was an internal error while creating this IC.");
  51. return;
  52. }
  53. Player player = event.getPlayer();
  54. if (BaseIC.hasPermission(player, this.MCName, this.MCGroup))
  55. {
  56. event.setLine(0, this.Name);
  57. event.setLine(1, this.MCName);
  58. if (event.getLine(2).length() > 1)
  59. {
  60. try
  61. {
  62. Integer.valueOf(event.getLine(2));
  63. }
  64. catch (Exception e)
  65. {
  66. cancelCreation(event, ChatColor.RED + "Line 3 must be a number.");
  67. return;
  68. }
  69. }
  70. if (event.getLine(3).length() > 1)
  71. {
  72. try
  73. {
  74. Integer.valueOf(event.getLine(3));
  75. }
  76. catch (Exception e)
  77. {
  78. cancelCreation(event, ChatColor.RED + "Line 4 must be a number.");
  79. return;
  80. }
  81. }
  82.  
  83. this.signBlock = ((Sign)event.getBlock().getWorld().getBlockAt(event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ()).getState());
  84. if (!FalseBookICBlockListener.getSensorList().contains(this))
  85. FalseBookICBlockListener.getSensorList().add(this);
  86. player.sendMessage(ChatColor.GREEN + this.Name + " created.");
  87. }
  88. else
  89. {
  90. cancelCreation(event, "You are not allowed to build a " + this.Name + ".");
  91. return;
  92. }
  93. }
  94. }
  95.  
  96. public void Execute()
  97. {
  98. if (!BaseIC.validateIC(this.MCName, this.signBlock.getLine(1))) {
  99. return;
  100. }
  101. if ((this.signBlock.getLine(2).length() > 0) && (this.signBlock.getLine(3).length() > 0))
  102. {
  103. if ((this.val1 == -1) && (this.val2 == -1))
  104. {
  105. this.val1 = Integer.valueOf(this.signBlock.getLine(2)).intValue();
  106. this.val2 = Integer.valueOf(this.signBlock.getLine(3)).intValue();
  107. }
  108.  
  109. if (this.val1 <= this.val2)
  110. {
  111. if ((this.signBlock.getWorld().getTime() >= this.val1) && (this.signBlock.getWorld().getTime() <= this.val2) && (!this.selfStatus))
  112. {
  113. switchLever(this.signBlock, true);
  114. this.selfStatus = (!this.selfStatus);
  115. }
  116. else if (((this.signBlock.getWorld().getTime() < this.val1) || (this.signBlock.getWorld().getTime() > this.val2)) && (this.selfStatus))
  117. {
  118. switchLever(this.signBlock, false);
  119. this.selfStatus = (!this.selfStatus);
  120. }
  121. }
  122. else if (this.val1 > this.val2)
  123. {
  124. if (((this.signBlock.getWorld().getTime() >= this.val1) || (this.signBlock.getWorld().getTime() <= this.val2)) && (!this.selfStatus))
  125. {
  126. switchLever(this.signBlock, true);
  127. this.selfStatus = (!this.selfStatus);
  128. }
  129. else if ((this.signBlock.getWorld().getTime() < this.val1) && (this.signBlock.getWorld().getTime() > this.val2) && (this.selfStatus))
  130. {
  131. switchLever(this.signBlock, false);
  132. this.selfStatus = (!this.selfStatus);
  133. }
  134.  
  135. }
  136.  
  137. }
  138. else if ((this.signBlock.getWorld().getTime() < 13000L) && (!this.selfStatus))
  139. {
  140. switchLever(this.signBlock, true);
  141. this.selfStatus = (!this.selfStatus);
  142. }
  143. else if ((this.signBlock.getWorld().getTime() >= 13000L) && (this.selfStatus))
  144. {
  145. switchLever(this.signBlock, false);
  146. this.selfStatus = (!this.selfStatus);
  147. }
  148. }
  149. }
Advertisement
Add Comment
Please, Sign In to add comment