Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Update to RandomPackage 16.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
BuildTools committed Nov 3, 2019
1 parent b89cff1 commit 9651e74
Show file tree
Hide file tree
Showing 8 changed files with 110 additions and 102 deletions.
98 changes: 50 additions & 48 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,50 +1,52 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.puyodead1</groupId>
<artifactId>RPBookGUI</artifactId>
<version>2.9.6</version>
<name>RPBookGUI</name>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>github</id>
<url>https://github.com/Puyodead1/maven/raw/repository/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.randomhashtags</groupId>
<artifactId>randompackage</artifactId>
<version>16.4.4</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>me.puyodead1</groupId>
<artifactId>RPBookGUI</artifactId>
<version>2.9.7</version>
<name>RPBookGUI</name>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>bungeecord-repo</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
<repository>
<id>github</id>
<url>https://github.com/Puyodead1/maven/raw/repository/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.randomhashtags</groupId>
<artifactId>randompackage</artifactId>
<version>16.5.0</version>
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

import io.github.puyodead1.rpbookgui.RPBookGUI;
import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils;
import me.randomhashtags.randompackage.RandomPackageAPI;
import me.randomhashtags.randompackage.addons.CustomEnchant;
import me.randomhashtags.randompackage.addons.EnchantRarity;
import me.randomhashtags.randompackage.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.util.RPStorage;

