Hot Summer Deals are Here!
Celebrate with up to 99% off on 17,300 resources
02
Days
20
Hours
54
Mins
04
Secs

Menu help (config name) event breaks

Status
This thread has been locked.

TheCrystalStar

Banned
Feedback score
2
Posts
213
Reactions
65
Resources
0
Ok so this is my code for the inventory click event

public class MainMenuHandler implements Listener {

public static Main plugin;

@EventHandler
public void onMainMenuClick(InventoryClickEvent event) {

Player player = (Player) event.getWhoClicked();

try {
if (event.getClickedInventory().getTitle().equals((plugin.getConfig().getString("GUI.MainMenu.Title").replace("&", "\u00A7")))) {

if (event.getCurrentItem().getType() == Material.SKULL_ITEM) {

if (event.getCurrentItem().hasItemMeta()) {

if (event.getCurrentItem().getItemMeta().getDisplayName().contains("§a§lPlayer Options")) {

event.setCancelled(true);
player.closeInventory();
player.performCommand("PlayerPanel");
}
}
return;
}

if (event.getCurrentItem().getType() == Material.STAINED_GLASS_PANE) {

if (event.getCurrentItem().hasItemMeta()) {

if (event.getCurrentItem().getItemMeta().getDisplayName()
.contains("§a§lView Block Cateogories")) {

event.setCancelled(true);
player.closeInventory();
player.performCommand("BlocksMenu");
}
}
return;
}
}
}
catch (NullPointerException e) {
}
}
}


And for my config:
Gui:
MainMenu:
Title : '&atest'

inventory event does work I can take stuff out and events won't work but if I didn't have it so it gets the name from the config it would work fine
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Guusz

Full-Stack Web Developer
Premium
Feedback score
0
Posts
248
Reactions
138
Resources
0
Code:
public static Main plugin;

Why :(

Try putting it in a code block[DOUBLEPOST=1468034386][/DOUBLEPOST]You also didn't assign the plugin variable to anything
Check on that, and why are you try-catching a NPE when every method in an event cant throw an NPE?
Please also show us any error in console from your plugin.
 

Ark9026

Accepting Plugin Orders!
Premium
Feedback score
6
Posts
64
Reactions
60
Resources
0
Besides the errors mentioned above, here is your main issue :)
Code:
if (event.getClickedInventory().getTitle().equals((plugin.getConfig().getString("GUI.MainMenu.Title").replace("&", "\u00A7")))) {
should be
Code:
if (event.getClickedInventory().getTitle().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI.MainMenu.Title")))) {
That should fix it :)
 

TheCrystalStar

Banned
Feedback score
2
Posts
213
Reactions
65
Resources
0
Besides the errors mentioned above, here is your main issue :)
Code:
if (event.getClickedInventory().getTitle().equals((plugin.getConfig().getString("GUI.MainMenu.Title").replace("&", "\u00A7")))) {
should be
Code:
if (event.getClickedInventory().getTitle().equalsIgnoreCase(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("GUI.MainMenu.Title")))) {
That should fix it :)
Thx. Bro helped a lot :D
 
Banned forever. Reason: Scamming (https://builtbybit.com/threads/thecrystalstar-scam-report.276555/)

Ark9026

Accepting Plugin Orders!
Premium
Feedback score
6
Posts
64
Reactions
60
Resources
0
If you're all set, feel free to close the thread :)
 
Status
This thread has been locked.
Top