Fix UI for PlayWire changes
Fix memory leak in Menu (cherry picked from commit 770c899)
This commit is contained in:
parent
36c26c0b2c
commit
2a81f2b317
@ -20,11 +20,11 @@ public class PlayWireButton implements GuiItem
|
||||
.setTitle(C.cGreen + C.Bold + "Watch an Ad!")
|
||||
.addLore(
|
||||
C.cWhite + "You have already redeemed your",
|
||||
C.cWhite + "250 Shards for watching the Ad!",
|
||||
C.cWhite + "100 Shards for watching the Ad!",
|
||||
" ",
|
||||
C.cWhite + "You can watch it again, but you won't earn any shards!",
|
||||
" ",
|
||||
C.cWhite + "You can watch the Ad once every 12 hours.",
|
||||
C.cWhite + "You can watch the Ad once every hour.",
|
||||
" ",
|
||||
C.cWhite + "Ads help us keep Mineplex awesome",
|
||||
C.cRedB + "Be sure to have your AdBlocker disabled!",
|
||||
@ -36,10 +36,10 @@ public class PlayWireButton implements GuiItem
|
||||
private static final ItemStack ENABLED_ICON = new ItemBuilder(Material.TRIPWIRE_HOOK)
|
||||
.setTitle(C.cGreen + C.Bold + "Watch an Ad!")
|
||||
.addLore(
|
||||
C.cYellow + "Earn a 250 Shard Reward",
|
||||
C.cYellow + "Earn a 100 Shard Reward",
|
||||
C.cWhite + "by checking out our partner's Advertisement",
|
||||
" ",
|
||||
C.cWhite + "You can watch the Ad once every 12 hours.",
|
||||
C.cWhite + "You can watch the Ad once every hour.",
|
||||
" ",
|
||||
C.cWhite + "Ads help us keep Mineplex awesome",
|
||||
C.cRedB + "Be sure to have your AdBlocker disabled!",
|
||||
|
@ -6,6 +6,7 @@ import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
/**
|
||||
* Listener for the Menu system
|
||||
@ -13,64 +14,70 @@ import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
public class MenuListener implements Listener
|
||||
{
|
||||
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent event)
|
||||
{
|
||||
String name = event.getInventory().getName();
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
Menu gui = Menu.get(player.getUniqueId());
|
||||
@EventHandler
|
||||
public void onClick(InventoryClickEvent event)
|
||||
{
|
||||
String name = event.getInventory().getName();
|
||||
Player player = (Player) event.getWhoClicked();
|
||||
Menu gui = Menu.get(player.getUniqueId());
|
||||
|
||||
if (gui == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (gui == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gui.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!gui.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Button button = gui.getButton(event.getRawSlot());
|
||||
Button button = gui.getButton(event.getRawSlot());
|
||||
|
||||
event.setCancelled(true);
|
||||
event.setResult(Event.Result.DENY);
|
||||
event.setCancelled(true);
|
||||
event.setResult(Event.Result.DENY);
|
||||
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (button == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(button.useItemClick())
|
||||
{
|
||||
button.onClick(player, event.getClick(), event.getCurrentItem());
|
||||
return;
|
||||
}
|
||||
if(button.useItemClick())
|
||||
{
|
||||
button.onClick(player, event.getClick(), event.getCurrentItem());
|
||||
return;
|
||||
}
|
||||
|
||||
button.onClick(player, event.getClick());
|
||||
}
|
||||
button.onClick(player, event.getClick());
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler
|
||||
public void onClose(InventoryCloseEvent event)
|
||||
{
|
||||
String name = event.getInventory().getName();
|
||||
Player player = (Player) event.getPlayer();
|
||||
Menu gui = Menu.get(player.getUniqueId());
|
||||
{
|
||||
String name = event.getInventory().getName();
|
||||
Player player = (Player) event.getPlayer();
|
||||
Menu gui = Menu.get(player.getUniqueId());
|
||||
|
||||
if (gui == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (gui == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!gui.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!gui.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if(gui.isUseClose())
|
||||
{
|
||||
gui.onClose(player);
|
||||
gui.setUseClose(false);
|
||||
}
|
||||
}
|
||||
if(gui.isUseClose())
|
||||
{
|
||||
gui.onClose(player);
|
||||
gui.setUseClose(false);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onQuit(PlayerQuitEvent event)
|
||||
{
|
||||
Menu.remove(event.getPlayer().getUniqueId());
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user