public class RarityInfo implements CommandExecutor {

private FileConfiguration rpbgConfig = RPBookGUI.getPlugin.getConfig();
private static RandomPackageAPI rpapi = new RandomPackageAPI();

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Expand All @@ -26,8 +25,8 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
|| !rpbgConfig.getBoolean("settings.use permissions")) {
String arg = args[0];
arg = arg.substring(0, 1).toUpperCase() + arg.substring(1, arg.length()).toLowerCase();
CustomEnchant ce = rpapi.valueOfCustomEnchant(arg);
EnchantRarity rarity = rpapi.valueOfEnchantRarity(ce);
CustomEnchant ce = RPStorage.valueOfCustomEnchant(arg);
EnchantRarity rarity = RPStorage.valueOfEnchantRarity(ce);
player.sendMessage(rarity != null
? RPBookGUIUtils
.ChatColor(rpbgConfig.getString("messages.rarity info").replace("{ENCHANT}", arg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;

import me.randomhashtags.randompackage.addons.CustomEnchant;
import me.randomhashtags.randompackage.addons.EnchantRarity;
import me.randomhashtags.randompackage.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.api.CustomEnchants;

public class EnchantConstructor {
Expand All @@ -29,7 +29,7 @@ public EnchantConstructor(CustomEnchant customEnchant, EnchantRarity enchantRari

enchants.put(customEnchant.getIdentifier(), this);

Bukkit.broadcastMessage("EnchantConstructor added: " + customEnchant.getIdentifier() + " " + enchantLevel);
// Bukkit.broadcastMessage("EnchantConstructor added: " + customEnchant.getIdentifier() + " " + enchantLevel);
}

public CustomEnchant getCustomEnchant() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@
import io.github.puyodead1.rpbookgui.ItemStacks;
import io.github.puyodead1.rpbookgui.RPBookGUI;
import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils;
import io.github.puyodead1.rpbookgui.Utils.UMaterial;
import me.randomhashtags.randompackage.RandomPackageAPI;
import me.randomhashtags.randompackage.addons.CustomEnchant;
import me.randomhashtags.randompackage.addons.EnchantRarity;
import me.randomhashtags.randompackage.utils.universal.UMaterial;
import me.randomhashtags.randompackage.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.util.RPStorage;

public class InventoryClick implements Listener {

private static RandomPackageAPI rpapi = new RandomPackageAPI();

@EventHandler
public void InventoryClickEvent(InventoryClickEvent e) {
if (!e.isCancelled() && e.getCurrentItem() != null && !e.getCurrentItem().getType().equals(Material.AIR)
Expand Down Expand Up @@ -109,7 +108,7 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
CustomEnchant ce = RPStorage.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
Expand All @@ -127,7 +126,7 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
CustomEnchant ce = RPStorage.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
Expand All @@ -144,7 +143,7 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
CustomEnchant ce = RPStorage.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
Expand All @@ -162,7 +161,7 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
CustomEnchant ce = RPStorage.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
Expand All @@ -179,7 +178,7 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
CustomEnchant ce = RPStorage.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
Expand All @@ -197,7 +196,7 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
CustomEnchant ce = RPStorage.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
Expand All @@ -214,8 +213,8 @@ public void InventoryClickEvent(InventoryClickEvent e) {
player.openInventory(Inventories.MainGUI());
}
if (e.getCurrentItem().getType().equals(UMaterial.match("BOOK").getMaterial())) {
CustomEnchant ce = rpapi.valueOfCustomEnchant(
ChatColor.stripColor(e.getCurrentItem().getItemMeta().getDisplayName()));
RPBookGUIUtils.SendDebugMessge(RPBookGUIUtils.FormatEnchantName(e.getCurrentItem()));
CustomEnchant ce = RPStorage.valueOfCustomEnchant(RPBookGUIUtils.FormatEnchantName(e.getCurrentItem()));
player.closeInventory();
player.openInventory(Inventories.Enchant(ce));
}
Expand All @@ -224,14 +223,14 @@ public void InventoryClickEvent(InventoryClickEvent e) {
/*
* Enchant inv click
*/
CustomEnchant enchant = rpapi.valueOfCustomEnchant(invTitle);
CustomEnchant enchant = RPStorage.valueOfCustomEnchant(invTitle);
if (enchant != null) {
e.setCancelled(true);
if (e.getCurrentItem().getItemMeta().getDisplayName()
.equals(ItemStacks.Back().getItemMeta().getDisplayName())
&& e.getCurrentItem().getType().equals(ItemStacks.Back().clone().clone().getType())) {
player.closeInventory();
switch (rpapi.valueOfEnchantRarity(enchant).getIdentifier()) {
switch (RPStorage.valueOfEnchantRarity(enchant).getIdentifier()) {
case "SIMPLE":
player.openInventory(Inventories.SimpleEnchants());
break;
Expand Down Expand Up @@ -260,8 +259,8 @@ public void InventoryClickEvent(InventoryClickEvent e) {
if (RPBookGUI.getPlugin.getConfig().getBoolean("settings.try to apply to item in hand")
&& RPBookGUIUtils.isOnCorrectItem(enchant, player.getItemInHand())) {

CustomEnchant ce = rpapi.valueOfCustomEnchant(ci);
EnchantRarity rarity = rpapi.valueOfEnchantRarity(ce);
CustomEnchant ce = RPStorage.valueOfCustomEnchant(ci);
EnchantRarity rarity = RPStorage.valueOfEnchantRarity(ce);

ItemStack o = player.getInventory().getItemInMainHand();
ItemMeta m = o.getItemMeta();
Expand Down Expand Up @@ -290,19 +289,19 @@ public void InventoryClickEvent(InventoryClickEvent e) {

for(EnchantConstructor ec : EnchantConstructor.getEnchants().values()) {
if(ec.getRevealItem() != ci) {
Bukkit.broadcastMessage("Removing EnchantConstructor: " + ec.getCustomEnchant().getIdentifier() + " " + ec.getEnchantLevel());
RPBookGUIUtils.SendDebugMessge("Removing EnchantConstructor: " + ec.getCustomEnchant().getIdentifier() + " " + ec.getEnchantLevel());
EnchantConstructor.getEnchants().remove(ec.getCustomEnchant().getIdentifier());
}
}

player.closeInventory();
player.openInventory(Inventories.SuccessDestroySelection(ci));
// player.getInventory().addItem(ci);
// if (!RPBookGUI.getPlugin.getConfig().getBoolean("settings.keep inventory open"))
// player.closeInventory();
// player.sendMessage(RPBookGUIUtils
// .ChatColor(RPBookGUI.getPlugin.getConfig().getString("messages.added book")
// .replace("{NAME}", ci.getItemMeta().getDisplayName())));
//player.closeInventory();
//player.openInventory(Inventories.SuccessDestroySelection(ci));
player.getInventory().addItem(ci);
if (!RPBookGUI.getPlugin.getConfig().getBoolean("settings.keep inventory open"))
player.closeInventory();
player.sendMessage(RPBookGUIUtils
.ChatColor(RPBookGUI.getPlugin.getConfig().getString("messages.added book")
.replace("{NAME}", ci.getItemMeta().getDisplayName())));
}
}
}
Expand Down
17 changes: 10 additions & 7 deletions src/main/java/io/github/puyodead1/rpbookgui/Inventories.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@

import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils;
import me.randomhashtags.randompackage.RandomPackageAPI;
import me.randomhashtags.randompackage.addons.CustomEnchant;
import me.randomhashtags.randompackage.addons.EnchantRarity;
import me.randomhashtags.randompackage.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.api.CustomEnchants;
import me.randomhashtags.randompackage.util.RPStorage;

public class Inventories {

private static RandomPackageAPI rpapi = new RandomPackageAPI();
// TODO: get the round method working, round to closest multiple of 9 depending
// on the number of enchants.

Expand Down Expand Up @@ -301,17 +301,20 @@ public static Inventory HeroicEnchants(ItemStack itemApplyTo) {
}

public static Inventory Enchant(CustomEnchant ce) {
EnchantRarity rarity = rpapi.valueOfEnchantRarity(ce);
EnchantRarity rarity = RPStorage.valueOfEnchantRarity(ce);
RPBookGUIUtils.SendDebugMessge("CE: " + ce.toString());
RPBookGUIUtils.SendDebugMessge("Name: " + ce.getName());
RPBookGUIUtils.SendDebugMessge("Colors: " + rarity.getNameColors());
Inventory inv = Bukkit.createInventory(null, 18, rarity.getNameColors() + ce.getName());
int x = 0;
for (int i = 1; i < ce.getMaxLevel() + 1; i++) {
ItemStack is = CustomEnchants.getCustomEnchants().getRevealedItem(ce, i, 100, 0, true, true).clone();
new EnchantConstructor(ce, rarity, i, 0, 0);
Bukkit.broadcastMessage("EnchantConstructor size: " + EnchantConstructor.getEnchants().size());
RPBookGUIUtils.SendDebugMessge("EnchantConstructor size: " + EnchantConstructor.getEnchants().size());
inv.setItem(x, is);
x++;
}
Bukkit.broadcastMessage("Final EnchantConstructor size: " + EnchantConstructor.getEnchants().size());
RPBookGUIUtils.SendDebugMessge("Final EnchantConstructor size: " + EnchantConstructor.getEnchants().size());
inv.setItem(17, ItemStacks.Back().clone());
return inv;
}
Expand Down Expand Up @@ -341,7 +344,7 @@ public static Inventory Settings() {

public static Inventory SuccessDestroySelection(ItemStack book) {
Inventory inv = Bukkit.createInventory(null, 54, "Success & Destry Configuration");
CustomEnchant ce = rpapi.valueOfCustomEnchant(book);
CustomEnchant ce = RPStorage.valueOfCustomEnchant(book);
// slot 10 - increase success
// slot 28 - decrease success
// slot 21 - book
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/io/github/puyodead1/rpbookgui/ItemStacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@
import org.bukkit.inventory.meta.ItemMeta;

import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils;
import io.github.puyodead1.rpbookgui.Utils.UMaterial;
import me.randomhashtags.randompackage.RandomPackage;
import me.randomhashtags.randompackage.RandomPackageAPI;
import me.randomhashtags.randompackage.addons.CustomEnchant;
import me.randomhashtags.randompackage.addons.EnchantRarity;
import me.randomhashtags.randompackage.utils.universal.UMaterial;
import me.randomhashtags.randompackage.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.util.RPStorage;

public class ItemStacks {

private static RandomPackageAPI rpapi = new RandomPackageAPI();

public static ItemStack SimpleCategoryItem() {
ItemStack item = new ItemStack(Material.BOOK);
Expand Down Expand Up @@ -174,15 +174,15 @@ public static ItemStack EnchantBook(CustomEnchant ce) {
ItemStack item = new ItemStack(Material.BOOK);
ItemMeta meta = item.getItemMeta();

EnchantRarity rarity = rpapi.valueOfEnchantRarity(ce);
EnchantRarity rarity = RPStorage.valueOfEnchantRarity(ce);

meta.setDisplayName(rarity.getNameColors() + ce.getName());
ArrayList<String> lore = new ArrayList<String>();
lore.addAll(ce.getLore());
String path = ce.getAppliesTo().toString().toLowerCase().replace(",", ";").replace("[", "").replace("]", "")
.replaceAll("\\p{Z}", "");
FileConfiguration config = YamlConfiguration
.loadConfiguration(new File(RandomPackage.getPlugin.getDataFolder(), "custom enchants.yml"));
.loadConfiguration(new File(RandomPackage.getPlugin.getDataFolder(), "custom enchants/_settings.yml"));
lore.add(RPBookGUIUtils.ChatColor(config.getString("enchant types." + path)));
meta.setLore(lore);
item.setItemMeta(meta);
Expand Down
Loading

0 comments on commit 9651e74

Please sign in to comment.