Solved Having difficulties updating plugin from 1.12 to 1.14+

Discussion in 'Plugin Development' started by Minesuchtiiii, May 19, 2019.

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

    Minesuchtiiii

    So I want to upgrade one of my plugins from Spigot 1.12 to 1.14.1 and after importing the new library I'm getting a lot of errors. Most of them are just updated names from ItemStacks, but my main problem is the following:

    I have a command, which removes the block sunder a player one by one to the first block above the void. After the player (hopefully) fell into the void and died those removed blocks should be replaced back to their original block. Now I'm getting an error in the following part of the code:

    Code:
    final Location loc = target.getLocation();
    Location blocksloc = loc.getBlock().getRelative(0, -i, 0).getLocation();
                            this.plugin.nummer.put(Integer.valueOf(i), Integer.valueOf(blocksloc.getBlock().getTypeId())); <---
    Is there a workaround for the getTypeId part? As I dont want to change the whole code which is used in more commands...

    Thanks!
     
  2. Offline

    timtower Administrator Administrator Moderator

  3. Offline

    Minesuchtiiii

    If for example there are different type of wool or wood blocks under the player they get changed back to white wool or the normal wood block, if yk what I mean
     
  4. Offline

    Mathias Eklund

    @Minesuchtiiii For 1.14 wool colors are specified in the material name though?
    And also, you could just use block.getRelative(BlockFace.UP) to get the block above the current locations block.

    And, don't keep using the typeId and MaterialData. Switch to the material names for the newer version. typeId has been deprecated for a long time.
     
  5. Offline

    Dai_Kunai

    Yeah in 1.14 they have materials such as BLACK_WOOL, BLUE_WOOL, CYAN_WOOL, and the same goes for stained glass and carpets and all of those things.
     
  6. Offline

    Minesuchtiiii

    So I tried it with the material, it works but it replaces the old (colored) blocks with just white wool / white concrete / standart oak planks. Any ideas?

    Code:
        public HashMap<Integer, Location> blockloc = new HashMap<Integer, Location>();
        public HashMap<Integer, Material> blockmat = new HashMap<Integer, Material>();
    
    final Location tloc = target.getLocation();
    final int times = Integer.valueOf((int) (tloc.getY() + 1));
                                   
                                    for(int i = 0; i<times; i++) {
                                       
                                        Location loc_of_block = tloc.getBlock().getRelative(0, -i, 0).getLocation();
                                        this.plugin.blockloc.put(Integer.valueOf(i), loc_of_block);
                                        this.plugin.blockmat.put(Integer.valueOf(i), tloc.getWorld().getBlockAt(loc_of_block).getType());
                                       
                                    }
    
    
     
  7. Offline

    timtower Administrator Administrator Moderator

  8. Offline

    Minesuchtiiii

    Code:
    [19:02:36] [Server thread/INFO]: Block:LEGACY_WOOL
    [19:02:36] [Server thread/INFO]: Block:LEGACY_WOOL
    [19:02:36] [Server thread/INFO]: Block:LEGACY_WOOL
    [19:02:36] [Server thread/INFO]: Block:LEGACY_GOLD_BLOCK
    [19:02:36] [Server thread/INFO]: Block:LEGACY_CONCRETE
    [19:02:36] [Server thread/INFO]: Block:LEGACY_CONCRETE
    [19:02:36] [Server thread/INFO]: Block:LEGACY_CONCRETE
    [19:02:36] [Server thread/INFO]: Block:LEGACY_WOOD
    I placed different wool and concrete colors
     
  9. Offline

    timtower Administrator Administrator Moderator

    @Minesuchtiiii api-version: 1.13 Do you have that or for 1.14 in your plugin.yml?
     
    Minesuchtiiii likes this.
  10. Offline

    Minesuchtiiii

    I didn't have neither! I put 1.14 in the plugin.yml and it works perfect now! Thank you!

    Code:
    [19:08:24] [Server thread/INFO]: Block:AIR
    [19:08:24] [Server thread/INFO]: Block:DARK_OAK_PLANKS
    [19:08:24] [Server thread/INFO]: Block:OAK_PLANKS
    [19:08:24] [Server thread/INFO]: Block:OAK_WOOD
    [19:08:24] [Server thread/INFO]: Block:RED_CONCRETE
    [19:08:24] [Server thread/INFO]: Block:WHITE_CONCRETE
    [19:08:24] [Server thread/INFO]: Block:GOLD_BLOCK
    Am I supposed to change the api-version in the plugin.yml every time I change the external jar I'm using?
     
  11. Offline

    timtower Administrator Administrator Moderator

    @Minesuchtiiii Believe that it was mostly for the material names. In 1.13 a lot changed in that area so they had to find a way to work with it.
    Think that you can keep it on 1.14 for a long time. Just keep it on the lowest supported version.
     
  12. Offline

    Minesuchtiiii

    Alright thanks again! Thread can be closed :)
     
  13. Offline

    Reflxction

    Sorry for the bump, however I'm having a similar issue (updating ~50 plugins from 1.12.2. to 1.14) and wish if you could thoroughly explain what api-version does or what is its purpose? The wiki page did not add it (yet, I assume) and apparently it seems to have a remarkable effect in the plugin.
     
  14. Offline

    KarimAKL

    Reflxction likes this.
Thread Status:
Not open for further replies.

Share This Page