1.12.2 How would you print block data to a file as numbers not strings

Discussion in 'Spigot Plugin Development' started by Steffbeard, Feb 17, 2020.

Thread Status:
Not open for further replies.
  1. So I am working with Towny's source code to try and backport it since they no longer support 1.12 with their recent updates. The problem is that my knowledge of Java is not great. I never had time to sit down and take a course and most of my knowledge is from watching developers on YouTube.

    My issue is that in their TownySQLSource.java, there is a new field that was never there in the 1.12 version:
    Snippet: https://sourceb.in/329ffaf370

    It is giving me an error on Line 29 of the above snippet
    Code (Java):
    Type mismatch: cannot convert from element type Integer to String
    . When I change type of "block" from "String" to "Integer", I get an error on line 40 telling me
    Code (Text):
    The method writeUTF(String) in the type DataOutputStream is not applicable for the arguments (Integer)
    How would be the correct way of fixing this part?
     
  2. What does .getBlockList return?
    If it's a bukkit Block, you can use block.getTpye().name() to get the block's name.
     
  3. BlockData didn't exist in 1.12.x
     
  4. If you're going to the effort to backport modern versions of Towny to 1.12 you will run into things like this that have changed significantly on the Bukkit side of things. That said, if you do accomplish this we'd love to see your code as a Pull Request to our 1.12.2 branch on Github.

    What you see in our 1.12.2 branch will most likely be what was used on those old builds before BlockData and other things came to be.
     
    • Agree Agree x 1
  5. thanks and will do when it's finished, thank you for making such a great plugin
     
Thread Status:
Not open for further replies.