Guest User

Untitled

a guest
Dec 16th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 5.24 KB | None | 0 0
  1. /* Mudsquisher and OwenHertz's Hide and Seek plugin
  2.  * Plugin: MudDucks HnS
  3.  * Class created on: October 3, 2012
  4.  * Version: 0.1
  5.  */
  6. package me.speeddcuskandmudsquisher.plugins.mudduckshideandseek;
  7.  
  8. import java.io.File;
  9. import java.util.ArrayList;
  10. import java.util.HashMap;
  11. import java.util.List;
  12. import java.util.logging.Logger;
  13.  
  14. import org.bukkit.Bukkit;
  15. import org.bukkit.ChatColor;
  16. import org.bukkit.GameMode;
  17. import org.bukkit.Location;
  18. import org.bukkit.block.Block;
  19. import org.bukkit.command.Command;
  20. import org.bukkit.command.CommandSender;
  21. import org.bukkit.entity.Player;
  22. import org.bukkit.plugin.PluginManager;
  23. import org.bukkit.plugin.java.JavaPlugin;
  24.  
  25. public class HnS extends JavaPlugin{
  26.     private HnSStart start0;
  27.     private HnS plugin;
  28.  
  29.  
  30.     public ArrayList<String> readyPlayers = new ArrayList<String>();
  31.     // public static List<String> Players = new ArrayList<String>();
  32.     public ArrayList<String> arenaNames = new ArrayList<String>();
  33.     //public ArrayList<String> lobbyNames = new ArrayList<String>();
  34.     //public ArrayList<Location> savedLocations = new ArrayList<Location>();
  35.         public HashMap<String, Location> lobbysList = new HashMap<String, Location>();
  36.     public Location loc;
  37.     private boolean notArena = false; //Returns true if player entered a correct arena name.
  38.     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.
  39.    
  40.     //private HnS bsc = new HnS();
  41.    
  42.     public int getGame()
  43.         {
  44.         return game;
  45.     }
  46.    
  47.     @Override
  48.     public boolean onCommand(CommandSender sender, Command cmd, String labe, String[] args)
  49.     {    
  50.         Player player;
  51.         player = (Player) sender;
  52.         String playerName = player.getName();
  53.        
  54.         if(cmd.getName().equalsIgnoreCase("hnsstart"))
  55.         {
  56.             if(readyPlayers.size() >= getConfig().getInt("options.min_players"))
  57.                         {          
  58.                 for(int i = 1; i <= arenaNames.size(); i++)
  59.                                 {
  60.                     if(arenaNames.get(i) == args[0])
  61.                                         {
  62.                         game = i;
  63.                     }
  64.                 }
  65.                 for(String current : readyPlayers)
  66.                                 {//loop though the readyPlayers
  67.                     getServer().getPlayer(current).teleport(lobbysList.get(loc));//teleport the players
  68.                 }
  69.                 start0.Start();
  70.             }
  71.             else{                  
  72.                 sender.sendMessage("Not enough players ready to start the game!");
  73.                 return true;
  74.             }
  75.         }
  76.  
  77.  
  78.         if(cmd.getName().equalsIgnoreCase("hnscreatelobby"))
  79.         {      
  80.  
  81.             if(args.length == 0)
  82.             {
  83.                 player.sendMessage(ChatColor.RED + "too few arguments. add a lobby name!");
  84.  
  85.             }
  86.             else if(args.length == 1)
  87.             {
  88.  
  89.                 String lobbyName = args[0];
  90.                 if(lobbysList.containsKey(lobbyName))
  91.                 {                              
  92.                     lobbysList.remove(lobbyName);
  93.                     player.sendMessage(ChatColor.RED + "lobby already exist!");
  94.  
  95.                 }
  96.                 else{
  97.                                    
  98.                                     this.loc = player.getLocation();
  99.                     lobbysList.put(lobbyName, loc);
  100.                     //lobbyNames.add(lobbyName);
  101.                    
  102.                     //savedLocations.add(loc);
  103.                     player.sendMessage(ChatColor.GREEN + "lobby successfully created!");
  104.                 }
  105.                 }          
  106.  
  107.         }
  108.  
  109.         if(cmd.getName().equalsIgnoreCase("hnsjoin"))
  110.         {
  111.                    
  112.                     if(args.length == 0)
  113.                     {
  114.                        
  115.                         player.sendMessage(ChatColor.RED + "add a lobby name to join!");
  116.                        
  117.                     }
  118.                     else if(args.length == 1)
  119.                     {
  120.                        
  121.                         String lobbyName = args[0];
  122.                        
  123.                         if(lobbysList.containsKey(lobbyName))
  124.                         {
  125.                            
  126.                             if(lobbysList.containsValue(this.loc))
  127.                             {
  128.                             player.teleport(this.loc);
  129.                             }
  130.                            
  131.                         }
  132.                        
  133.                        
  134.                     }
  135.         }
  136.         return true;
  137.     }
  138.  
  139.  
  140.    
  141.    
  142.    
  143.     ////////////////////////////////////////////////////////////////////////////////////////////////////////////
  144.     ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  145.     //////////////////////////////////////////////////////////////////////////////////////////////////////////
  146.    
  147. //  private HnSCommands commands;
  148.     Logger log = Logger.getLogger("Minecraft");
  149.    
  150.     public void onEnable(){
  151.         log.info("[MuDucks HnS] Plugin Enabled!");
  152.  
  153.         File file = new File(getDataFolder() + File.separator + "config.yml");
  154.         if(!file.exists()){
  155.             this.getLogger().info("[MuDucks HnS] Generating config.yml...");   
  156.             this.getConfig().addDefault("options.min_players",1);
  157.             this.getConfig().options().copyDefaults(true);
  158.             this.saveConfig();
  159.         }
  160.     //  getCommand("basic").setExecutor(commands);
  161.        
  162.         PluginManager pm = Bukkit.getServer().getPluginManager();        
  163.         //pm.registerEvents(new HnSCommands(this), this);      
  164.         pm.registerEvents(new HnSStart(), this);
  165.     }
  166.  
  167.     public void onDisable(){
  168.         log.info("[MuDucks HnS] Plugin Disabled!");
  169.     }
  170.  
  171. }
Add Comment
Please, Sign In to add comment