Solved Casting WorldGuard World to Bukkit World WG7

Discussion in 'Plugin Development' started by Exequtor, Jan 4, 2019.

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

    Exequtor

    Hey everyone! :)

    (Wrong title: Bukkit World to WorldEdit World - and not reverse :D)

    I was trying to find out how to get the Region List from the RegionContainer for a specific world with the new WorldGuard 7 API.
    Code:
    RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();    
    
    World world = (World) player.getWorld();
    
    container.get(world).addRegion(region);
    I'm constantly running into the error that I cannot simply cast a Bukkit World to a WorldEdit World.

    One has to notice that I imported the WorldEdit World and therefore didn't make the mistake to refer twice to the same kind of world. This line where I'm trying to cast the Bukkit World to the WorldGuars World throws the following exception:
    Code:
    aused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_13_R2.CraftWorld cannot be cast to com.sk89q.worldedit.world.World
    So I've been looking aroung for a while in different forums and found older solutions that recommend using BukkitUtil.getLocalWorld() or something similar to that. But this method can't be found in the new WorldGuard 7 (and neither in WorldEdit 7, I also use this as an archive for the same plugin).

    I also can't find anything concerning this problem in the WorldGuard Documentation, maybe anyone of you out there can help me?
     
    Last edited: Jan 4, 2019
  2. Online

    timtower Ninja on the waves Moderator

  3. Offline

    Exequtor

    Thank you - this thread really helped me out. I had no idea that they moved this kind of functionality to BukkitAdapter.adapt();
     
    Last edited by a moderator: Jan 4, 2019
    timtower likes this.
Thread Status:
Not open for further replies.

Share This Page