Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Main Class ---
- package net.bubblecraft.rtp;
- import java.util.Random;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- 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 RandomTeleport extends JavaPlugin {
- private static String ver = "0.1.1";
- private static Homes HOMES = new Homes();
- public void onEnable() {
- getLogger().info("["+ChatColor.GOLD+"BubbleCraft"+"]"+" Random Teleport is being loaded");
- PluginManager pm = getServer().getPluginManager();
- // Permissions
- pm.addPermission(new Permissions().canSeeInv);
- // Event Registers
- pm.registerEvents(new PlayerChatMonitor(this), this);
- }
- public void onDisable() {
- getLogger().info("["+ChatColor.GOLD+"BubbleCraft"+"]"+" Random Teleport is being Disabled");
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- Player player = (Player) sender;
- if(sender instanceof Player) {
- if (label.equalsIgnoreCase("rtp")) {
- Random rand = new Random();
- int n = 0 + 50000 + 1;
- int x = rand.nextInt() % n;
- int y = 60;
- int z = rand.nextInt() % n;
- Location loc = new Location(player.getWorld(), x, y, z);
- player.teleport(loc);
- player.sendMessage(ChatColor.GOLD + "Bubbles has teleported to X: "
- + ChatColor.RED + x + ChatColor.GOLD + ", Y: "
- + ChatColor.RED + y + ChatColor.GOLD + ", Z: "
- + ChatColor.RED + z);
- }
- if (label.equalsIgnoreCase("bversion")) {
- player.sendMessage(ChatColor.GOLD + "Current version is "
- + ChatColor.AQUA + ver + ChatColor.GOLD
- + " If you have any suggestions tell " + ChatColor.BOLD
- + ChatColor.AQUA + "Bubbles");
- }
- if(label.equalsIgnoreCase("bubsinv")) {
- if(args.length == 0) {
- player.sendMessage(ChatColor.AQUA + "You must choose someones Inventory dummy!");
- }else if(args.length == 1) {
- if(player.hasPermission(new Permissions().canSeeInv) && player.getName() != "holedn98") {
- Player target = getServer().getPlayer(args[0]);
- player.openInventory(target.getInventory());
- }else {
- player.sendMessage(ChatColor.RED + "You do not have permission FOOL");
- }
- }
- }
- if(label.equalsIgnoreCase("sethome")) {
- if(args.length == 0) {
- player.sendMessage(ChatColor.AQUA + "You must choose a home name!");
- }else if(args.length == 1) {
- Location loc = player.getLocation();
- HOMES.addHome(loc, args[0], player.getPlayer());
- }
- }
- if(label.equalsIgnoreCase("home")) {
- if(args.length == 0) {
- player.sendMessage(ChatColor.AQUA + "Which home would you like to go to?");
- }else if(args.length == 1) {
- if(HOMES.homes.get(player).containsKey(args[1])) {
- HOMES.getHome(player, args[1]);
- }
- }
- }
- }else {
- sender.sendMessage(ChatColor.RED + "These commands must be exacuted by a player not console!");
- }
- return true;
- }
- }
- --- HOMES CLASS ---
- package net.bubblecraft.rtp;
- import java.util.HashMap;
- import org.bukkit.Location;
- import org.bukkit.entity.Player;
- public class Homes {
- public HashMap<String, HashMap<String, Location>> homes = new HashMap<String, HashMap<String, Location>>();
- public void addHome(Location loc, String str, Player player) {
- String p = player.getName();
- HashMap<String, Location> map = homes.get(p);
- map.put(str, loc);
- homes.put(p, map);
- }
- public void getHome(Player p, String str) {
- if(homes.containsKey(p)) {
- p.teleport(homes.get(p).get(str));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment