Solved WorldGuard track region creators

Discussion in 'Plugin Development' started by Colby l, May 27, 2014.

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

    Colby l

    I'm rewriting a WorldGuard plugin in which it tracks regions, and deletes them/removes the owner after they have been inactive for x amount of time. I'm trying to track the creator of the region, in case the owner is not set.

    The regions are stored as a Map of String and ProtectedRegion, in which ProtectedRegion stores most all of the data - besides the creator of the region.

    In theory, I would like to get the creator of the region if no owner is chosen, or have the owner of the region automatically set as the creator until another owner is assigned, that isn't the region creator.

  2. Offline


    Then add a getCreator() String object in your ProtectedRegion...?
  3. Offline

    Colby l

    But I won't know who to add, if I don't know who created the region.
  4. Offline


    Colby l well, I assume your owner will be represented by a player object, or an object created by passing a player or something... the simplest solution would be to parse the command used to create the region "/region create <region name> [Owner]" for example. Simply check to see if the args.length is more than 2, and if it is get the 3rd argument (args[2]), loop through your online players, or offline players depending on how flexible you want this, and find a player whos names contains the 3rd argument, and make that player the owner of the region. If there is no 3rd argument passed, simply cast your CommandSender:

    Player player = (Player) sender;

    and use them as your Owner.

    Basically you should never reach a point where you don't know who the owner is. If you do, thats just bad plugin design.
Thread Status:
Not open for further replies.

Share This Page