Breakable warp blocks for survival servers.

Discussion in 'Plugin Requests' started by GreenPls, Jun 26, 2016.

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

    GreenPls

    Plugin category: Survival/pvp

    Minecraft version: 1.7.10

    Suggested name: BlockWarps

    What I want: The issue i find with most factions servers is if you kill someone they can just instantly ( or in like 12 seconds) warp back to there base. I think this issue is why many factions servers are now hardcore factions with no warps and 3 hour death bans. well i have a different solution that still allows you to play after you get absolutely destroyed.

    For this plugin i would like a craftable block that when placed acts as a warp pad. When placed it will ask you to name your warp and to get back to it you will use /warp (itsname) like you normally would. But this block is breakable by anyone. So if you get raided the enemy can destroy your block and they essential win. You could walk back to base if you wanted but with no gear good luck.

    this way as soon as you lose your base instead of getting banned for 3 hours while others steal your stuff, you can now continue to play and start a new base right away to get prepared to get your revenge.

    Things to note: I don't use any protection plugins on my server so you don't have to worry about factions or something making the block invincible when it never should be. you should only be aloud 1 block per player ( this could be configurable though.)

    i know you cant make new blocks so you could use the jukebox and i can use a different plugin to make a custom recipe for it if you would like.

    Ideas for commands: /warp [warp name]
    /setwarp [name] (you need to be looking at block)
    no need for a command to remove warp bc destroying the block should remove it

    Ideas for permissions: player.canplace
    player.canwarp
    player.candestroy
    player.canPlaceAmount.2

    Config: How many warp blocks can a player own:
    WarpTime:
    How close can blocks be together:

    all config and permissions is optional. i would like it if you could work it in but if you cant thats ok. just the plain 1 block per person would be fine.

    When I'd like it by: ASAP but take you time
     
  2. Offline

    GreenPls

  3. Offline

    Tecno_Wizard

    @GreenPls, this is actually a very good idea. Reminds me a little of the COD tac insert. I did look up any existing plugins for this and while there is, it is missing a LOT of the dynamics you're looking for.

    I'm willing to take this. Should be fun. I'm going to build it with 1.10 as the target. If you have any issues with it I'll make the necessary changes to fix the problem you're having.

    Also, for the purpose of not making my life a living hell and keeping your sever from being filled to the brim with torches, I'm going to make it that these warps are broken when you log out. Is that okay or do you want to have them stay? If you do want them to stay I am happy to make them persist.

    How about Tactical Insertions instead of BlockWarps?
     
  4. Offline

    GreenPls


    Thanks! Tactical inserts works for me! i would like a option to have them stay for ever though( untill broken by a player). as without it it kinda defeats my intended use for it. I would be using it so other players could essentialy destroy your f home ( hopefully you know a bit about factions and that makes sense.)

    also are you planning on using torches? if so thats ok as long as you can make them different than normal ones, as in not as easy to craft. i can set up my own custom recipes but i would like normal players to still be able to use normal torches. this is why i suggested the juke box bc no one really ever uses them anyway.
     
  5. Offline

    Tecno_Wizard

    @GreenPls They won't be able to be made besides with the commands. Dont worry about it. They will have some particle effects to know they are a tac too.

    Staying forever isn't an issue. Ill have to make a flat file or database save though. Do you already have a database or should I develop using just player files?

    PS. I have most of my environment ready and I'm looking for where I put all the frameworks I've made for other plugins. I had to do a clean wipe of my computer since my last plugin. Where did I put those darn things? (It's a library of code I reuse with every plugin make things a lot simpler. Holds the premade multi-language support, player file system, and other utilities I would otherwise have to rewrite every time I make a plugin)
     
    Last edited: Jun 27, 2016
  6. Offline

    GreenPls


    just playr files if you can. can you maybe make it so you can chose the block then?
     
  7. Offline

    Tecno_Wizard

    @GreenPls

    I'll say yes for now, but I'll have to see how the particle effects work out. If they don't go so well (don't want to overload the server with particles), you might want to set a specific block. Hopefully that won't be an issue. ;)

    Player files it is.

    EDIT: As I begin to really work on this, I am realizing that due to how the plugin has to edit the world and also must observe all changes to it, shutting down your server improperly WILL cause serious issues. In addition, I will do my best to make this as easy on the server as possible, but I cannot guarantee that this will be lightweight. I have to check through every single current tac when one is broken to determine which it is, and this is going to inenviably cause some block lag when breaking the type of block you determine for the tacs. Because of this, I'm going to add an option to dispose of all tacs in the world if the lag becomes too much. I'm going to use as much simultaneous processing as possible.

    You've been warned. I will create this as fast as possible but know that the first jar I give you is going to be pretty laggy.
     
    Last edited: Jun 28, 2016
  8. Offline

    Tecno_Wizard

    @GreenPls small issue. How will I define what tactical will be used when the player respawns? For now I'll leave it as one tac per player, but I'm building the framework for multiple once you know how you want that to work.
     
  9. @Tecno_Wizard They could always been spawned somewhere dark and have signs infront of them or clickable chat messages to take them to a insert. By the way, the particles should be green, just like the ones in COD.
     
    GreenPls likes this.
  10. Offline

    Tecno_Wizard

    @bwfcwalshy, of course you show up in this thread... BTW, I was looking for you on Skype. I wasted 15 min trying to figure out where the dumb registerEvents() method was. I swear they had to make that so confusing.

    The signs could work. Not my first concern ATM. Is there a respawn event, because I can't find it. XD

    EDIT: PlayerRespawnEvent... Wow Techno, you really couldn't find that? :eek:

    EDIT2: Okay, okay. This is 100% counterintuitive.
    Code:
    Block block = insert.getLoc().getBlock();
    block.getDrops().clear();
     
    Last edited: Jun 29, 2016
  11. Offline

    GreenPls


    Well originally it had nothing to do with reswpawning. its was just a block that when destroyed would delete a warp that was set on top of it.

    example:

    You place a juke box and then chat prompts you "pleas name your warp" you would do /set warp (name or somthing like that

    then you could do /warp (name) to warp back to the top of that block from anywhere.

    but if someone destroyed that block then the warp would also be removed making it so no one can use that warp again.

    so like if you were raiding someones base on a factions server, your in there killing guys but as soon as you kill one they can just warp back to there base and continue to fight you with infinite lives. So you would have to go find their warp block and destroy it.



    im not entierly sure where you are going with this whole tac insert thing now. Are you planing on having them only be usable once? do you have to die to go back to it? You have lsot me a bit unfortunetly i am not enierly sure what is going on. I still wish you luck and hope it turns out well, im just a bit lost.\

    Edit: you shouldnt have to define what one to go to whne you spawn. the player should type a command linked to a specific one to go to it.
     
  12. Offline

    Tecno_Wizard

    @GreenPls, I was a little bit unclear on things it seems. Not a problem. I see what you intended now. They are multiple use warps that when broken no longer work.

    Currently, the backend is designed to have a block that is put into your inventory that you can get with a command / a custom recipe you create. Placing that block will prompt you to name it. Once you place it, you can call the command to get another of the block. It is a configurable option to make the tac block droppable. (is that a word?)

    Placing the block requires 3 blocks of space above it for a safe teleport back. Placing blocks above it will eventually also have a check, but it requires concurrency to do well, something that any developer here will tell you is a major pain to get right and I want you to have working version of this ASAP.
     
  13. Offline

    GreenPls


    Yes that is correct. The only thing I was unclear on is when you said "Once you place it, you can call the command to get another of the block".
     
  14. Offline

    Tecno_Wizard

    @GreenPls, ah. You can only have one of the warp blocks in your inventory at a time. That was a side effect of some of the earlier ideas I had. I can make that configurable if you'd like.

    Once you place it you can run the command to get another. This wouldn't matter if you make a custom recipe.
     
  15. Offline

    GreenPls

    Oh no its fine. My misunderstanding
     
  16. Offline

    Tecno_Wizard

  17. Yeah I also couldn't find it at first when I started a new plugin recently. I had to look it up on the Wiki, getCommand is in JavaPlugin see no reason why registerEvents can't be as well. *sigh*
     
  18. Offline

    Tecno_Wizard

    @GreenPls after looking at what you wanted versus what I originally thought you wanted, I realize that a server owner could really want either way. Therefore, I will keep the code I already made and add a mode configuration. I'll focus on your mode first.

    I tend to overdo all my plugins, but as @bwfcwalshy will tell you, they usually come out spectacularly.

    (2 distinct packages I guess, walshy? Register each package's listeners/cmd executors based on mode.)
     
    Last edited: Jun 30, 2016
    bwfcwalshy likes this.
  19. Offline

    I Al Istannen

    @Tecno_Wizard
    Why not use a HashMap<Location, TacticalInsertion> instead of a List? Would save looping through all and reduce the lag on blockbreak to one contains and get call. O(1) each.

    Or am I missing something? Could also easily be the case :p
     
  20. Offline

    Tecno_Wizard

    @I Al Istannen you know it's getting serious when you break out big O notation...

    You would be right, however, you have forgotten to include the big O of the map's get method (same efficiency as contains), which is actually worst case O(n) with n being the lenght of the map's entry list. The load is practically the same, and I can wrap the location into the same object.

    EDIT: Googled it. Apparently Java's map worst case is indeed O(n), however it is usually O(1). Got me there. There is still the issue that searching by warp name and owner is laggy. This is why I originally asked if SQL was possible...
     
    Last edited: Jun 30, 2016
  21. Offline

    GreenPls

    Ight cool man. I'm excited
     
  22. Offline

    I Al Istannen

    @Tecno_Wizard
    I apologize :p It wasn't intended to be too serious, I am still learning :D


    Yea, if there are only hash collisions, the performance goes down really quick. But there shouldn't be, if Locations hashCode is implemented correctly (which you never know... But I would hope so :p)


    You are right on this point, but looking up the location from SQL would still take way longer than from the map (One is from memory, the other probably not). So for searching by owner or name or whatever, it could be faster, but for the Location it hopefully (hashcode) won't.

    If the Location map's memeory usage gets too high, it will be bad too. Don't know if that would happen in reasonable time though :D
    I have read that mysql has it's own cache, which will cache query results for some time if you don't alter the table in the meantime. But I have never tried it and I would be extremly surprised, if it would be faster than the HashMap.

    I would say, if you expect a really large number of Tacs, you will need a database, otherwise the memory usage of the map will get too high. If you are able to save the location in a HashSet or HashMap, you will win a good chunk on every block break, as the checking if it contains the location should be instantious.
    You can then query the database for other information and maybe remove the Location from both. This approach could save you the lookup time on block breaks (which could be a lot, depending on the block used) and would keep the memory usage quite low (Location has a few bytes for the Reference to the world, and then a few doubles and floats). To get the actual tac, you would need to query the database.


    And, I have never really worked with MySql. How would you save and read an object to it? You would need to serialise it? There is the BLOB type, which would be able to hold it, but makes searches impossible. How would you efficiently save such a tac? A few columns with all the important data? How long does it take to reassemble it then? Is it negligible?
     
  23. Offline

    Tecno_Wizard

    @I All Istannen
    Very few developers here are professional. That's why I was surprised by big O.

    While SQL is a bit slower, it is significantly better all-around. And yes, I'm aware of the hashmap becoming too big poses a serious problem.

    For SQL, you would be merely serializing the non-transient fields into a table with rows as entries and columns as primitive data types/String.

    Reassembly is almost immediate because you can access the resulting row VERY fast. it would not actually go back to being a TacticalInsertion object. You're really limited to the ping time of the SQL server.
     
    bwfcwalshy likes this.
  24. Offline

    I Al Istannen

    @Tecno_Wizard
    Ah, one "l" too much :p

    Professional is taking it a bit far :p But thanks, I guess :)


    So you are gonna taking a database only solution? The SQL server is probably a localhost anyways, which reduces the ping to one symbolic millisecond.
    I am interested to see how it turns out with block breaks, if a few players are online and the tac block is stone ==> That is the theoretical worst case I can imagine :p

    But you don't need to cancel the BlockBreak event anyways, which means async processing is totally fine. No player will notice a few ticks delay. Skipped that part before :/ If you would need to cancel it, you couldn't have done it async, meaning the few ms delay per player could have made a difference.


    Do you actively serialise the class, or do you just mark the fields you don't want as transient and the database/java does it for you? Like the Java serialisation works?

    This means you can only access the saved variables, but can't call methods on the saved objects?

    Thanks for the answers so far though :)
     
  25. Offline

    Tecno_Wizard

    Yup. None of the operations are a real speed concern here.

    You don't per-say serialize the class. You save each value you need to a column of the database table manually. There is no "Object".

    The object is gone. All you are left with is a entry (row) with the data (columns) you saved. If you need it later, you need to save it.
     
  26. Offline

    I Al Istannen

    @Tecno_Wizard
    Thanks!

    Have a nice day and good luck with this project ;)
     
  27. Offline

    Tecno_Wizard

    @GreenPls, wasn't able do much today. I was with family for the holiday. Most of the warp mode code should be done tomorrow with possible exceptions to detecting illegal placing locations and when a warp becomes obstructed. Naming the warp should be simple enough, but I have never coded a system to take over the chat input before despite knowing how to do it. The only language file I will be making is English, but you are of course welcome to translate the file into another language and send it to me so I can put it into the plugin. Any messages you want to change can be done very easily by editing the English language file, but I won't be embedding that in the published version.

    I don't know how the particle effect will look yet. That's new territory for me.
     
  28. @Tecno_Wizard I can continue working on it today, I will do the name and things if you want.
     
  29. Offline

    Tecno_Wizard

    @bwfcwalshy, only if you want to, not if you just want to help me out. LOL.
     
  30. @Tecno_Wizard Created a pull request for block placement and block naming.
     
Thread Status:
Not open for further replies.

Share This Page