Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.brinedev.vip;
- import org.bukkit.Bukkit;
- import org.bukkit.Location;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.java.JavaPlugin;
- public class VIP extends JavaPlugin
- {
- public void onEnable()
- {
- saveDefaultConfig();
- }
- public String serializeLocation(Location l) {
- String s = "";
- s += "@w;" + l.getWorld().getName();
- s += ":@x;" + l.getBlockX();
- s += ":@y;" + l.getBlockY();
- s += ":@z;" + l.getBlockZ();
- s += ":@p;" + l.getPitch();
- s += ":@ya;" + l.getYaw();
- return s;
- }
- public Location deserializeLocation(String s) {
- try {
- Location l = new Location(Bukkit.getWorlds().get(0), 0, 0, 0);
- String[] att = s.split(":");
- for(String attribute : att) {
- String[] split = attribute.split(";");
- if(split[0].equalsIgnoreCase("@w"))
- l.setWorld(Bukkit.getWorld(split[1]));
- if(split[0].equalsIgnoreCase("@x"))
- l.setX(Double.parseDouble(split[1]));
- if(split[0].equalsIgnoreCase("@y"))
- l.setY(Double.parseDouble(split[1]));
- if(split[0].equalsIgnoreCase("@z"))
- l.setZ(Double.parseDouble(split[1]));
- if(split[0].equalsIgnoreCase("@p"))
- l.setPitch(Float.parseFloat(split[1]));
- if(split[0].equalsIgnoreCase("@ya"))
- l.setYaw(Float.parseFloat(split[1]));
- }
- return l;
- } catch (Exception e) {
- return null;
- }
- }
- public void onDisable() {
- }
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
- if ((sender instanceof Player)==false) {
- sender.sendMessage("§cApenas players!");
- return true;
- }
- Player p = (Player)sender;
- if (cmd.getName().equalsIgnoreCase("setvip")) {
- if (!p.hasPermission("vip.setar")) {
- sender.sendMessage("§cVoce nao tem permissao!");
- return true;
- }
- getConfig().set("LugarVIP", serializeLocation(p.getLocation().clone()));
- saveConfig();
- sender.sendMessage("§aLugar VIP setado!");
- return false;
- } else if (cmd.getName().equalsIgnoreCase("vip")) {
- if (!p.hasPermission("vip.ir")) {
- sender.sendMessage("§cVoce nao tem permissao!");
- return true;
- }
- if (!getConfig().contains("LugarVIP")) {
- sender.sendMessage("§cLocal VIP nao setado, chame um admin!");
- return false;
- }
- if (getConfig().getString("LugarVIP").equalsIgnoreCase("")) {
- sender.sendMessage("§cLocal VIP nao setado, chame um admin!");
- return false;
- }
- if (deserializeLocation(getConfig().getString("LugarVIP"))==null) {
- sender.sendMessage("§cLocal VIP nao setado, chame um admin!");
- return false;
- }
- p.teleport(deserializeLocation(getConfig().getString("LugarVIP")));
- p.sendMessage(getConfig().getString("Mensagem").replace("&", "§"));
- return false;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment