Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.jobisingh;
- import java.lang.reflect.Array;
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.Collection;
- import java.util.HashMap;
- import java.util.HashSet;
- import java.util.List;
- import com.sk89q.worldedit.BlockVector;
- import com.sk89q.worldedit.bukkit.WorldEditPlugin;
- import com.sk89q.worldedit.bukkit.selections.CuboidSelection;
- import com.sk89q.worldedit.bukkit.selections.Selection;
- import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
- import com.sk89q.worldguard.bukkit.commands.task.RegionAdder;
- import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
- import com.sk89q.worldguard.protection.regions.ProtectedRegion;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- // Color Code Here §
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.InventoryView;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- import me.jobisingh.handlers.Game;
- //Color Code §
- public class MainClass extends JavaPlugin {
- public static Location lobbyLocation;
- public int getPoint1;
- @Override
- public void onEnable() {
- new ListenerClass(this);
- new Game();
- this.getConfig().addDefault("LobbySpawn:", lobbyLocation);
- this.getConfig().options().copyDefaults(true);
- saveConfig();
- }
- @Override
- public void onDisable() {
- saveConfig();
- }
- private WorldGuardPlugin getWorldGuard() {
- Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
- // WorldGuard may not be loaded
- if (plugin == null || !(plugin instanceof WorldGuardPlugin)) {
- return null; // Maybe you want throw an exception instead
- }
- return (WorldGuardPlugin) plugin;
- }
- public WorldEditPlugin getWorldEdit() {
- Plugin p = Bukkit.getServer().getPluginManager().getPlugin("WorldEdit");
- if(p instanceof WorldEditPlugin) return (WorldEditPlugin) p;
- else return null;
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (cmd.getName().equalsIgnoreCase("setteam1spawn") && sender instanceof Player) {
- Player player = (Player) sender;
- @SuppressWarnings("deprecation")
- Block getBlock = player.getTargetBlock((HashSet<Byte>)null, 100);
- int x = getBlock.getX();
- int y = getBlock.getY();
- int z = getBlock.getZ();
- player.sendMessage("Team 1 Spawn Set At " + x + " " + y + " " + z);
- return true;
- }
- else if (cmd.getName().equalsIgnoreCase("lobbyCreate") && sender instanceof Player) {
- Player player = (Player) sender;
- int length = args.length;
- if (length == 1) {
- Object lobbyName = args[0];
- if(lobbyName.equals(args[0])) {
- int getPoint1X = ListenerClass.pointGetter.get("point1X");
- int getPoint2X = ListenerClass.pointGetter2.get("point2X");
- int getPoint1Y = ListenerClass.pointGetter.get("point1Y");
- int getPoint2Y = ListenerClass.pointGetter2.get("point2Y");
- int getPoint1Z = ListenerClass.pointGetter.get("point1Z");
- int getPoint2Z = ListenerClass.pointGetter2.get("point2Z");
- Location getPoint1 = ListenerClass.locationGetter.get("point1");
- Location getPoint2 = ListenerClass.locationGetter2.get("point2");
- if (getPoint1 != null && getPoint2 != null) {
- if (getConfig().get((String) lobbyName) == null) {
- HashMap<Integer, Location> lobbies = new HashMap<>();
- Location blockSelector = getPoint1;
- int blockSelectorX = blockSelector.getBlockX();
- int blockSelectorY = blockSelector.getBlockY();
- int blockSelectorZ = blockSelector.getBlockZ();
- double blockSelector2;
- int replaceVarX = 0;
- int replaceVarY = 0;
- int replaceVarZ = 0;
- if(getPoint1X > 0 && getPoint2X > 0 && getPoint1X < getPoint2X) {
- replaceVarX = blockSelector.getBlockX() + 1;
- }
- else if(getPoint1X > 0 && getPoint2X > 0 && getPoint1X > getPoint2X) {
- replaceVarX = blockSelector.getBlockX() - 1;
- }
- else if (getPoint1X < 0 && getPoint2X < 0 && getPoint1X < getPoint2X) {
- replaceVarX = blockSelector.getBlockX() + 1;
- }
- else if (getPoint1X < 0 && getPoint2X < 0 && getPoint1X > getPoint2X) {
- replaceVarX = blockSelector.getBlockX() - 1;
- }
- //maybe good code plz
- else if (getPoint1X > 0 && getPoint2X < 0) {
- replaceVarX = blockSelector.getBlockX() - 1;
- }
- else if (getPoint1X < 0 && getPoint2X > 0) {
- replaceVarX = blockSelector.getBlockX() + 1;
- }
- if(getPoint1Z > 0 && getPoint2Z > 0 && getPoint1Z < getPoint2Z) {
- replaceVarZ = blockSelector.getBlockZ() + 1;
- }
- else if(getPoint1Z > 0 && getPoint2Z > 0 && getPoint1Z > getPoint2Z) {
- replaceVarZ = blockSelector.getBlockZ() - 1;
- }
- else if (getPoint1Z < 0 && getPoint2Z < 0 && getPoint1Z < getPoint2Z) {
- replaceVarX = blockSelector.getBlockX() + 1;
- }
- else if (getPoint1Z < 0 && getPoint2Z < 0 && getPoint1Z > getPoint2Z) {
- replaceVarZ = blockSelector.getBlockZ() - 1;
- }
- //maybe good code plz
- else if (getPoint1Z > 0 && getPoint2Z < 0) {
- replaceVarZ = blockSelector.getBlockZ() - 1;
- }
- else if (getPoint1Z < 0 && getPoint2Z > 0) {
- replaceVarZ = blockSelector.getBlockZ() + 1;
- }
- if(getPoint1Y > getPoint2Y) {
- replaceVarY = blockSelector.getBlockY() - 1;
- }
- else if (getPoint1Y < getPoint2Y) {
- replaceVarY = blockSelector.getBlockY() +1;
- }
- for(; blockSelector.getBlockX() != getPoint2X; blockSelector.setX(replaceVarX)) {
- for(; blockSelector.getBlockZ() != getPoint2Z; blockSelector.setZ(replaceVarZ) ) {
- for(; blockSelector.getBlockY() != getPoint2Y; blockSelector.setY(replaceVarY)) {
- lobbies.put(blockSelector.getBlockY(), blockSelector);
- }
- lobbies.put(blockSelector.getBlockZ(), blockSelector);
- }
- lobbies.put(blockSelector.getBlockZ(), blockSelector);
- }
- player.sendMessage("Lobby Created, " + args[0]);
- return true;
- }}
- else if (getPoint1 == null || getPoint2 == null) {
- player.sendMessage("Make Sure You Select Both Point1 and Point2");
- }
- else if (getConfig().get((String) lobbyName) != null) {
- player.sendMessage("A Lobby With This Name Already Exists! Do /lobbydelete (name) to delete the Lobby!");
- }
- }
- else {
- player.sendMessage("Error Invalid Syntax, /lobbycreate (LobbyName)");
- }
- }
- }
- else if (cmd.getName().equalsIgnoreCase("lobbySetSpawn") && sender instanceof Player) {
- Player player = (Player) sender;
- Location lobbyLocation = player.getLocation();
- int Xx = lobbyLocation.getBlockX();
- int Yy = lobbyLocation.getBlockY();
- int Zz = lobbyLocation.getBlockZ();
- World world = player.getWorld();
- Location lobbyLoc = new Location(player.getWorld(), Xx, Yy, Zz);
- getConfig().set("LobbySpawn:", lobbyLocation);
- return true;
- }
- else if (cmd.getName().equalsIgnoreCase("positionwand") && sender instanceof Player) {
- Player player = (Player) sender;
- int length = args.length;
- if (length == 0) {
- ItemStack wand = new ItemStack(Material.BLAZE_ROD, 1);
- Inventory inv = player.getInventory();
- int openInv = inv.firstEmpty();
- inv.setItem(openInv, wand);
- player.updateInventory();
- if(inv.getItem(0) != null) {
- ItemMeta wandIM = inv.getItem(openInv).getItemMeta();
- wandIM.setDisplayName(ChatColor.GREEN + "§lPositionWand");
- List<String> lore = Arrays.asList("§cLeft Click To Set Position 1, ", "§cAnd Right Click To Set Position 2.", " §cThen Simply do /lobbycreate");
- wandIM.setLore(lore);
- inv.getItem(openInv).setItemMeta(wandIM);
- }
- return true;
- }
- else {
- player.sendMessage("Error Invalid Syntax, /pos1");
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement