This repository has been archived by the owner on Sep 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added the inventory click event for the settings inventory - Temporarily disabled the settings inventory
- Loading branch information
Showing
3 changed files
with
76 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
src/main/java/io/github/puyodead1/rpbookgui/Events/SettingsInventoryClick.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package io.github.puyodead1.rpbookgui.Events; | ||
|
||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.inventory.ClickType; | ||
import org.bukkit.event.inventory.InventoryClickEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
|
||
import io.github.puyodead1.rpbookgui.Inventories; | ||
import io.github.puyodead1.rpbookgui.ItemStacks; | ||
import io.github.puyodead1.rpbookgui.RPBookGUI; | ||
import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils; | ||
|
||
public class SettingsInventoryClick extends RPBookGUIUtils implements Listener { | ||
|
||
@EventHandler | ||
public void InventoryClickEvent(InventoryClickEvent e) { | ||
if (!e.isCancelled() && e.getCurrentItem() != null | ||
&& !e.getCurrentItem().getType().equals(Material.AIR) | ||
&& e.getClickedInventory() != null && e.getCursor() != null | ||
&& !e.getClick().equals(ClickType.DOUBLE_CLICK)) { | ||
ItemStack item = e.getCurrentItem(); | ||
Player player = (Player) e.getWhoClicked(); | ||
String invTitle = e.getView().getTitle(); | ||
|
||
if (invTitle.equals("RPBookGUI Settings")) { | ||
e.setCancelled(true); | ||
|
||
if (item.getItemMeta().getDisplayName().equals(ItemStacks.Back() | ||
.clone().getItemMeta().getDisplayName())) | ||
player.getOpenInventory().close(); | ||
if (item.getItemMeta().getDisplayName() | ||
.equals(ItemStacks.KeepMenuOpenSetting().clone() | ||
.getItemMeta().getDisplayName())) { | ||
RPBookGUI.getPlugin.getConfig().set("settings.keepinvopen", | ||
!RPBookGUI.getPlugin.getConfig() | ||
.getBoolean("settings.keepinvopen")); | ||
|
||
player.getOpenInventory().close(); | ||
player.openInventory(Inventories.settingsInventory()); | ||
} | ||
if (item.getItemMeta().getDisplayName() | ||
.equals(ItemStacks.UsePermissionsSetting().clone() | ||
.getItemMeta().getDisplayName())) { | ||
RPBookGUI.getPlugin.getConfig().set( | ||
"settings.usepermissions", | ||
!RPBookGUI.getPlugin.getConfig() | ||
.getBoolean("settings.usepermissions")); | ||
|
||
player.getOpenInventory().close(); | ||
player.openInventory(Inventories.settingsInventory()); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters