Faction (Level)

Discussion in 'Plugin Requests' started by MacMasterMac, May 28, 2016.

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

    MacMasterMac

    It's like Skyblock, you do /is level (name) and you see how many levels your island has, now try this:
    The piece of land you've claimed counts the amount of blocks and then looks the $ value from the block
    So you can do something like /f top so you see which faction has a lot of blocks or special blocks that is worth a lot. Because you see a lot of videos on youtube like "RICHEST FACTION FROM THE SERVER TOUR" this could be helpful
     
  2. Offline

    jokie666

    I think it is not too hard to implement only the block counting would be resource heavy from the server. Also you would need a list which holds all the prices of the blocks
     
  3. Offline

    I Al Istannen

    @jokie666
    A chunk snapshot is apparently ThreadSafe. So you could get one and then take your time computing the whole thing async. Just a shot in the dark, but it might work. Would certainly be better than getting all blocks on the Main thread.
     
  4. Offline

    jokie666

    @I Al Istannen
    As far as I know the claim radius can be changed in factions and doesn't have to be the same size as a chunk
    (correct me if I'm wrong, it's been a while since I used factions)
     
  5. Offline

    I Al Istannen

    @jokie666
    Well, still more than my "never used it". But that isn't a problem, is it. Just also store the boundaries in two location variables and be good. Just snapshot a bit more chunks if you need them. I haven't tried it though, just threw an idea in.
     
  6. Offline

    jokie666

    @I Al Istannen @MacMasterMac
    I like the idea of calculating in a seperate thread, wouldn't be too hard.
    Though I am currently stuck in getting the claimed chunks of a faction, it sounds simple but I can't find it in the factions API. Looping through all the chunks of a server and check if they belong to a faction doesn't seem a good idea :p
     
  7. Offline

    I Al Istannen

    @jokie666
    Well, it certainly isn't. But thankfully it is not what I meant :p
    You said that factions doesn't need to be in a chunk, so I said you should just snapshot one more chunk than needed (i.e. the one where half is in a faction). I would snapshot only a few of them and then add more on demand, as the snapshot is a full copy of many properties of a block. Might get memory intense otherwise.

    Never worked with factions, so I sadly can't help with the API.
     
  8. Offline

    jokie666

    @I Al Istannen
    Thankfully when I was fully awake I read your comment again and I know you did not mean that :p

    @MacMasterMac
    I have the plugin almost done, there is a small asynchronous issue I am working out.
     
  9. Offline

    I Al Istannen

    @jokie666
    No problem! What developer is not sleep deprived :p
    If you have any questions, you think I may be able to answer, feel free to send me a pm or post them here. Concurrent threads are just a pain to work with ;)

    Good luck with the plugin though!
     
    jokie666 and timtower like this.
  10. Offline

    jokie666

    @I Al Istannen
    The problem is that the methods getBlockData and getBlockTypeId for the Object ChunkSnapshot are deprecated.
    I am looking for a solution to grab each block and check which type it is. Preferably not in the main thread because it would hang the server
     
  11. Offline

    I Al Istannen

    @jokie666
    You know what? I would ignore it and use it anyways. Afaik there is no alternative. Material#getId() gives you the numerical id for each material.
     
  12. Offline

    jokie666

    @I Al Istannen
    I could just ignore it with the problem that I can't feature proof the plugin or I could not use a ChunkSnapshot and just take the normal chunk, scan the blocks and take every block that way. The only thing is that I get an asynchronous error because it says I am trying to edit an entity while requesting the material which shouldn't be an entity.

    I know a lot of things in the bukkit api aren't thread safe, but since I am only taking information and not editting it this shouldn't be a problem?
     
    Last edited: Jun 2, 2016
  13. Offline

    I Al Istannen

    @jokie666
    You would guess that. In fact, I made a thread about it. In there is probably the solution for your problem, but I still don't know wether it should work.

    Personally, I would sacrifice the "feature proof"ity of the plugin and use ChunkSnpashots methods. You can still make an async block get if the methods will ever be removed. I just think that it is the better alternative.
    Concurrent threads can have lots and lots of problems, which just occur in very specific conditions (e.g. race conditions mostly met, but not every time). You don't know if the get is threadsafe or if it does some not-treadsafe actions in order to get the block.
    To know that, you would need to read the whole Craftbukkit and NMS code related to it and it could also change in the future.
     
    jokie666 likes this.
  14. Offline

    jokie666

    @I Al Istannen
    Well apparantly those 2 methods don't work as intended anymore since I get the most weird id's back (-22o1???)
    Your hack would work but I think it only slips past the security mechanisms.

    @MacMasterMac
    I like the idea but I would become so power heavy to have it work without corrupting the world that it wouldn't be worth the effort and the time waiting to calculate all the things.
     
  15. Offline

    I Al Istannen

    @jokie666
    I will toy around a bit. What version are you using?

    EDIT: Later... :p

    EDIT 2: I send you a PM.
     
    Last edited: Jun 4, 2016
  16. Offline

    jokie666

    @I Al Istannen My code merged wrong which resulted in a weird id returning. Thank you for helping without you I would have given up :p

    @MacMasterMac I have the plugin done.

    The plugin is still pretty heavy for servers because all the ChunkSnapshots needs to be taken from the main thread.
    It took me 1 minute and 56 seconds to calculate 1129 chunks. That is an average of 0.1 second for each chunk.
    As you see the time to calculate it all depends on how many claims there are on your server. I would not give the permission to everybody because it could generate some lagg.

    On first launch the plugin will create a config where you can set all the prices for placeable items. These are 0 on default.

    the plugin has 2 commands:
    /factiontop OR /ft : this will start the calculation
    /factiontop reload OR /ft reload : this will reload the config file.

    Permissions are:
    factiontop.use - You'll need this for the /factiontop command
    factiontop.admin - You'll need this for the /factiontop reload command

    FactionTop.jar: https://www.dropbox.com/s/c8idjqgqmy7pnwb/FactionTop.jar?dl=0

    If there are any bugs, send me a message please :)
     
    I Al Istannen likes this.
  17. Offline

    I Al Istannen

    @jokie666
    Great you did it! Well done :)
    I can't look at it in the next few days, as a lightning fried our router, but i will surely look at it after that! Sounds great!

    Have a nice day and good luck developing :p
     
    jokie666 likes this.
  18. Offline

    MacMasterMac

    Perfect! Sorry for the very late reaction. Thank you for your hard work. So cool people can make this! :)
     
    Last edited: Jun 20, 2016
Thread Status:
Not open for further replies.

Share This Page