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

Commit 1eaa1f4

Browse files
committed
Release 3.0
* Added compatibility for 1.13 * Allow empty text for items to keep lore and name from items.yml
1 parent eebdb3e commit 1eaa1f4

File tree

8 files changed

+45
-32
lines changed

8 files changed

+45
-32
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ For all this you only have to be familliar with BetonQuests events/conditions sy
88
Everything can be created by simply creating and modifying config files in YAML.
99

1010
## Features
11-
* Spigot **1.9**, **1.10**, **1.11** and **1.12** support
11+
* Spigot **1.9**, **1.10**, **1.11**, **1.12** and **1.13** support
1212
* Completly **costumizable** guis
1313
* **Display** or **hide** items in guis based on **conditions**
1414
* Run **events** when items are clicked, menus are opened or closed

docs/Menu.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ Each item has the following settings:
8888

8989
* `text`: *(list of strings)*
9090
In the text section you can specify the text that is displayed if you hover over the item.
91-
The lore and the display name of the item specified in `items.yml` will be overwritten by this.
91+
The lore and the display name of the item specified in `items.yml` will be overwritten by this.
92+
If no text is specified the items default name and lore from `items.yml` will be kept.
9293
You can use [formatting codes](https://minecraft.gamepedia.com/Formatting_codes) with `&` and [variables](https://github.com/Co0sh/BetonQuest/wiki/Variables-List)
9394

9495
**Example:**

pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>de.ungefroren</groupId>
88
<artifactId>RPGMenu</artifactId>
9-
<version>2.1</version>
9+
<version>3.0</version>
1010

1111
<repositories>
1212
<repository>
@@ -26,13 +26,13 @@
2626
<dependency>
2727
<groupId>org.spigotmc</groupId>
2828
<artifactId>spigot-api</artifactId>
29-
<version>1.12.2-R0.1-SNAPSHOT</version>
29+
<version>1.13.1-R0.1-SNAPSHOT</version>
3030
<scope>provided</scope>
3131
</dependency>
3232
<dependency>
3333
<groupId>org.bukkit</groupId>
3434
<artifactId>bukkit</artifactId>
35-
<version>1.12.2-R0.1-SNAPSHOT</version>
35+
<version>1.13.1-R0.1-SNAPSHOT</version>
3636
<scope>provided</scope>
3737
</dependency>
3838
<dependency>

src/main/java/de/ungefroren/rpgmenu/MenuItem.java

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -106,15 +106,18 @@ protected String of() throws Missing {
106106
this.item = new Item(itemID, amount);
107107
// load description
108108
this.descriptions = new HashMap<>();
109-
if (section.isConfigurationSection("text")) {
110-
for (String lang : section.getConfigurationSection("text").getKeys(false)) {
111-
this.descriptions.put(lang, new ItemDescription(this.pack, getStringList("text." + lang)));
109+
try {
110+
if (section.isConfigurationSection("text")) {
111+
for (String lang : section.getConfigurationSection("text").getKeys(false)) {
112+
this.descriptions.put(lang, new ItemDescription(this.pack, getStringList("text." + lang)));
113+
}
114+
if (!this.descriptions.containsKey(Config.getLanguage()))
115+
throw new Missing("text." + Config.getLanguage());
116+
} else {
117+
this.descriptions.put(Config.getLanguage(),
118+
new ItemDescription(this.pack, getStringList("text")));
112119
}
113-
if (!this.descriptions.containsKey(Config.getLanguage()))
114-
throw new Missing("text." + Config.getLanguage());
115-
} else {
116-
this.descriptions.put(Config.getLanguage(),
117-
new ItemDescription(this.pack, getStringList("text")));
120+
} catch (Missing missing) {
118121
}
119122
//load events
120123
this.left_click = new ArrayList<>();
@@ -216,15 +219,17 @@ public ItemStack generateItem(Player player) {
216219
String lang = BetonQuest.getInstance().getPlayerData(playerId).getLanguage();
217220
ItemStack item = this.item.generate(playerId);
218221
ItemMeta meta = item.getItemMeta();
219-
ItemDescription description = this.descriptions.get(lang);
220-
if (description == null) description = this.descriptions.get(Config.getLanguage());
221-
try {
222-
meta.setDisplayName(description.getDisplayName(playerId));
223-
meta.setLore(description.getLore(playerId));
224-
item.setItemMeta(meta);
225-
} catch (NullPointerException npe) {
226-
Log.error("Couldn't add custom text to §7" + id + "§4: No text for language §7" + Config.getLanguage() + "§4 " +
227-
"specified");
222+
if (!descriptions.isEmpty()) {
223+
ItemDescription description = this.descriptions.get(lang);
224+
if (description == null) description = this.descriptions.get(Config.getLanguage());
225+
try {
226+
meta.setDisplayName(description.getDisplayName(playerId));
227+
meta.setLore(description.getLore(playerId));
228+
item.setItemMeta(meta);
229+
} catch (NullPointerException npe) {
230+
Log.error("Couldn't add custom text to §7" + id + "§4: No text for language §7" + Config.getLanguage() + "§4 " +
231+
"specified");
232+
}
228233
}
229234
return item;
230235
} catch (QuestRuntimeException qre) {

src/main/java/de/ungefroren/rpgmenu/RPGMenu.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ public void onEnable() {
163163
new ReloadListener();
164164
} else {
165165
//load all data on first tick
166-
Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> reloadData());
166+
Bukkit.getScheduler().scheduleSyncDelayedTask(this, this::reloadData);
167167
}
168168
}
169169

src/main/java/de/ungefroren/rpgmenu/config/SimpleYMLSection.java

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -193,15 +193,21 @@ protected <T extends Enum<T>> T getEnum(String key, Class<T> enumType) throws Mi
193193
*/
194194
protected Material getMaterial(String key) throws Missing, Invalid {
195195
String s = this.getString(key);
196+
if (key.trim().matches("\\d+")) {
197+
throw new Invalid(key, "Material numbers can no longer be supported! Please use the names instead.");
198+
}
199+
Material m;
196200
try {
197-
Material m = Material.getMaterial(Integer.parseInt(s));
198-
if (m != null) return m;
199-
else throw new Invalid(key);
200-
} catch (NumberFormatException e) {
201-
Material m = Material.getMaterial(s.toUpperCase().replace(" ", "_"));
202-
if (m != null) return m;
203-
else throw new Invalid(key, "'" + s + "' isn't a material");
201+
m = Material.matchMaterial(s.replace(" ", "_"));
202+
if (m == null) {
203+
m = Material.matchMaterial(s.replace(" ", "_"), true);
204+
}
205+
} catch (LinkageError error) {
206+
//pre 1.13
207+
m = Material.getMaterial(s.toUpperCase().replace(" ", "_"));
204208
}
209+
if (m != null) return m;
210+
else throw new Invalid(key, "'" + s + "' isn't a material");
205211
}
206212

207213
/**

src/main/resources/plugin.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# RPGMenu plugin.yml - See https://bukkit.gamepedia.com/Plugin_YAML/de for more information
22
name: RPGMenu
3-
version: 2.1
3+
version: 3.0
4+
api-version: 1.13
45
description: 'A addon for BetonQuest which allows you to simply create your own guis by using events and items from BetonQuest.'
56
author: ungefroren
67
website: https://github.com/joblo2213/RPGMenu

version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.1
1+
3.0

0 commit comments

Comments
 (0)