Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Mudsquisher and OwenHertz's Hide and Seek plugin
- * Plugin: MudDucks HnS
- * Class created on: October 3, 2012
- * Version: 0.1
- */
- package me.speeddcuskandmudsquisher.plugins.mudduckshideandseek;
- import java.io.File;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.List;
- import java.util.logging.Logger;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.GameMode;
- import org.bukkit.Location;
- import org.bukkit.block.Block;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- public class HnS extends JavaPlugin{
- private HnSStart start0;
- private HnS plugin;
- public ArrayList<String> readyPlayers = new ArrayList<String>();
- // public static List<String> Players = new ArrayList<String>();
- public ArrayList<String> arenaNames = new ArrayList<String>();
- //public ArrayList<String> lobbyNames = new ArrayList<String>();
- //public ArrayList<Location> savedLocations = new ArrayList<Location>();
- public HashMap<String, Location> lobbysList = new HashMap<String, Location>();
- public Location loc;
- private boolean notArena = false; //Returns true if player entered a correct arena name.
- private int game;//Value of array position. Set to -1 for no game. Set to the slot of selected lobby in lobbyNames. Ex: /hnsjoin hi. If hi is first lobbyNames slot, then games is 0.
- //private HnS bsc = new HnS();
- public int getGame()
- {
- return game;
- }
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args)
- {
- Player player;
- player = (Player) sender;
- String playerName = player.getName();
- if(cmd.getName().equalsIgnoreCase("hnsstart"))
- {
- if(readyPlayers.size() >= getConfig().getInt("options.min_players"))
- {
- for(int i = 1; i <= arenaNames.size(); i++)
- {
- if(arenaNames.get(i) == args[0])
- {
- game = i;
- }
- }
- for(String current : readyPlayers)
- {//loop though the readyPlayers
- getServer().getPlayer(current).teleport(lobbysList.get(loc));//teleport the players
- }
- start0.Start();
- }
- else{
- sender.sendMessage("Not enough players ready to start the game!");
- return true;
- }
- }
- if(cmd.getName().equalsIgnoreCase("hnscreatelobby"))
- {
- if(args.length == 0)
- {
- player.sendMessage(ChatColor.RED + "too few arguments. add a lobby name!");
- }
- else if(args.length == 1)
- {
- String lobbyName = args[0];
- if(lobbysList.containsKey(lobbyName))
- {
- lobbysList.remove(lobbyName);
- player.sendMessage(ChatColor.RED + "lobby already exist!");
- }
- else{
- this.loc = player.getLocation();
- lobbysList.put(lobbyName, loc);
- //lobbyNames.add(lobbyName);
- //savedLocations.add(loc);
- player.sendMessage(ChatColor.GREEN + "lobby successfully created!");
- }
- }
- }
- if(cmd.getName().equalsIgnoreCase("hnsjoin"))
- {
- if(args.length == 0)
- {
- player.sendMessage(ChatColor.RED + "add a lobby name to join!");
- }
- else if(args.length == 1)
- {
- String lobbyName = args[0];
- if(lobbysList.containsKey(lobbyName))
- {
- if(lobbysList.containsValue(this.loc))
- {
- player.teleport(this.loc);
- }
- }
- }
- }
- return true;
- }
- ////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ///////////////////////////////////////////////////////////////////////////////////////////////////////////
- //////////////////////////////////////////////////////////////////////////////////////////////////////////
- // private HnSCommands commands;
- Logger log = Logger.getLogger("Minecraft");
- public void onEnable(){
- log.info("[MuDucks HnS] Plugin Enabled!");
- File file = new File(getDataFolder() + File.separator + "config.yml");
- if(!file.exists()){
- this.getLogger().info("[MuDucks HnS] Generating config.yml...");
- this.getConfig().addDefault("options.min_players",1);
- this.getConfig().options().copyDefaults(true);
- this.saveConfig();
- }
- // getCommand("basic").setExecutor(commands);
- PluginManager pm = Bukkit.getServer().getPluginManager();
- //pm.registerEvents(new HnSCommands(this), this);
- pm.registerEvents(new HnSStart(), this);
- }
- public void onDisable(){
- log.info("[MuDucks HnS] Plugin Disabled!");
- }
- }
Add Comment
Please, Sign In to add comment