How would this work? Config & Worlds

Discussion in 'Plugin Development' started by xDeeKay, Sep 12, 2014.

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


    I have a config that looks like this:

        Owner: xdeekay
        - john
    PersonalWorlds.xdeekay is treated as the world name, and I only want the Owner and Members in the world "xdeekay" to be able to build there. I've tried ideas to no success, I was wondering if anyone could give me some light on this.
  2. Offline


    Could you show me what you've tried already? It should be as simple as
    public void onBreak(BlockBreakEvent event) {
        Player p = event.getPlayer();
        String playerName = p.getName();
        World world = event.getWorld();
        String worldName = world.getName();
        FileConfiguration configObject = ...; // getConfig()
        if(configObject.contains("PersonalWorlds." + worldName) {
                return; // exit if we already know the player owns this world
            List<String> members = configObject.getStringList("PersonalWorlds." + worldName + ".Members"));
    if(!members.contains(playerName) event.setCancelled(true);
    Sorry for the formatting on that one line. I'm on my phone and it messed up. Basically do the same for BlockPlaceEvent.

    Also the Owner field is unnecessary if the world name is the player name. If not, you need to edit the code a bit.
    xDeeKay likes this.
  3. Offline


    Assist Thanks for that, I'll try this out. I literally have no code to show because I would write 1 line and realise it wasn't gonna work lol. As for the Owner field, it was there for when the world name wasn't the players name, so I needed to store who owned the world, I just forgot to remove it.
Thread Status:
Not open for further replies.

Share This Page