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.
- Optimize performance for loading enchants - Reduce code size - Added ability to read custom enchant categories - Added dynamic sized inventories (inventory sizes for enchants will be the correct sizes no matter if new enchants are made) - Better error catching - Other small improvements
- Loading branch information
Showing
14 changed files
with
1,480 additions
and
815 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
173 changes: 111 additions & 62 deletions
173
src/main/java/io/github/puyodead1/rpbookgui/Commands/BookGUICommand.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
62 changes: 62 additions & 0 deletions
62
src/main/java/io/github/puyodead1/rpbookgui/Events/EnchantInventoryClick.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,62 @@ | ||
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.RPBookGUI; | ||
import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils; | ||
import me.randomhashtags.randompackage.util.RPStorage; | ||
import me.randomhashtags.randompackage.util.universal.UMaterial; | ||
|
||
public class EnchantInventoryClick 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 (enchants.keySet().contains( | ||
Strip(invTitle).toUpperCase().replace(" ", "_"))) { | ||
e.setCancelled(true); | ||
|
||
if (item.getType() | ||
.equals(UMaterial.match("BOOK").getMaterial())) { | ||
// Note: there was the old enchant constructor removal here, | ||
// but | ||
// doesnt seem needed as there is only one enchant now | ||
if (RPBookGUI.getPlugin.getConfig().getBoolean( | ||
"settings.use success destroy configuration")) { | ||
player.getOpenInventory().close(); | ||
player.openInventory( | ||
Inventories.SuccessDestroySelection( | ||
RPStorage.valueOfCustomEnchant(item))); | ||
} else { | ||
player.getInventory().addItem(item); | ||
if (!RPBookGUI.getPlugin.getConfig() | ||
.getBoolean("settings.keep inventory open")) | ||
player.getOpenInventory().close(); | ||
player.sendMessage(RPBookGUIUtils | ||
.ChatColor(RPBookGUI.getPlugin.getConfig() | ||
.getString("messages.added book") | ||
.replace("{NAME}", item.getItemMeta() | ||
.getDisplayName()))); | ||
} | ||
} else { | ||
player.getOpenInventory().close(); | ||
player.openInventory(Inventories.MainGUI()); | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.