Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package me.jonah.Minigames;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.block.Sign;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.block.BlockPlaceEvent;
- import org.bukkit.event.inventory.InventoryClickEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.event.player.PlayerJoinEvent;
- import org.bukkit.inventory.Inventory;
- import org.bukkit.inventory.ItemStack;
- import org.bukkit.inventory.meta.ItemMeta;
- import org.bukkit.plugin.java.JavaPlugin;
- import org.bukkit.scoreboard.Scoreboard;
- import org.bukkit.scoreboard.ScoreboardManager;
- import org.bukkit.scoreboard.Team;
- public class MiniGamesPaintball extends JavaPlugin implements Listener{
- Logger l = Bukkit.getLogger();
- ScoreboardManager manager;
- Scoreboard board;
- Team flame,flame2,flame3;
- Team ice,ice2,ice3;
- @Override
- public void onEnable(){
- l.info("Minigames Paintball is being enabled!");
- getConfig();
- getConfig().options().copyDefaults(true);
- saveConfig();
- manager = Bukkit.getScoreboardManager();
- board = manager.getNewScoreboard();
- ice = board.registerNewTeam("Ice Team");
- flame = board.registerNewTeam("Flame Team");
- ice2 = board.registerNewTeam("Ice Team 2");
- flame2 = board.registerNewTeam("Flame Team 2");
- ice3 = board.registerNewTeam("Ice Team 3");
- flame3 = board.registerNewTeam("Flame Team 3");
- ice.setPrefix(ChatColor.AQUA+"");
- flame.setPrefix(ChatColor.RED+"");
- ice2.setPrefix(ChatColor.AQUA+"");
- flame2.setPrefix(ChatColor.RED+"");
- ice3.setPrefix(ChatColor.AQUA+"");
- flame3.setPrefix(ChatColor.RED+"");
- this.getServer().getPluginManager().registerEvents(this,this);
- }
- @Override
- public void onDisable(){
- l.info("Minigames Paintball is being disabled!");
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player p = (Player) sender;
- if (p.isOp()){
- if ((label.equalsIgnoreCase("createpbarena"))&&(args.length == 1)){
- if (getConfig().contains("paintball" + args[0])){
- p.sendMessage("This arena already exists");
- }
- else
- {
- getConfig().createSection("paintball" + args[0]);
- getConfig().createSection("paintball" + args[0] + ".lobby");
- getConfig().createSection("paintball" + args[0] + ".lobby.world");
- getConfig().createSection("paintball" + args[0] + ".lobby.x");
- getConfig().createSection("paintball" + args[0] + ".lobby.y");
- getConfig().createSection("paintball" + args[0] + ".lobby.z");
- getConfig().createSection("paintball" + args[0] + ".flame");
- getConfig().createSection("paintball" + args[0] + ".flame.world");
- getConfig().createSection("paintball" + args[0] + ".flame.x");
- getConfig().createSection("paintball" + args[0] + ".flame.y");
- getConfig().createSection("paintball" + args[0] + ".flame.z");
- getConfig().createSection("paintball" + args[0] + ".ice.world");
- getConfig().createSection("paintball" + args[0] + ".ice.x");
- getConfig().createSection("paintball" + args[0] + ".ice.y");
- getConfig().createSection("paintball" + args[0] + ".ice.z");
- saveConfig();
- p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " created.");
- }
- }
- if ((label.equalsIgnoreCase("setpblobby"))&&(args.length == 1)){
- Location l = p.getLocation();
- getConfig().set("paintball" + args[0] + ".lobby.world", l.getWorld().getName());
- getConfig().set("paintball" + args[0] + ".lobby.x", l.getX());
- getConfig().set("paintball" + args[0] + ".lobby.y", l.getY());
- getConfig().set("paintball" + args[0] + ".lobby.z", l.getZ());
- saveConfig();
- l = null;
- p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " lobby set.");
- }
- if ((label.equalsIgnoreCase("gotopblobby"))&&(args.length == 1)){
- Location lobby = p.getLocation();
- String worldname = getConfig().getString("paintball" + args[0] + ".lobby.world");
- lobby.setWorld(Bukkit.getServer().getWorld(worldname));
- lobby.setX(getConfig().getDouble("paintball" + args[0] + ".lobby.x"));
- lobby.setY(getConfig().getDouble("paintball" + args[0] + ".lobby.y"));
- lobby.setZ(getConfig().getDouble("paintball" + args[0] + ".lobby.z"));
- p.teleport(lobby);
- saveConfig();
- lobby = null;
- p.sendMessage(ChatColor.AQUA + "Teleported to paintball lobby " + args[0]);
- }
- if (label.equalsIgnoreCase("setpbflame")){
- Location flame = p.getLocation();
- getConfig().set("paintball" + args[0] + ".flame.world", flame.getWorld().getName());
- getConfig().set("paintball" + args[0] + ".flame.x", flame.getX());
- getConfig().set("paintball" + args[0] + ".flame.y", flame.getY());
- getConfig().set("paintball" + args[0] + ".flame.z", flame.getZ());
- saveConfig();
- flame = null;
- p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " Flame set.");
- }
- if ((label.equalsIgnoreCase("gotopbflame"))&&(args.length == 1)){
- Location flame = p.getLocation();
- String worldname = getConfig().getString("paintball" + args[0] + ".flame.world");
- flame.setWorld(Bukkit.getServer().getWorld(worldname));
- flame.setX(getConfig().getDouble("paintball" + args[0] + ".flame.x"));
- flame.setY(getConfig().getDouble("paintball" + args[0] + ".flame.y"));
- flame.setZ(getConfig().getDouble("paintball" + args[0] + ".flame.z"));
- p.teleport(flame);
- saveConfig();
- flame = null;
- p.sendMessage(ChatColor.AQUA + "Teleported to paintball Flame " + args[0]);
- }
- if (label.equalsIgnoreCase("setpbice")){
- Location ice = p.getLocation();
- getConfig().set("paintball" + args[0] + ".ice.world", ice.getWorld().getName());
- getConfig().set("paintball" + args[0] + ".ice.x", ice.getX());
- getConfig().set("paintball" + args[0] + ".ice.y", ice.getY());
- getConfig().set("paintball" + args[0] + ".ice.z", ice.getZ());
- saveConfig();
- ice = null;
- p.sendMessage(ChatColor.AQUA + "Paintball Arena " + args[0] + " Ice set.");
- }
- if ((label.equalsIgnoreCase("gotopbice"))&&(args.length == 1)){
- Location ice = p.getLocation();
- String worldname = getConfig().getString("paintball" + args[0] + ".ice.world");
- ice.setWorld(Bukkit.getServer().getWorld(worldname));
- ice.setX(getConfig().getDouble("paintball" + args[0] + ".ice.x"));
- ice.setY(getConfig().getDouble("paintball" + args[0] + ".ice.y"));
- ice.setZ(getConfig().getDouble("paintball" + args[0] + ".ice.z"));
- p.teleport(ice);
- saveConfig();
- ice = null;
- p.sendMessage(ChatColor.AQUA + "Teleported to paintball Ice " + args[0]);
- }
- if (label.equalsIgnoreCase("mgpbreload")){
- reloadConfig();
- saveConfig();
- }
- if (label.equalsIgnoreCase("openlast")){
- openGUIpb(p);
- }
- }
- return true;
- }
- public void startpb(){
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- Player p = event.getPlayer();
- if(event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
- if(event.getClickedBlock().getType().getId() ==63 || event.getClickedBlock().getType().getId() == 68) {
- Sign sign = (Sign) event.getClickedBlock().getState();
- if (sign.getLine(0).contains("[Paintball]")){
- Location lobby = p.getLocation();
- String worldname = getConfig().getString("paintball1.lobby.world");
- lobby.setWorld(Bukkit.getServer().getWorld(worldname));
- lobby.setX(getConfig().getDouble("paintball" + sign.getLine(1) + ".lobby.x"));
- lobby.setY(getConfig().getDouble("paintball" + sign.getLine(1) + ".lobby.y"));
- lobby.setZ(getConfig().getDouble("paintball" + sign.getLine(1) + ".lobby.z"));
- p.teleport(lobby);
- saveConfig();
- lobby = null;
- p.sendMessage(ChatColor.AQUA + "Teleported to paintball lobby " + sign.getLine(1));
- }
- }
- }
- if (event.getAction() == Action.PHYSICAL || event.getItem() == null || event.getItem().getType() == Material.AIR){
- return;
- }
- if (event.getItem().getType() == Material.COMPASS){
- openGUI(p);
- }
- }
- @EventHandler
- public void onPlayerJoin(PlayerJoinEvent event){
- Player p = event.getPlayer();
- p.sendMessage("Yo");
- }
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onBlockPlaceEvent(BlockPlaceEvent e) {
- Player p = e.getPlayer();
- if (e.getBlockPlaced().getType().getId() ==63 || e.getBlockPlaced().getType().getId() == 68) {
- p.sendMessage("You placed a sign");
- }
- }
- public void openGUI(Player p){
- Inventory inv = Bukkit.createInventory(null,9,"Game Selector");
- ItemStack pbservers = new ItemStack(Material.SNOW_BALL);
- ItemMeta pbserversMeta = pbservers.getItemMeta();
- pbserversMeta.setDisplayName(ChatColor.RED + "Paintball");
- pbservers.setItemMeta(pbserversMeta);
- inv.setItem(3, pbservers);
- p.openInventory(inv);
- }
- public void openGUIpb(Player p){
- Inventory inv1 = Bukkit.createInventory(null,9,"Paintball Servers");
- ItemStack pbserver1 = new ItemStack(Material.EYE_OF_ENDER);
- ItemMeta pbserver1Meta = pbserver1.getItemMeta();
- pbserver1Meta.setDisplayName(ChatColor.AQUA + "Server 1");
- List<String> pbserver1List = new ArrayList<String>();
- pbserver1List.add(ChatColor.GRAY + "Players: " + ChatColor.GREEN + (ice.getSize() + flame.getSize()) + "/16");
- pbserver1Meta.setLore(pbserver1List);
- pbserver1.setItemMeta(pbserver1Meta);
- inv1.setItem(0, pbserver1);
- p.closeInventory();
- p.sendMessage("YOYOYO");
- p.openInventory(inv1);
- }
- @EventHandler
- public void onInventoryClick(InventoryClickEvent event){
- Player p = (Player) event.getWhoClicked();
- p.sendMessage("test");
- if (event.getCurrentItem().getType() == Material.SNOW_BALL){
- p.sendMessage("Hey!");
- openGUIpb(p);
- }
- if (event.getCurrentItem().getType() == Material.EYE_OF_ENDER){
- Location lobby = p.getLocation();
- String worldname = getConfig().getString("paintball1.lobby.world");
- lobby.setWorld(Bukkit.getServer().getWorld(worldname));
- lobby.setX(getConfig().getDouble("paintball1.lobby.x"));
- lobby.setY(getConfig().getDouble("paintball1.lobby.y"));
- lobby.setZ(getConfig().getDouble("paintball1.lobby.z"));
- p.teleport(lobby);
- saveConfig();
- lobby = null;
- p.sendMessage(ChatColor.AQUA + "Teleported to paintball lobby 1");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement