Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onInteract(PlayerInteractEvent event){
- if(event.getAction() != Action.PHYSICAL)
- return;
- Player player = event.getPlayer();
- String playername = player.getName();
- player.sendMessage(event.getClickedBlock().getType().toString() + "");
- if(parkourMode.containsKey(playername) && checkpoints.containsKey(playername) &&event.getClickedBlock().getType() == Material.STONE_PLATE){
- try{
- List<String> data = checkpoints.get(playername);
- String region = data.get(0);
- File file = new File(plugin.getDataFolder() + "/courses/" + region + ".yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- for(String key : cfg.getConfigurationSection("checkpoints").getKeys(false)){
- int x = cfg.getInt("checkpoints." + key + ".x");
- int y = cfg.getInt("checkpoints." + key + ".y");
- int z = cfg.getInt("checkpoints." + key + ".z");
- World world = Bukkit.getWorld(cfg.getString("name"));
- Location loc = new Location(world, x, y, z);
- if(loc.equals(event.getClickedBlock().getLocation())){
- data.set(1, key);
- checkpoints.put(playername, data);
- break;
- }
- }
- }catch(Exception e){
- e.printStackTrace();
- }
- }else if(parkourMode.containsKey(playername) && event.getClickedBlock().getType() == Material.IRON_PLATE){
- Location loc = event.getClickedBlock().getLocation();
- for(CuboidSelection sel : selections){
- if(sel.contains(loc)){
- List<String> data = null;
- for(String reg : regions){
- try{
- File file = new File(plugin.getDataFolder() + "/courses/" + reg + ".yml");
- FileConfiguration cfg = YamlConfiguration.loadConfiguration(file);
- World world = Bukkit.getWorld(cfg.getString("selection.world"));
- int x1 = cfg.getInt("selection.pos1.x");
- int y1 = cfg.getInt("selection.pos1.y");
- int z1 = cfg.getInt("selection.pos1.z");
- int x2 = cfg.getInt("selection.pos2.x");
- int y2 = cfg.getInt("selection.pos2.y");
- int z2 = cfg.getInt("selection.pos2.z");
- Location pos1 = new Location(world, x1, y1, z1);
- Location pos2 = new Location(world, x2, y2, z2);
- if(sel.getMinimumPoint().equals(pos1) && sel.getMaximumPoint().equals(pos2)){
- data.set(0, cfg.getString("name"));
- data.set(1, "start");
- break;
- }
- }catch(Exception e){
- }
- }
- if(data != null){
- checkpoints.put(playername, data);
- break;
- }
- }
- }
- }else if(parkourMode.containsKey(playername) && checkpoints.containsKey(playername) && event.getClickedBlock().getType() == Material.GOLD_PLATE){
- List<String> data = checkpoints.get(playername);
- String region = data.get(0);
- player.sendMessage(ChatColor.DARK_GREEN + "[Parkour] " + ChatColor.GREEN + region + "has been completed!");
- parkourMode.remove(playername);
- checkpoints.remove(playername);
- Double x = LSMain.configs.getParkourConfig().getDouble("startpoint.x");
- Double y = LSMain.configs.getParkourConfig().getDouble("startpoint.y");
- Double z = LSMain.configs.getParkourConfig().getDouble("startpoint.z");
- Location loc = new Location(player.getWorld(), x, y, z);
- player.teleport(loc);
- }else{
- player.sendMessage(ChatColor.GREEN + "doesnt work");
- player.sendMessage(ChatColor.GREEN + "" + parkourMode.get(playername) + "");
- player.sendMessage(ChatColor.GREEN + playername + "");
- printState(player);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement