InventivetalentDev / MapManager

MIT License
54 stars 20 forks source link

showInHand or showInInventory not working #46

Closed stijnb1234 closed 4 years ago

stijnb1234 commented 4 years ago

What steps will reproduce the problem?

  1. I run wrapper.getController().showInHand(p, true);
  2. The user get's an empty image

What were you expecting to happen? What happened instead?

A good image is shown

What version of the plugin are you using? Type /version <Plugin Name>

1.7.5-SNAPTSHOT

What Spigot version are you using? Type /version

1.14.4-R0.1-SNAPSHOT [PaperSpigot build 237]

What plugins are you using? Type /plugins

image

The image (ArrayImage) is okay. image

But it's not shown in the inventory, and it says "Unkown map" image

image

InventivetalentDev commented 4 years ago

Would you mind attaching a snippet of your code (for both the itemframe and inventory ones)?

stijnb1234 commented 4 years ago
public static void render() {
    //AFRender is my object where I store the MapWrapper
    AFRender render = new AFRender();

    BufferedImage img = ...;
    MapWrapper wrapper = mapManager.wrapImage(img);

    render.setWrapper(wrapper);

    for (Player p: Bukkit.getServer().getOnlinePlayers()) {
        showForPlayer(p, /* I get the frame from another object */ , render);
    }
}

public static void showForPlayer(Player p, ItemFrame frame, AFRender render) {
    MapController controller = render.getWrapper().getController();
    controller.addViewer(p);
    controller.sendContent(p);
    controller.showInFrame(p, frame, true);
}

public static void showInInv(Player p, AFRender render) {
    render.getWrapper().getController().showInHand(p, true);
}
InventivetalentDev commented 4 years ago

Fixed in 1.7.6-SNAPSHOT :)