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

Commit

Permalink
[2.9.8-rc5] Updates and Fixes
Browse files Browse the repository at this point in the history
- Fixed NullPointers from RANDOM enchant category being loaded when it shouldn't have.
- Update RandomPackage to 16.5.2
  • Loading branch information
Puyodead1 committed Nov 7, 2019
1 parent 268cdee commit 3ed9f96
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 56 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>me.puyodead1</groupId>
<artifactId>RPBookGUI</artifactId>
<version>2.9.8-rc4</version>
<version>2.9.8-rc5</version>
<name>RPBookGUI</name>
<repositories>
<repository>
Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>me.randomhashtags</groupId>
<artifactId>randompackage</artifactId>
<version>16.5.1</version>
<version>16.5.2</version>
<scope>provided</scope>
</dependency>
</dependencies>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
package io.github.puyodead1.rpbookgui.Commands;

import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
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.addon.EnchantRarity;
import me.randomhashtags.randompackage.util.addon.FileCustomEnchant;
import me.randomhashtags.randompackage.util.addon.FileEnchantRarity;
import me.randomhashtags.randompackage.util.addon.RPAddon;

public class BookGUICommand implements CommandExecutor {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@

import java.util.HashMap;

import org.bukkit.Bukkit;
import org.bukkit.inventory.ItemStack;

import io.github.puyodead1.rpbookgui.Utils.RPBookGUIUtils;
import me.randomhashtags.randompackage.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.api.CustomEnchants;
Expand Down
2 changes: 0 additions & 2 deletions src/main/java/io/github/puyodead1/rpbookgui/ItemStacks.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,8 @@
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.addon.CustomEnchant;
import me.randomhashtags.randompackage.addon.EnchantRarity;
import me.randomhashtags.randompackage.util.RPStorage;

public class ItemStacks {

Expand Down
42 changes: 23 additions & 19 deletions src/main/java/io/github/puyodead1/rpbookgui/RPBookGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@

import io.github.puyodead1.rpbookgui.Commands.BookGUICommand;
import io.github.puyodead1.rpbookgui.Commands.RarityInfo;
import io.github.puyodead1.rpbookgui.Events.EnchantInventoryClick;
import io.github.puyodead1.rpbookgui.Events.MainInventoryClick;
import io.github.puyodead1.rpbookgui.Events.RarityInventoryClick;
import io.github.puyodead1.rpbookgui.Events.SettingsInventoryClick;
import io.github.puyodead1.rpbookgui.Events.SuccessDestroyInventoryClick;
import io.github.puyodead1.rpbookgui.Events.EnchantInventoryClick;
import io.github.puyodead1.rpbookgui.Events.MainInventoryClick;
import io.github.puyodead1.rpbookgui.Utils.FileCustomEnchant;
import io.github.puyodead1.rpbookgui.Utils.FileEnchantRarity;
import io.github.puyodead1.rpbookgui.Utils.MetricsLite;
Expand Down Expand Up @@ -128,6 +128,7 @@ public void InitEvents() {
/**
* Enable Metrics
*/
@SuppressWarnings("unused")
public void InitMetrics() {
long started = System.currentTimeMillis();
MetricsLite metrics = new MetricsLite(this);
Expand All @@ -150,29 +151,32 @@ private void InitRarities() {
if (folder.exists()) {
for (File f : folder.listFiles()) {
if (f.isDirectory()) {
final File[] files = new File(p + separator + f.getName())
.listFiles();
if (files != null) {
FileEnchantRarity rarity = null;
final List<File> F = Arrays.asList(files);
for (File k : F) {
if (k.getName().contains("_settings")) {
rarity = new FileEnchantRarity(f, k);
if(!f.getName().contains("RANDOM")) {
final File[] files = new File(p + separator + f.getName())
.listFiles();
if (files != null) {
FileEnchantRarity rarity = null;
final List<File> F = Arrays.asList(files);
for (File k : F) {
if (k.getName().contains("_settings")) {
rarity = new FileEnchantRarity(f, k);
}
}
}
if (rarity != null) {
for (File ff : files) {
if (!ff.getName().startsWith("_settings")) {
final FileCustomEnchant e = new FileCustomEnchant(
ff);
if(e.isEnabled()) {
rarity.getEnchants().add(e);
RPBookGUIUtils.enchants.put(e.getIdentifier(), e);
if (rarity != null) {
for (File ff : files) {
if (!ff.getName().startsWith("_settings")) {
final FileCustomEnchant e = new FileCustomEnchant(
ff);
if(e.isEnabled()) {
rarity.getEnchants().add(e);
RPBookGUIUtils.enchants.put(e.getIdentifier(), e);
}
}
}
}
}
}
// Note: Random ce category causes errors, so dont load it
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,71 +29,76 @@ public FileEnchantRarity(File folder, File f) {
enchants = new ArrayList<>();
addEnchantRarity(this);
}

public String getIdentifier() {
return folder.getName();
}

public String[] getRevealedEnchantRarities() {
return yml.getString("reveals enchant rarities").split(";");
}

public List<String> getRevealedEnchantMsg() {
if (revealedEnchantMsg == null)
revealedEnchantMsg = api.colorizeListString(
yml.getStringList("reveal enchant msg"));
revealedEnchantMsg = api.colorizeListString(yml.getStringList("reveal enchant msg"));
return revealedEnchantMsg;
}

public ItemStack getRevealItem() {
if (revealItem == null)
revealItem = api.d(yml, "reveal item");
return getClone(revealItem, null);
}

public ItemStack getRevealedItem() {
if (revealedItem == null)
revealedItem = api.d(yml, "revealed item");
return getClone(revealedItem, null);
}

public String getNameColors() {
return ChatColor.translateAlternateColorCodes('&',
yml.getString("revealed item.name colors"));
return ChatColor.translateAlternateColorCodes('&', yml.getString("revealed item.name colors"));
}

public String getApplyColors() {
return ChatColor.translateAlternateColorCodes('&',
yml.getString("revealed item.apply colors"));
return ChatColor.translateAlternateColorCodes('&', yml.getString("revealed item.apply colors"));
}

public boolean percentsAddUpto100() {
return yml.getBoolean("settings.success+destroy=100");
}

public String getSuccess() {
return ChatColor.translateAlternateColorCodes('&',
yml.getString("settings.success"));
return ChatColor.translateAlternateColorCodes('&', yml.getString("settings.success"));
}

public String getDestroy() {
return ChatColor.translateAlternateColorCodes('&',
yml.getString("settings.destroy"));
return ChatColor.translateAlternateColorCodes('&', yml.getString("settings.destroy"));
}

public List<String> getLoreFormat() {
if (loreFormat == null)
loreFormat = api.colorizeListString(
yml.getStringList("settings.lore format"));
loreFormat = api.colorizeListString(yml.getStringList("settings.lore format"));
return loreFormat;
}

public int getSuccessSlot() {
return getLoreFormat().indexOf("{SUCCESS}");
}

public int getDestroySlot() {
return getLoreFormat().indexOf("{DESTROY}");
}

public Firework getFirework() {
if (firework == null) {
final String[] a = yml.getString("revealed item.firework")
.split(":");
firework = api.createFirework(
FireworkEffect.Type.valueOf(a[0].toUpperCase()),
api.getColor(a[1]), api.getColor(a[2]),
Integer.parseInt(a[3]));
final String[] a = yml.getString("revealed item.firework").split(":");
firework = api.createFirework(FireworkEffect.Type.valueOf(a[0].toUpperCase()), api.getColor(a[1]),
api.getColor(a[2]), Integer.parseInt(a[3]));
}
return firework;
}

public List<CustomEnchant> getEnchants() {
return enchants;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import java.util.Map;

import org.bukkit.Color;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: RPBookGUI
version: 2.9.8-rc4
version: 2.9.8-rc5
author: Puyodead1
main: io.github.puyodead1.rpbookgui.RPBookGUI
depend: [RandomPackage]
Expand Down

0 comments on commit 3ed9f96

Please sign in to comment.