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

    Tecno_Wizard

    @bwfcwalshy, going to have to do a merge on that. I was working at the same time. XD
     
  2. @Tecno_Wizard I saw :D You did pretty much the same as me so it's fine, no need to merge it.
     
  3. Offline

    Tecno_Wizard

    @bwfcwalshy, I used a heck of a lot more concurrency. XD.

    Think you see room for a concurrent mod? I used a concurrent hashmap hoping that would prevent any issues.
     
  4. @Tecno_Wizard I didn't really see much of a need, didn't think any issues would occur but you took the better safe than sorry approach I guess :p You might also want to mention to people this is Java 8 so the OP and others who use this need a Java 8 server.
     
  5. Offline

    Tecno_Wizard

    @bwfcwalshy, I am going to make that clear, don't worry. Java 8 lambas and streams rule, server owners/hosts who are too stubborn to use java 8 drool.

    Otherwise, like the config manager? I think that is one of the most useful pieces of code I've ever written for bukkit.
     
    bwfcwalshy likes this.
  6. Offline

    Tecno_Wizard

    @GreenPls Evening!

    I'm currently working on solving an issue with block recognition while they are being placed. I'm having an issue detecting when the torch is being placed because the Bukkit API does not give me access to the data that identifies that a tactical insertion is not a normal stack during the place. I'm looking for a work-around.

    Here's the thread. https://bukkit.org/threads/how-does...rk-with-blockplaceevent-getiteminhand.424118/

    Happy 4th!

    EDIT: The workaround seems to have worked, but there is another case I still have to check. In all, if you don't try to confuse the plugin, it is working at it's core. At this point nothing saves through a reload/restart, which will be addressed.

    Just some notes for you. When you get the first jar, if you set the mode to respawn, it won't work at all. I'm also still working out some of the kinks with specific actions that would break how the naming system works. (ie breaking a tac you haven't named yet, logging out when naming the tac, alerting the player that one of their tacs have been broken...) I haven't started the particle effect yet either.

    PS. The invalid email commits are me. I got a new laptop today (woo!) and it seems I didn't 100% configure git yet.
     
    Last edited: Jul 4, 2016
  7. Offline

    Tecno_Wizard

    @GreenPls I didn't have a whole lot of time today and I apologize for that. This is taking me longer than I would have hoped it would. Know that I'm still dedicated to finishing this for you.

    I'm currently working on getting rid of any problems that would arise if the user logs out, they never name the tac, they brake it before they name it, those sort of issues. Once that is fixed, I'll get particle effects working (something subtle) and then saving data through server restarts.
     
  8. Offline

    Tecno_Wizard

    @GreenPls Lots of stuff today!

    Warp mode is nearly complete. There are some issues with detecting when hanging blocks (such as torches) break because the block they are attached to breaks, but besides that things are going well. Messages that are currently hardcoded will soon be moved to the language manager and the config will be editable instead of only being internal. Particle effects are coming up soon.
     
  9. Offline

    I Al Istannen

  10. Offline

    Tecno_Wizard

  11. Offline

    I Al Istannen

    @Tecno_Wizard
    I know, but I think it breaks at unicode (äöü and similar). At least I have seen some posts where this was the iusse. And you can more deeply specify the format "{0,number,$00.00}" will make a number appear in the form of "$xx.xx". The message format is quite customizable.

    Just wanted to show you an alternative which minecrtaft itself (afaik), essentials and some other use.

    Sorry if it sounds like I want to force you to do anything, just wanted to mention it to you :)

    Have a nice day!
     
  12. Offline

    Tecno_Wizard

    @I Al Istannen, nope. You're not forcing anything. I might incorporate that into the language files. Thank you!
     
  13. Offline

    I Al Istannen

    @Tecno_Wizard
    Thanks for taking it the way it was meant :)

    Good luck with your project, wether you include it or not!
     
  14. Offline

    GreenPls

    SOunds fantastic, cant wait! sorry i have been a bit inactive i am currently very busy elswear.
     
  15. Offline

    Tecno_Wizard

    @GreenPls,

    Here's a particle effect trial. What do you think? I can change it, no worries if it isn't what you were looking for.

    [​IMG]

    I'm working on moving the messages to files right now. 90% of the config is working but when I give you the first jar it isn't going to be 100% complete. Respawn mode won't do anything.

    BTW, changing what material the tacticals are WILL break all existing ones. I will be adding detection to when this happens to prevent it eventually, but it won't be part of the jar you get at first.

    Well, the first jar is in what I consider running condition. A few things to remember...

    1. There is currently a permission to allow use of the /gettac command. "tacticalinsertions.getblock" I'll add more to other functions if you want.
    2. Do not allow your users to use the plugin before you configure what material you want to use for the tactical insertion. By default I believe it is a diamond block. If you do, you will have insertions that have no corresponding block anymore. A warning about this will be added eventually. (and all existing insertions will be deleted). Look up the bukkit material list. Any of these names in all caps will work, but they must be exactly that same. Don't use anything you can't place. Use common sense there.
    3. If you get an error, report it to me asap with the text from the console.
    4. Use the /help tacticalinsertions command to see the help menu
    5. Google drive link. https://drive.google.com/file/d/0B6okEWgp3tkcclZsTVZDN3FyYjg/view?usp=sharing
     
    Last edited: Jul 10, 2016
  16. Offline

    Tecno_Wizard

    My word this is confusing. 2 questions since you seem to know how this works. Is it possible to save properties files inside the plugin directory and load them from there so the server owners can change the messages and can I do this without specifying a locale in the bundle file?
     
  17. Offline

    I Al Istannen

    @Tecno_Wizard
    You can have a look at my Implementation here. (Used in the InventoryProfiles repo, but in the second branch) (Can surely be made better, so if anything comes to your mind, say it :p)
    It just uses the most basic features, you can do a lot more of stuff with Properties files. But this is the easist and I didn't need to others yet.
    • Loading from the plugin dir:
      You will need to create a file class loader (not that much code and quite easy) to allow what you want.
    • Saving to it:
      Simply copy the file using a BufferedWriter or things like this. You normally don't need to edit the file after you saved it, so that doesn't really matter. If you write your translate method nicely, it will fallback to the intern translation if the key is missing in the saved one.

    Not quite sure what you mean with the "without a locale" part, but it will select the File to use in this way.
    This means if you just use the base name (e.g. "Messages.properties") without the "_<language tag>", it will apply to all possible languages. It is always nice to have one without anything as a fallback.

    If I didn't answer your questions or you have another just say so!
     
  18. Offline

    Tecno_Wizard

    I would overload the tr and translate methods instead of giving them different names. They do nearly the same thing. I submitted a pull request fixing it for you if you'd like. Besides that, this is a great place for me to start. I'll use this as a reference. Thank you. I'm 100% self taught so some of the more complicated aspects of the Java SDK get to be a bit too much at times.

    EDIT: I just noticed the inherited interface, so this may not apply. Maybe just rename the interface or the old translate method to tr. Do whatever works for you. It's your code, not mine.
     
    Last edited: Jul 14, 2016
  19. Offline

    I Al Istannen

    @Tecno_Wizard
    I originally only intended one category for the MessageProvider and liked the short name "tr". In my I18N class, I provided the translate method additionally (needed it for a plugin which had two files. One "Messages" and an "Items" one, to localize the displayed item names. It is basically Timtowers chest shop for InventoryProfiles, just written by me) and to make the difference clear, it is called "translate".
    Just for me to not mess up, as I would totally do otherwise xD

    It totally slipped past me that I could just refer to the other method, I did that now. Thanks!

    But yea, I may change the Interface in the future, thank you!

    I learned most of it from a book and then recently programming (not a specific language, abstract concepts) more seriously (uni courses).
    So I also make a lot of mistakes, which is why I am always glad if somebody points something out :)
    And, to be honest, I heavily used Essentials (and the oracle Trail) for referecence. Just compare the method names ;)
    But it works, and I think I understood how, so all is good!

    Good luck with your project, I think am sure you can manage it alone (and may prefer it ;)), but I would try to help you if you have a question :)

    Have a nice day!
     
  20. Offline

    Tecno_Wizard

  21. Offline

    I Al Istannen

  22. Offline

    Tecno_Wizard

    @I Al Istannen, Okay, that was dumb. Thanks.

    @GreenPls The first jar is back a little bit in this thread if you haven't gotten it yet. The google drive link. We're discussing the language files here.
     
    I Al Istannen likes this.
  23. Offline

    Tecno_Wizard

    Since my last post:
    1. Plugin now detects unsafe config changes to the config and resolves them by clearing all insertions.
    2. The mode must be changed through the plugin. It has been removed from the config file and left as a note in the header. Data for this is stored in the general save data file.
    3. Language files are getting there. I'm still seeing some strange behavior from it that I need to fix.
    4. My brother spent a half-hour making diamonds out of insertion blocks. I think I caught all of his shenanigans... I think.

    I'm really loving how this plugin is turning out and I hope you'll like it, @GreenPls. I hate how long it is taking but I have a full time job on weekdays.

    The link for the second alpha jar is here:
    https://drive.google.com/file/d/0B6okEWgp3tkcdGtFT0lDaXhtQXc/view?usp=sharing
    @bwfcwalshy go ahead with your jar checky thing. I know you like that. XD
     
    Last edited: Jul 24, 2016
  24. Offline

    Tecno_Wizard

    @GreenPls Woohoo! TacticalInsertions 1.0 is nearly complete! I know I spent a long time making it, but I put a lot of work into preventing exploits you may not immediately see. The only remaining issue I know of is that pushing an insertion with a piston makes the insertion unbreakable. I'm working on a solution to this.
    Once I finish with the English language file I will make a primary release.
     
  25. Offline

    I Al Istannen

    @Tecno_Wizard
    Either I am dumb, or you need to use a new MessageFormat for every message you want to translate.
    It is build from a Pattern and replaces "{0}", "{1}" and so on. Look at this and this method.

    Afaik my language system works, so if nothing works for you, you could just compile my system in your plugin and look here how to use it (the folder on the disk must have the same name as the package the properties files are in. It is just the way my FileClassLoader is designed). To see if anything works :p
     
  26. Offline

    Tecno_Wizard

    @I Al Istannen, it's been working so far, but I haven't had to use the formatter yet.
    PS: IntelliJ is too smart for it's own good sometimes. I HAVE IN NO WAY SPECIFIED THAT THIS IS A PROPERTIES FILE BESIDES A SINGLE ENUM WITH A FILE NAME AND A RESOURCE BUNDLE.
    [​IMG]
    [​IMG]
     
    Last edited: Jul 26, 2016
  27. Offline

    I Al Istannen

    @Tecno_Wizard
    Maybe because you have the file open? But nonetheless, this looks insanely smart... Okay, I will look into IntelliJ again xD
    Eclipse is already a pain, as it completly disables ANY functionality inside lambdas... But I am used to it and don't really know IntelliJ. Well, I will see...

    Enough offtopic, good luck with it! If you think I can help you, feel free to message me :)
     
  28. Offline

    Tecno_Wizard

    Completely supports lambdas and will suggest you change things into them. If you have an anonymous functional interface and your JDK is set to 8 it will ask to change it for you. And this worked even with the properties file closed... Personally IntelliJ tears Eclipse to shreads, but it needs a good computer to run on. It's demanding.

    On topic, Everything is going really well besides detecting if the block is pushed by a piston. Tried a BlockIterator but couldn't figure out it's startPositionVector thingy. Notch does realize that a vector isn't a point, right? XD
     
  29. Offline

    I Al Istannen

    @Tecno_Wizard
    This is the first time I am actually interested in IntelliJ :p I tried it for a few hours some time ago, but just couldn't get on friendly terms with it...
    My computer is okay, not a potato, but not that good either. IntelliJ was working the last time I tried it though ;)

    On topic:
    I wrote some code ages ago to see if a block was pulled/pushed by a piston. You will have to clean it up by a LOT, but the basic idea is hopefully still relevant. (Works in 1.7 and 1.8, don't know above)
    If your block is a torch, you will probably need to check any blocks attached to it too. Will make it more complicated.
    Code:
        @EventHandler
        public void onPistonPull(BlockPistonRetractEvent e) {
            if(!(onlyInCreative || protect)) {
                return;
            }
           
            Block block = e.getBlock();
            // don't freaking ask why this **** is needed...
            // It was when I wrote the code and was totally baffeling me
            if(Bukkit.getBukkitVersion().startsWith("1.8")) {
                block = block.getRelative(e.getDirection().getOppositeFace(), 2);
            }
            else {
                block = block.getRelative(e.getDirection(), 2);
            }
           
            if(block.getType() == Material.CAULDRON && AFS.getInstance().getMortarManager().containsLocation(block.getLocation())) {
                e.setCancelled(true);
            }
           
        }
    Code:
        @EventHandler
        public void onPistonPush(BlockPistonExtendEvent e) {
            if(!(onlyInCreative || protect)) {
                return;
            }
           
            for(Block block : e.getBlocks()) {
                if(block.getType() == Material.CAULDRON && AFS.getInstance().getMortarManager().containsLocation(block.getLocation())) {
                    e.setCancelled(true);
                }
            }
                   
        }
     
  30. Never had that issue, what Eclipse are you using?
     
Thread Status:
Not open for further replies.

Share This Page