Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package event.main;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Location;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.block.Block;
- import org.bukkit.block.Sign;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.ConfigurationSection;
- 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.block.SignChangeEvent;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Event extends JavaPlugin implements Listener {
- @Override
- public void onEnable(){
- getLogger().info("Scoreboard plugin has been Enabled");
- this.getConfig();
- this.getServer().getPluginManager().registerEvents( this, this );
- }
- @Override
- public void onDisable(){
- getLogger().info("Scoreboard plugin has been Disabled");
- this.saveConfig();
- }
- @EventHandler
- public void onSignChange(SignChangeEvent event) {
- Player player = event.getPlayer();
- String[] lines = event.getLines();
- if(player.hasPermission("event.sign.join")) {
- if(event.getLine(0).contains("[join]")) {
- if(!lines[1].isEmpty()) {
- event.setLine(0, "§2[Join]");
- player.sendMessage(ChatColor.GREEN + "Join sign created!");
- }else{
- player.sendMessage(ChatColor.RED + "Please set a valid arena name on line 2");
- event.setCancelled(true);
- }
- }
- }
- }
- @EventHandler
- public void onPlayerInteract(PlayerInteractEvent event) {
- Player player = event.getPlayer();
- Block block = event.getClickedBlock();
- Action action = event.getAction();
- if(action == Action.RIGHT_CLICK_BLOCK) {
- if(((block.getType() == Material.SIGN)
- || (block.getType() == Material.SIGN_POST)
- || (block.getType() == Material.WALL_SIGN)
- )){
- Sign sign = (Sign) block.getState();
- String textFromSign = sign.getLine(1);
- ConfigurationSection section = this.getConfig().getConfigurationSection("root.arenor");
- if(sign.getLine(0).contains("[Join]")) {
- if(section.contains(textFromSign)) {
- Bukkit.dispatchCommand(player, "arena" + sign.getLine(1));
- //String world = section.getString("world");
- // double x = section.getDouble( "x" );
- // double y = section.getDouble( "y" );
- // double z = section.getDouble( "z" );
- //player.sendMessage(ChatColor.BLUE + wCoord);
- //player.teleport( new Location( this.getServer().getWorld( world ), x, y, z ) );
- }else{
- player.sendMessage(ChatColor.RED + "That arena does not exist");
- }
- }
- }
- }
- }
- public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
- {
- if (!(sender instanceof Player) )
- {
- sender.sendMessage("Player command only");
- return false;
- }
- Player player = (Player)sender;
- // setlobby
- if( commandLabel.equalsIgnoreCase( "setlobby" ) )
- if(sender.hasPermission("event.setlobby") ) {
- if(args.length == 1) {
- String world = player.getLocation().getWorld().getName();
- double x = player.getLocation().getX();
- double y = player.getLocation().getY();
- double z = player.getLocation().getZ();
- this.getConfig().set("root.lobbies." + args[0] + "-lobby.world", world);
- this.getConfig().set("root.lobbies." + args[0] + "-lobby.x", x);
- this.getConfig().set("root.lobbies." + args[0] + "-lobby.y", y);
- this.getConfig().set("root.lobbies." + args[0] + "-lobby.z", z);
- this.saveConfig();
- player.sendMessage(ChatColor.GOLD + "Lobby "+ ChatColor.RED + args[0] + ChatColor.GOLD + " set!");
- }
- if(args.length == 0) {
- player.sendMessage(ChatColor.RED + "Usage:" + ChatColor.GOLD + "/setlobby " + ChatColor.RED + " <Name>");
- }
- }else{
- player.sendMessage(ChatColor.RED + "You dont have permission");
- }
- // setarena
- if( commandLabel.equalsIgnoreCase( "setarena" ) )
- if(sender.hasPermission("event.setarena") ) {
- if(args.length == 1) {
- String world = player.getLocation().getWorld().getName();
- double x = player.getLocation().getX();
- double y = player.getLocation().getY();
- double z = player.getLocation().getZ();
- this.getConfig().set("root.arenor." + args[0] + ".world", world);
- this.getConfig().set("root.arenor." + args[0] + ".x", x);
- this.getConfig().set("root.arenor." + args[0] + ".y", y);
- this.getConfig().set("root.arenor." + args[0] + ".z", z);
- this.saveConfig();
- player.sendMessage(ChatColor.GOLD + "Arena "+ ChatColor.RED + args[0] + ChatColor.GOLD + " set!");
- }
- if(args.length == 0) {
- player.sendMessage(ChatColor.RED + "Usage:" + ChatColor.GOLD + "/setarena " + ChatColor.RED + " <Name>");
- }
- }else{
- player.sendMessage(ChatColor.RED + "You dont have permission");
- }
- // arena
- ConfigurationSection section = this.getConfig().getConfigurationSection("root.arenor");
- String arena = args[0];
- if( commandLabel.equalsIgnoreCase( "arena" ) )
- if(args.length == 1) {
- if(section.contains(arena)) {
- String worldName = section.getString("world");
- World world = this.getServer().getWorld(worldName);
- double x = this.getConfig().getDouble("x");
- double y = this.getConfig().getDouble("y");
- double z = this.getConfig().getDouble("z");
- Location loc = new Location(world, x, y, z);
- player.teleport(loc);
- player.sendMessage(ChatColor.GOLD + "Teleported to: " + ChatColor.RED + args[0]);
- }else{
- player.sendMessage(ChatColor.RED + "That arena does not exist!");
- }
- }else{
- player.sendMessage(ChatColor.RED + "Usage:" + ChatColor.GOLD + "/arena " + ChatColor.RED + " <Name>");
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment