Chunks

Discussion in 'Plugin Development' started by PHILLIPS_71, Jul 21, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    newboyhun

    PHILLIPS_71
    getConfig().set(chunk.getX()+";"+chunk.getZ(),"");
     
  2. Offline

    PHILLIPS_71

    newboyhun
    Okay, the config is not working at all, do i need to add stuff into my onEnable and onDisable? because the config file is not generating.
     
  3. Offline

    PHILLIPS_71

    newboyhun
    Okay this is what i have i think the issue was that i already am using a config file here is the code encase i'm wrong.

    Code:
        Map<String, Integer[]> oldChunk = new HashMap<String, Integer[]>();
     
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
     
            if (sender instanceof Player) {
                Player player = (Player) sender;
     
                if ((commandLabel.equalsIgnoreCase("chunk") && player.isOp())) {   
     
                    if (args.length == 0) {
                        player.sendMessage(ChatColor.RED + "Chunk added");
                        org.bukkit.Chunk chunk = player.getLocation().getChunk();
                        oldChunk.put(player.getName(), new Integer[] {chunk.getX(), chunk.getZ()});
                        return true;
                    }
                }
            }
            return false;
        }
     
        @EventHandler
        public void onPlayerMove(PlayerMoveEvent e) {
            Player player = e.getPlayer();
            org.bukkit.Chunk chunk = player.getLocation().getChunk();
     
            Integer[] old = oldChunk.get(player.getName());
            if(old == null || (old[0] == chunk.getX() && old[1] == chunk.getZ()))
                return;
     
            String chunkName = getConfig().getString(chunk.getX() + ";" + chunk.getZ());
            if(chunkName != null)
                player.sendMessage("You entered");
            else
                player.sendMessage("You're entering no man's land!");
            oldChunk.put(player.getName(), new Integer[] {chunk.getX(), chunk.getZ()});
        }
    }
     
Thread Status:
Not open for further replies.

Share This Page