Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.relocatedgaming;
- import java.util.HashMap;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.EventPriority;
- import org.bukkit.event.Listener;
- import org.bukkit.event.player.PlayerRespawnEvent;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{ //Extending JavaPlugin so that Bukkit knows its the main class...
- private static Plugin plugin;
- public final HashMap<String, String> Jumpto = new HashMap<String, String>();
- public void onEnable() {
- plugin = this;
- registerEvents(this, new Vanish());
- registerEvents(this, new Chat());
- getCommand("vanish").setExecutor(new Vanish());
- getCommand("killme").setExecutor(new Chat());
- getCommand("Help").setExecutor(new CommandHelp());
- getCommand("Who").setExecutor(new Who());
- //This is where we register our events/commands
- }
- public void onDisable() {
- plugin = null;//To stop memory leaks
- }
- //Much easier then registering events in 10 different methods
- public static void registerEvents(org.bukkit.plugin.Plugin plugin, Listener... listeners) {
- for (Listener listener : listeners) {
- Bukkit.getServer().getPluginManager().registerEvents(listener, plugin);
- }
- }
- //To access the plugin variable from other classes
- public static Plugin getPlugin() {
- return plugin;
- }
- public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
- if (cmd.getName().equalsIgnoreCase("jumpto")) {
- if (sender.hasPermission("relocatedgaming.jumpto")) {
- Player p = (Player) sender;
- if (args.length == 0) {
- sender.sendMessage("/jumpto list - List who is allowed to jump to you.");
- sender.sendMessage("/jumpto clear - Clear all allowed names.");
- sender.sendMessage("/jumpto allow [name] - Allow player to jump to you.");
- sender.sendMessage("/jumpto remove [name] - Remove player from your list");
- sender.sendMessage("/jumpto [name] - Jump to players location");
- sender.sendMessage("/jumpto here - Saves this location to jump to again.");
- sender.sendMessage("/jumpto there - Jump to saved location.");
- sender.sendMessage("/jumpto up - Jump up to next surface.");
- return true;
- }
- if (args[0].equalsIgnoreCase("allow")) {
- if (args.length == 1) {
- sender.sendMessage("Allow who dumbass?");
- }
- if(args.length == 2) {
- Player target = getServer().getPlayer(args[1]);
- if (target == null) {
- sender.sendMessage("Player " + args[1] + " not found.");
- return false;
- }
- sendRequest(p, target);
- }
- return true;
- }
- if (args[0].equalsIgnoreCase("remove")) {
- }
- if (args[0].equalsIgnoreCase("list")) {
- }
- if (args[0].equalsIgnoreCase("up")) {
- sender.sendMessage("You have jumped up.");
- }
- else if (args[0].equalsIgnoreCase("here")) {
- Player target = (Player) sender;
- String uuid = target.getUniqueId().toString();
- sender.sendMessage("This location is saved as your jump point.");
- getConfig().set(uuid + "." + "jumpto.world", target.getLocation().getWorld().getName());
- getConfig().set(uuid + "." + "jumpto.x", target.getLocation().getX());
- getConfig().set(uuid + "." + "jumpto.y", target.getLocation().getY());
- getConfig().set(uuid + "." + "jumpto.z", target.getLocation().getZ());
- getConfig().set(uuid + "." + "jumpto.yaw", target.getLocation().getYaw());
- getConfig().set(uuid + "." + "jumpto.pitch", target.getLocation().getPitch());
- saveConfig();
- }
- else if (args[0].equalsIgnoreCase("there")) {
- Player target = (Player) sender;
- String uuid = target.getUniqueId().toString();
- sender.sendMessage("You have jumped to your saved location.");
- if (getConfig().getConfigurationSection(uuid) == null) {
- target.sendMessage(ChatColor.RED + "You have not set a jumpto location.");
- return true;
- }
- World w = Bukkit.getServer().getWorld(getConfig().getString(uuid + "." + "jumpto.world"));
- double x = getConfig().getDouble(uuid + "." + "jumpto.x");
- double y = getConfig().getDouble(uuid + "." + "jumpto.y");
- double z = getConfig().getDouble(uuid + "." + "jumpto.z");
- float yaw = getConfig().getInt(uuid + "." + "jumpto.yaw");
- float pitch = getConfig().getInt(uuid + "." + "jumpto.pitch");
- target.teleport(new Location(w, x, y, z, yaw, pitch));
- }
- else if (!(p == null)) {
- if (Jumpto.containsValue(p.getName())) { // started fucking up around here.
- Player Jumps = getServer().getPlayer(Jumpto.get(p.getName()));
- if (Jumpto.containsKey(Jumps)) {
- p.teleport(Jumps);
- p.sendMessage("You jumped to " + Jumps.getDisplayName());
- Jumps.sendMessage(sender.getName() + " jumped to your location");
- }
- else {
- sender.sendMessage(args[0] + " has not added you to their jump list.");
- }
- }
- }
- }
- }
- }
- public void sendRequest(Player sender, Player recipient) {
- sender.sendMessage(recipient.getDisplayName() + " is allowed to jump to you.");
- String allow = "";
- String remove = "";
- if (recipient.hasPermission("relocatedgaming.jumpto")) {
- allow = sender.getDisplayName() + " has added you to their jump list.";
- } else {
- allow = "";
- }
- if (recipient.hasPermission("relocatedgaming.jumpto")) {
- remove = "";
- } else {
- remove = "";
- }
- recipient.sendMessage(allow);
- Jumpto.put(recipient.getName(), sender.getName());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement