ipvp-mc / canvas Goto Github PK
View Code? Open in Web Editor NEWCanvas is a java library built for Bukkit to manage custom inventory based menus
License: MIT License
Canvas is a java library built for Bukkit to manage custom inventory based menus
License: MIT License
I have a system of menus that use canvas, some use redraw and some do not. Redraw is true on my paginated menus, but not on the static screens like the main menu.
My issue is that when a click handler opens a different (redraw enabled) menu from a non redraw menu, the title does not update.
I might be using it wrong but I don't think redraw menus should redraw over top of non redraw menus (AbstractMenu:114 only checks the menu it's opening for redraw, not the one its drawing over) Sidenote: In my particular case adding the open.isRedraw() fixed it
Whether that's intended behavior or not I would like to make sure that the containers title changes when the new menu opens.
Thanks in advance
Hi, I'm trying to use this api, but when I put the dependency in the dependencies tag it gives me an error, saying it can't find the dependency in the spigot repository, how can I solve it?
(in case you could write to me on discord, tag: codedevv)
Hi, I really like the ability to select which actions can player do (like put items inside but donť take them out etc) - but I have problem with getting items which players put inside.
I have created simple empty ChestMenu and allowed putting items in. Then I created closeHandler for it which prints all slots.
But even if I put items inside this ChestMenu, when I get items from slots, all items are null.
How can I get items which I put inside ?
It seems like that a player is removed from the menu before the close handler is triggered:
MenuHolder holder = (MenuHolder) currentInventory;
holders.remove(holder);
if (triggerCloseHandler) {
getCloseHandler().ifPresent(h -> h.close(viewer, this));
}
which prevents you from using things like Slot::getItem(player)
inside of close handlers.
Would just swapping around the close handler and removing the holder work and fix this?
I've been trying to use this library, and setting itemstacks in the gui works fine, but no matter how many ways I try, I get no response on any click handlers. I'm using the latest paper jar.
i run the following code but the change page items never appear, ever.
BinaryMask itemSlots = BinaryMask.builder(pageTemplate.getDimensions())
.pattern("000000000")
.pattern("000000000")
.pattern("111111111")
.pattern("111111111")
.pattern("111111111")
.pattern("000000000").build();
Collection listOfItems = new ArrayList();
for (LoadoutItem item:loadout.getAllItems()) {
ItemStack builtItem = loadout.buildFormattedItemStack(item);
listOfItems.add(builtItem);
}
//list items, then return a collection of items for feeding ;)
List<Menu> pages = PaginatedMenuBuilder.builder(pageTemplate)
.slots(itemSlots)
.addItems(listOfItems)
.nextButton(new ItemStack(Material.ARROW))
.nextButtonSlot(45)
.previousButton(new ItemStack(Material.ARROW))
.previousButtonSlot(36)
.build();
for (Menu menuMenu:pages) {
addBorder(menuMenu);
addLoadoutActionItems(menuMenu, sender);
}
return pages.get(page);
Hello,
i have following test-code which showcases my problem:
Menu test = ChestMenu.builder(1).build();
test.getSlot(0).setItem(new ItemStack(Material.GRASS_BLOCK));
Menu test2 = ChestMenu.builder(6).build();
test2.getSlot(5).setItem(new ItemStack(Material.DIAMOND));
test.setCloseHandler(((player, menu) -> {
test2.open(player);
}));
test2.setCloseHandler(((player, menu) -> {
test.open(player);
}));
test.open(e.getPlayer());
I would expect that both Inventories are alternating when closing them and both Items in both Menu's are not movable. But what happens here is that after the first close, the diamond-item is free movable and the closeHandler is not executed for the second Inventory. The first one works just fine.
am I using something wrong?
any ideas on this?
Thanks!
I would like to use this in minecraft 1.8.8. Is that possible?
Perhaps it's a good idea to mention in the Readme which versions are supported.
I need to allow dropping of items
DROP_ALL_CURSOR, DROP_ONE_CURSOR
but even when I allow it, it doesn't work - only dropping slot works :(
I've used spigui for over 2 years now (linked here) and was wondering what benifits/drawbacks would occur if I switched to canvas.
This is a simple question for me and other users out there
So how should I use this example the right or new way?
https://github.com/IPVP-MC/canvas#pagination
Other question?
Is this project still maintained? Should I use this for production?
When i have a paginated menu open, players clicking on a button does not redraw the page. I worked around this by causing the player to close the inventory first, and then re-open the menu, but this will reset the page the player is viewing. Is there a built in method to redraw the page for the player on clicking a dynamic button?
Example config struct(in hocon format):
shop {
inventory {
title = "&0Shop"
rows = 4
}
matrix = [
"____e____"
"__m___d__"
"_ABC_EFG_"
"_D___H___"
]
items {
"e" {
type = ENDER_CHEST
name = "&eКейс с косметикой"
lore = [
"&fPrice: &e{price}"
"&fOne more line"
]
}
etc for each char
}
}
_
by default air
SlotSettings clickableItem = SlotSettings.builder()
.itemTemplate(
new StaticItemTemplate(new ItemStack(Material.ACACIA_BOAT));
)
.clickHandler((player, click) -> {
/* click logic goes here */
}).build();
With the following, why is it that you can pass Player and ClickInfo through the clickhandler but not Player through the itemTemplate? When I try to do
.itemTemplate(p -> {}) it informs me that it is not applicable for the argument p
yet when using the Slot.setItemTemplate method the Player argument is valid?
Hi! I'm so sorry for using issues to get support, do you have a discord?
Anyways, here is my issue. I'm using the following method to display a menu of a specific player's statistics controlled by a command. The only problem is, the first time the method is run, it hangs the server. Any subsequent usage of the method is lag-free.
public void showProfile(ElytraPlayer viewer, ElytraPlayer target) { ChestMenu menu = ChestMenu.builder(6).redraw(true).title(AuriUtils.colorString("&f&l" + target.getName() + "'s &c&lProfile")).build();
BinaryMask itemSlots = BinaryMask.builder(menu.getDimensions())
.item(new ItemBuilder(Material.GRAY_STAINED_GLASS_PANE).setDisplayName("").build())
.pattern("011111111")
.pattern("000100000")
.pattern("000100000")
.pattern("000100000")
.pattern("000100000")
.pattern("000100000").build();
menu.getSlot(1, 1).setSettings(SlotSettings.builder().itemTemplate(p -> {
return new ItemBuilder(Material.BARRIER).setLore("",AuriUtils.colorString("&7Click to close!")).setDisplayName(AuriUtils.colorString("&cClose")).build();
}).clickHandler((p, c) -> {
p.closeInventory();
}).build());
menu.getSlot(3, 2).setSettings(SlotSettings.builder().itemTemplate(p -> {
ElytraPlayer ep = target;
ArrayList<String> lore = new ArrayList<>();
lore.add(AuriUtils.colorString(""));
lore.add(AuriUtils.colorString("&c" + ep.asBukkitPlayer().getName() + "&7's Main Network statistics"));
lore.add(AuriUtils.colorString(""));
lore.add(AuriUtils.colorString("&7[ " + ep.getProgressBar() + "&7 ] &7&l" + "&c" + ep.getExperience() + "&7/" + ep.getRequiredXPToNextLevel() + " &c❂"));
lore.add(AuriUtils.colorString(""));
lore.add(AuriUtils.colorString("&7You are level &c" + ep.getLevel() + "!&7"));
return new ItemBuilder(Material.LEGACY_SKULL_ITEM, (short) 3).setHead(p.getName()).setLore(lore).setDisplayName(AuriUtils.colorString("&c&l" + p.getName() + " &c[&7" + ep.getLevel() + "&c]" + "&7 's Profile")).build();
}).clickHandler((p, c) -> {
//row, collum
}).build());
menu.getSlot(5, 2).setSettings(SlotSettings.builder().itemTemplate(p -> {
ElytraPlayer ep = target;
ArrayList<String> lore = new ArrayList<>();
lore.add(AuriUtils.colorString(""));
lore.add(AuriUtils.colorString("&c" + ep.asBukkitPlayer().getName() + "&7's Balance:"));
lore.add(AuriUtils.colorString(""));
lore.add(AuriUtils.colorString("&7Your balance: &6" + PlaceholderAPI.setPlaceholders(ep.asBukkitPlayer(), "%vault_eco_balance_commas% ⛃")));
if (RewardController.get().hasRewards(ep)) {
lore.add(AuriUtils.colorString(""));
lore.add(AuriUtils.colorString("&e&lYou have rewards!&7 Do /rewards to claim them!"));
}
return new ItemBuilder(Material.SUNFLOWER).setLore(lore).setDisplayName(AuriUtils.colorString("&c&l" + p.getName() + " &c[&7" + ep.getLevel() + "&c]" + "&7 's Balance")).build();
}).clickHandler((p, c) -> {
}).build());
itemSlots.apply(menu);
menu.open(viewer.asBukkitPlayer());
}`
Anyways, i realize a better way to do this would be to store a private ChestMenu in my GUIController (which provides this method) but then i would not be able to specify the 2nd player(target). Is there a better way of doing this or am i doing this correctly?
Missing Artifact org.ipvp:canvas:jar:1.5.0-SNAPSHOT
Hello.
I would like to ask if then iPvP server is still in development and if not, would it be possible to buy the domain? Please contact me on Discord (lukeeey#2013) to speak more about this.
Thanks.
Is there a way to get what item was removed from a slot? I'm currently trying:
https://paste.md-5.net/ofogaqoqah.coffeescript
and I'm getting an error that the itemstack in that slot is null.
I did a clean install of canvas, then added it as a depend to my pom.xml. however, it still throws a noclassdeferror
java.lang.NoClassDefFoundError: org/ipvp/canvas/MenuFunctionListener
at main.java.com.elytraforce.loadoutsystem.Main.registerListeners(Main.java:39) ~[?:?]
at main.java.com.elytraforce.loadoutsystem.Main.onEnable(Main.java:26) ~[?:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[server.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:337) [server.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:403) [server.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugin(CraftServer.java:381) [server.jar:git-Spigot-79a30d7-acbc348]
at org.bukkit.craftbukkit.v1_12_R1.CraftServer.enablePlugins(CraftServer.java:330) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.t(MinecraftServer.java:422) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.l(MinecraftServer.java:383) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.a(MinecraftServer.java:338) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.DedicatedServer.init(DedicatedServer.java:272) [server.jar:git-Spigot-79a30d7-acbc348]
at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:545) [server.jar:git-Spigot-79a30d7-acbc348]
at java.lang.Thread.run(Thread.java:748) [?:1.8.0_242]
please help :)
I can't seem to find a documentation.
Where do I find it?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.