Source Code

I will not update this plugin more. This is the code I made, you can do whatever you want with it:

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin implements Listener{
	public void onEnable() {
		getConfig().options().copyDefaults(true);
		saveConfig();
		Bukkit.getServer().getPluginManager().registerEvents(this, this);
	}
	public void onDisable() {
		
	}
	public boolean onCommand(CommandSender sender, Command cmd, String cmdLabel, String[] args) {
		if(sender instanceof Player){
			Player player = (Player)sender;
			if(cmd.getName().equalsIgnoreCase("lobby") || cmd.getName().equalsIgnoreCase("LOBBY")){
				if(args.length == 0){
					if(getConfig().getString("x") == null || getConfig().getString("y") == null || getConfig().getString("z") == null || getConfig().getString("yaw") == null || getConfig().getString("pitch") == null) {
						sender.sendMessage(ChatColor.RED + "Lobby not found. Use /setlobby to set it.");
					}else {
						player.teleport(new Location(
							Bukkit.getServer().getWorld(getConfig().getString("world")),
							getConfig().getDouble("x"),
							getConfig().getDouble("y"),
							getConfig().getDouble("z"),
							getConfig().getInt("yaw"),
							getConfig().getInt("pitch")));
					}
				}
				if(args.length == 1){
					String lobby = args[0];
					if(getConfig().getString("x-" + lobby) == null || getConfig().getString("y-" + lobby) == null || getConfig().getString("z-" + lobby) == null || getConfig().getString("yaw-" + lobby) == null || getConfig().getString("pitch-" + lobby) == null) {
						sender.sendMessage(ChatColor.RED + "Lobby not found. Use /setlobby to set it.");
					}else {
						player.teleport(new Location(
							Bukkit.getServer().getWorld(getConfig().getString("world-" + lobby)),
							getConfig().getDouble("x-" + lobby),
							getConfig().getDouble("y-" + lobby),
							getConfig().getDouble("z-" + lobby),
							getConfig().getInt("yaw-" + lobby),
							getConfig().getInt("pitch-" + lobby)));
					}
				}
				
			}
			if(cmd.getName().equalsIgnoreCase("setlobby") || cmd.getName().equalsIgnoreCase("SETLOBBY")) {
				if(player.hasPermission("lobby.set") || player.isOp() == true){
					if(args.length == 0){
						getConfig().set("x", player.getLocation().getX());
						getConfig().set("y", player.getLocation().getY());
						getConfig().set("z", player.getLocation().getZ());
						getConfig().set("pitch", player.getLocation().getPitch());
						getConfig().set("yaw", player.getLocation().getYaw());
						getConfig().set("world", player.getWorld().getName());
						saveConfig();
						sender.sendMessage(ChatColor.GREEN + "Lobby set at " + player.getLocation().getX() + ", " + player.getLocation().getY() + ", " + player.getLocation().getZ() );
						if(getConfig().getString("TeleportOnJoin").equalsIgnoreCase("false")){
							sender.sendMessage(ChatColor.RED + "If you want that players teleport to the Lobby when join, set \"TeleportOnJoin: true\" in config.yml");
						}
					}
					if(args.length == 1){
						String lobby = args[0];
						getConfig().addDefault("Specifics", lobby);
						getConfig().set("x-" + lobby, player.getLocation().getX());
						getConfig().set("y-" + lobby, player.getLocation().getY());
						getConfig().set("z-" + lobby, player.getLocation().getZ());
						getConfig().set("pitch-" + lobby, player.getLocation().getPitch());
						getConfig().set("yaw-" + lobby, player.getLocation().getYaw());
						getConfig().set("world-" + lobby, player.getWorld().getName());
						saveConfig();
						sender.sendMessage(ChatColor.GREEN + "Lobby " + lobby + " set at " + player.getLocation().getX() + ", " + player.getLocation().getY() + ", " + player.getLocation().getZ() );
					}
				}
			
				else{
					sender.sendMessage(ChatColor.RED + "No permissions");
					}
			}
		}else{
			System.out.println("You must be a player!");
		}
		return false;
	}
	@EventHandler
	public void onPlayerJoin(PlayerJoinEvent event){
		Player player = event.getPlayer();
		if(getConfig().getString("TeleportOnJoin").equalsIgnoreCase("true")) {
			if(getConfig().getString("x") == null || getConfig().getString("y") == null || getConfig().getString("z") == null || getConfig().getString("yaw") == null || getConfig().getString("pitch") == null) {
				player.sendMessage(ChatColor.RED + "Lobby not found.");
			}else {
				player.teleport(new Location(
					Bukkit.getServer().getWorld(getConfig().getString("world")),
					getConfig().getDouble("x"),
					getConfig().getDouble("y"),
					getConfig().getDouble("z"),
					getConfig().getInt("yaw"),
					getConfig().getInt("pitch")));
			}
		}
	}	
	@EventHandler
	public void onSignClick(PlayerInteractEvent event) {
	Player player = event.getPlayer();
	Action action = event.getAction();
	Block clicked = event.getClickedBlock();
	if(action == Action.RIGHT_CLICK_BLOCK){
		if(clicked.getType() == Material.WALL_SIGN || clicked.getType() == Material.SIGN_POST || clicked.getType() == Material.SIGN) {
			Sign sign = (Sign) clicked.getState();
			String line = sign.getLine(0);
				if(line.equalsIgnoreCase(getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.AQUA + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.BLACK + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.BLUE + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.DARK_AQUA + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.DARK_BLUE + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.DARK_GRAY + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.DARK_GREEN + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.DARK_PURPLE + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.DARK_RED + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.LIGHT_PURPLE + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.GRAY + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.GREEN + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.RED + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.WHITE + getConfig().getString("signword")) || line.equalsIgnoreCase(ChatColor.YELLOW + getConfig().getString("signword"))){
					if(getConfig().contains("world") == true){
						player.teleport(new Location(
							Bukkit.getServer().getWorld(getConfig().getString("world")),
							getConfig().getDouble("x"),
							getConfig().getDouble("y"),
							getConfig().getDouble("z"),
							getConfig().getInt("yaw"),
							getConfig().getInt("pitch")));
					}else{
						player.sendMessage(ChatColor.RED + "Lobby not installed. Use \"/setlobby\" to install.");
					}
				}
			}
		}
	}
}

Comments

Posts Quoted:
Reply
Clear All Quotes