Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.gemo.FalseBook.IC.ICs.selftriggered;
- import com.gemo.FalseBook.IC.FalseBookICBlockListener;
- import com.gemo.FalseBook.IC.FalseBookICCore;
- import com.gemo.FalseBook.IC.ICs.BaseIC;
- import java.util.ArrayList;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.Server;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.block.Sign;
- import org.bukkit.entity.Player;
- import org.bukkit.event.block.SignChangeEvent;
- public class MC0230 extends BaseIC
- {
- private boolean selfStatus = false;
- private int val1 = -1; private int val2 = -1;
- public MC0230(FalseBookICCore plugin, int x, int y, int z, String worldName)
- {
- super(plugin, x, y, z);
- this.Name = "IS IT DAY";
- this.MCName = "[MC0230]";
- this.MCGroup = "selftriggered";
- World w = plugin.getServer().getWorld(worldName);
- if (w.getBlockAt(x, y, z).getType().equals(Material.WALL_SIGN))
- {
- this.signBlock = ((Sign)w.getBlockAt(x, y, z).getState());
- if (!BaseIC.validateIC(this.MCName, this.signBlock.getLine(1)))
- return;
- if (!FalseBookICBlockListener.getSensorList().contains(this))
- FalseBookICBlockListener.getSensorList().add(this);
- }
- }
- public MC0230(FalseBookICCore plugin, SignChangeEvent event, boolean creation)
- {
- super(plugin, event, creation);
- this.Name = "IS IT DAY";
- this.MCName = "[MC0230]";
- this.MCGroup = "selftriggered";
- if (creation)
- {
- if (!event.getBlock().getType().equals(Material.WALL_SIGN))
- {
- cancelCreation(event, ChatColor.RED + "There was an internal error while creating this IC.");
- return;
- }
- Player player = event.getPlayer();
- if (BaseIC.hasPermission(player, this.MCName, this.MCGroup))
- {
- event.setLine(0, this.Name);
- event.setLine(1, this.MCName);
- if (event.getLine(2).length() > 1)
- {
- try
- {
- Integer.valueOf(event.getLine(2));
- }
- catch (Exception e)
- {
- cancelCreation(event, ChatColor.RED + "Line 3 must be a number.");
- return;
- }
- }
- if (event.getLine(3).length() > 1)
- {
- try
- {
- Integer.valueOf(event.getLine(3));
- }
- catch (Exception e)
- {
- cancelCreation(event, ChatColor.RED + "Line 4 must be a number.");
- return;
- }
- }
- this.signBlock = ((Sign)event.getBlock().getWorld().getBlockAt(event.getBlock().getX(), event.getBlock().getY(), event.getBlock().getZ()).getState());
- if (!FalseBookICBlockListener.getSensorList().contains(this))
- FalseBookICBlockListener.getSensorList().add(this);
- player.sendMessage(ChatColor.GREEN + this.Name + " created.");
- }
- else
- {
- cancelCreation(event, "You are not allowed to build a " + this.Name + ".");
- return;
- }
- }
- }
- public void Execute()
- {
- if (!BaseIC.validateIC(this.MCName, this.signBlock.getLine(1))) {
- return;
- }
- if ((this.signBlock.getLine(2).length() > 0) && (this.signBlock.getLine(3).length() > 0))
- {
- if ((this.val1 == -1) && (this.val2 == -1))
- {
- this.val1 = Integer.valueOf(this.signBlock.getLine(2)).intValue();
- this.val2 = Integer.valueOf(this.signBlock.getLine(3)).intValue();
- }
- if (this.val1 <= this.val2)
- {
- if ((this.signBlock.getWorld().getTime() >= this.val1) && (this.signBlock.getWorld().getTime() <= this.val2) && (!this.selfStatus))
- {
- switchLever(this.signBlock, true);
- this.selfStatus = (!this.selfStatus);
- }
- else if (((this.signBlock.getWorld().getTime() < this.val1) || (this.signBlock.getWorld().getTime() > this.val2)) && (this.selfStatus))
- {
- switchLever(this.signBlock, false);
- this.selfStatus = (!this.selfStatus);
- }
- }
- else if (this.val1 > this.val2)
- {
- if (((this.signBlock.getWorld().getTime() >= this.val1) || (this.signBlock.getWorld().getTime() <= this.val2)) && (!this.selfStatus))
- {
- switchLever(this.signBlock, true);
- this.selfStatus = (!this.selfStatus);
- }
- else if ((this.signBlock.getWorld().getTime() < this.val1) && (this.signBlock.getWorld().getTime() > this.val2) && (this.selfStatus))
- {
- switchLever(this.signBlock, false);
- this.selfStatus = (!this.selfStatus);
- }
- }
- }
- else if ((this.signBlock.getWorld().getTime() < 13000L) && (!this.selfStatus))
- {
- switchLever(this.signBlock, true);
- this.selfStatus = (!this.selfStatus);
- }
- else if ((this.signBlock.getWorld().getTime() >= 13000L) && (this.selfStatus))
- {
- switchLever(this.signBlock, false);
- this.selfStatus = (!this.selfStatus);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment