Closed LUF3N closed 3 months ago
Can you provide me example of the new API? I will add it to ItemCreator
Thats the original issue in paper https://github.com/PaperMC/Paper/issues/10693
They thought about adding a dummy value. I was not able to recreate that yet. That was my try: public ItemStack removeItemMeta(ItemStack itemStack) {
itemStack.getItemMeta().setAttributeModifiers(MultimapBuilder.hashKeys().hashSetValues().build());
itemStack.getItemMeta().addItemFlags(ItemFlag.HIDE_ATTRIBUTES);
return itemStack;
}
thats how they did it at paper: meta.setAttributeModifiers(MultimapBuilder.hashKeys().hashSetValues().build())
Got it. Use ItemCreator, then call make() and apply the changes manually on getting the itemstack from the make() method.
How would you implement it into this?
public PlotToggleSettingsMenu(TownBlock townBlock) { super(PlotMenu.this);
setSize(9 * 2);
setTitle(Localization.PlotMenu.ToggleMenu.MENU_TITLE);
Button.setInfoButtonTitle(Localization.MENU_INFORMATION);
fireToggle = new Button() {
@Override
public void onClickedInMenu(Player player, Menu menu, ClickType click) {
town.getPermissions().change(TownyPermissionChange.Action.SINGLE_PERM, !town.getPermissions().getOutsiderPerm(TownyPermission.ActionType.SWITCH), TownyPermission.PermLevel.OUTSIDER, TownyPermission.ActionType.SWITCH);
restartMenu();
townBlock.getPermissions().fire = !townBlock.getPermissions().fire;
townBlock.setChanged(true);
TownBlockSettingsChangedEvent event = new TownBlockSettingsChangedEvent(townBlock);
Bukkit.getServer().getPluginManager().callEvent(event);
TownyAPI.getInstance().getDataSource().saveTownBlock(townBlock);
TownyAPI.getInstance().getDataSource().saveTown(town);
restartMenu();
}
@Override
public ItemStack getItem() {
return ItemCreator.of(HeadDatabaseUtil.HeadDataUtil.createItem(String.valueOf(Settings.PLOT_TOGGLE_FIRE)))
.name(Localization.PlotMenu.ToggleMenu.FIRE)
.modelData(Integer.valueOf(Settings.PLOT_TOGGLE_FIRE_CMD))
.lore("")
.lore("" + (townBlock.getPermissions().fire ? Localization.PlotMenu.ToggleMenu.TOGGLE_OFF : Localization.PlotMenu.ToggleMenu.TOGGLE_ON)).make();
}
};
mobsToggle = new Button() {
@Override
public void onClickedInMenu(Player player, Menu menu, ClickType click) {
townBlock.getPermissions().mobs = !townBlock.getPermissions().mobs;
townBlock.setChanged(true);
TownBlockSettingsChangedEvent event = new TownBlockSettingsChangedEvent(townBlock);
Bukkit.getServer().getPluginManager().callEvent(event);
TownyAPI.getInstance().getDataSource().saveTownBlock(townBlock);
TownyAPI.getInstance().getDataSource().saveTown(town);
restartMenu();
}
@Override
public ItemStack getItem() {
return ItemCreator.of(HeadDatabaseUtil.HeadDataUtil.createItem(String.valueOf(Settings.PLOT_TOGGLE_MOBS)))
.name(Localization.PlotMenu.ToggleMenu.MOBS)
.modelData(Integer.valueOf(Settings.PLOT_TOGGLE_MOBS_CMD))
.lore("")
.lore("" + (townBlock.getPermissions().mobs ? Localization.PlotMenu.ToggleMenu.TOGGLE_OFF : Localization.PlotMenu.ToggleMenu.TOGGLE_ON)).make();
}
};
explosionToggle = new Button() {
@Override
public void onClickedInMenu(Player player, Menu menu, ClickType click) {
townBlock.getPermissions().explosion = !townBlock.getPermissions().explosion;
townBlock.setChanged(true);
TownBlockSettingsChangedEvent event = new TownBlockSettingsChangedEvent(townBlock);
Bukkit.getServer().getPluginManager().callEvent(event);
TownyAPI.getInstance().getDataSource().saveTownBlock(townBlock);
TownyAPI.getInstance().getDataSource().saveTown(town);
restartMenu();
}
@Override
public ItemStack getItem() {
return ItemCreator.of(HeadDatabaseUtil.HeadDataUtil.createItem(String.valueOf(Settings.PLOT_TOGGLE_EXPLOSIONS)))
.name(Localization.PlotMenu.ToggleMenu.EXPLODE)
.modelData(Integer.valueOf(Settings.PLOT_TOGGLE_EXPLOSIONS_CMD))
.lore("")
.lore("" + (townBlock.getPermissions().explosion ? Localization.PlotMenu.ToggleMenu.TOGGLE_OFF : Localization.PlotMenu.ToggleMenu.TOGGLE_ON)).make();
}
};
pvpToggle = new Button() {
@Override
public void onClickedInMenu(Player player, Menu menu, ClickType click) {
townBlock.getPermissions().pvp = !townBlock.getPermissions().pvp;
townBlock.setChanged(true);
TownBlockSettingsChangedEvent event = new TownBlockSettingsChangedEvent(townBlock);
Bukkit.getServer().getPluginManager().callEvent(event);
TownyAPI.getInstance().getDataSource().saveTownBlock(townBlock);
TownyAPI.getInstance().getDataSource().saveTown(town);
restartMenu();
}
@Override
public ItemStack getItem() {
return ItemCreator.of(HeadDatabaseUtil.HeadDataUtil.createItem(String.valueOf(Settings.PLOT_TOGGLE_PVP)))
.name(Localization.PlotMenu.ToggleMenu.PVP)
.modelData(Integer.valueOf(Settings.PLOT_TOGGLE_PVP_CMD))
.lore("")
.lore("" + (townBlock.getPermissions().pvp ? Localization.PlotMenu.ToggleMenu.TOGGLE_OFF : Localization.PlotMenu.ToggleMenu.TOGGLE_ON)).make();
}
};
}
@Override
public ItemStack getItemAt(int slot) {
if (slot == 1)
return fireToggle.getItem();
if (slot == 3)
return mobsToggle.getItem();
if (slot == 5)
return explosionToggle.getItem();
if (slot == 7)
return pvpToggle.getItem();
return DUMMY_BUTTON;
}
}
I can't advise with coding due to time constraints, sorry.
Opravil som to v novej Foundation 7, commit este nie je pripraveny.
Great! Will this fix the hide attribute flag than?
I apology for replying in Slovak, thought you were someone else.
Correct. In the new Foundation 7, setting hideTags() or adding the ItemFlag.HIDE_ATTRIBUTES will invoke this code which will fix it.
Ah no problem, google translator is my friend xD Thank you a lot for the fix! Any etc for the release?
Given the amount of breaking changes, might take a week or so. I will see if I have time to backport this to 6.
Hello kangarko, Could you backport it if version 7 is taking longer?
Done! New version will be out in ten minutes
Thank you very much! Will give it a try
Ahh its working perfectly! Thank you so much! <3
Hello, 1.20.5 broke the hide attribute functions. There is a workaround that would set an empty item attribute to hide the "+1 armor on feet" or "dyed" Tag from an item, but I can't figure out how I would apply "setattribute" to the Itemstack builder of your api.
The version I currently use is 1.21
Thank you in advance!