O3Bubbles09

Untitled

Dec 19th, 2013
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.21 KB | None | 0 0
  1. --- Main Class ---
  2. package net.bubblecraft.rtp;
  3.  
  4. import java.util.Random;
  5.  
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Location;
  8. import org.bukkit.command.Command;
  9. import org.bukkit.command.CommandSender;
  10. import org.bukkit.entity.Player;
  11. import org.bukkit.plugin.PluginManager;
  12. import org.bukkit.plugin.java.JavaPlugin;
  13.  
  14. public class RandomTeleport extends JavaPlugin {
  15.     private static String ver = "0.1.1";
  16.     private static Homes HOMES = new Homes();
  17.    
  18.     public void onEnable() {
  19.         getLogger().info("["+ChatColor.GOLD+"BubbleCraft"+"]"+" Random Teleport is being loaded");
  20.         PluginManager pm = getServer().getPluginManager();
  21.        
  22.         // Permissions
  23.         pm.addPermission(new Permissions().canSeeInv);
  24.        
  25.         // Event Registers
  26.         pm.registerEvents(new PlayerChatMonitor(this), this);
  27.     }
  28.  
  29.     public void onDisable() {
  30.         getLogger().info("["+ChatColor.GOLD+"BubbleCraft"+"]"+" Random Teleport is being Disabled");
  31.     }
  32.  
  33.     public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
  34.         Player player = (Player) sender;
  35.  
  36.         if(sender instanceof Player) {
  37.               if (label.equalsIgnoreCase("rtp")) {
  38.                     Random rand = new Random();
  39.  
  40.                     int n = 0 + 50000 + 1;
  41.                     int x = rand.nextInt() % n;
  42.                     int y = 60;
  43.                     int z = rand.nextInt() % n;
  44.  
  45.                     Location loc = new Location(player.getWorld(), x, y, z);
  46.                     player.teleport(loc);
  47.                     player.sendMessage(ChatColor.GOLD + "Bubbles has teleported to X: "
  48.                             + ChatColor.RED + x + ChatColor.GOLD + ", Y: "
  49.                             + ChatColor.RED + y + ChatColor.GOLD + ", Z: "
  50.                             + ChatColor.RED + z);
  51.                 }
  52.  
  53.                 if (label.equalsIgnoreCase("bversion")) {
  54.                     player.sendMessage(ChatColor.GOLD + "Current version is "
  55.                             + ChatColor.AQUA + ver + ChatColor.GOLD
  56.                             + " If you have any suggestions tell " + ChatColor.BOLD
  57.                             + ChatColor.AQUA + "Bubbles");
  58.                 }
  59.                
  60.                 if(label.equalsIgnoreCase("bubsinv")) {
  61.                     if(args.length == 0) {
  62.                         player.sendMessage(ChatColor.AQUA + "You must choose someones Inventory dummy!");
  63.                     }else if(args.length == 1) {
  64.                         if(player.hasPermission(new Permissions().canSeeInv) && player.getName() != "holedn98") {
  65.                             Player target = getServer().getPlayer(args[0]);
  66.                            
  67.                             player.openInventory(target.getInventory());
  68.                         }else {
  69.                             player.sendMessage(ChatColor.RED + "You do not have permission FOOL");
  70.                         }
  71.                     }
  72.                 }
  73.                
  74.                 if(label.equalsIgnoreCase("sethome")) {
  75.                     if(args.length == 0) {
  76.                         player.sendMessage(ChatColor.AQUA + "You must choose a home name!");
  77.                     }else if(args.length == 1) {
  78.                         Location loc = player.getLocation();
  79.                        
  80.                         HOMES.addHome(loc, args[0], player.getPlayer());
  81.                     }
  82.                 }
  83.                
  84.                 if(label.equalsIgnoreCase("home")) {
  85.                     if(args.length == 0) {
  86.                         player.sendMessage(ChatColor.AQUA + "Which home would you like to go to?");
  87.                     }else if(args.length == 1) {
  88.                         if(HOMES.homes.get(player).containsKey(args[1])) {
  89.                             HOMES.getHome(player, args[1]);
  90.                         }
  91.                     }
  92.                 }
  93.         }else {
  94.             sender.sendMessage(ChatColor.RED + "These commands must be exacuted by a player not console!");
  95.         }
  96.  
  97.         return true;
  98.     }
  99. }
  100.  
  101.  
  102. --- HOMES CLASS ---
  103.  
  104. package net.bubblecraft.rtp;
  105.  
  106. import java.util.HashMap;
  107.  
  108. import org.bukkit.Location;
  109. import org.bukkit.entity.Player;
  110.  
  111. public class Homes {
  112.    
  113.     public HashMap<String, HashMap<String, Location>> homes = new HashMap<String, HashMap<String, Location>>();
  114.    
  115.     public void addHome(Location loc, String str, Player player) {
  116.         String p = player.getName();
  117.         HashMap<String, Location> map = homes.get(p);
  118.         map.put(str, loc);
  119.        
  120.         homes.put(p, map);
  121.     }
  122.    
  123.     public void getHome(Player p, String str) {
  124.         if(homes.containsKey(p)) {
  125.             p.teleport(homes.get(p).get(str));
  126.         }
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment