Skip to content
This repository has been archived by the owner on Dec 5, 2021. It is now read-only.

Commit

Permalink
Fix default config & NPE
Browse files Browse the repository at this point in the history
Former-commit-id: 6945dfd
  • Loading branch information
cakoyo committed Jan 27, 2020
1 parent 9d0775c commit 0b7e740
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 6 deletions.
21 changes: 20 additions & 1 deletion src/main/java/org/maxgamer/quickshop/Shop/DisplayItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

package org.maxgamer.quickshop.Shop;

import com.bekvon.bukkit.residence.commands.contract;
import com.google.common.collect.Collections2;
import com.google.common.collect.Lists;
import com.google.gson.Gson;
Expand Down Expand Up @@ -208,22 +209,40 @@ static DisplayType getNowUsing(@Nullable ItemStack item) {
*/
// type id such as 0, 1, 2, 3.
List<?> typeSections =
QuickShop.instance.getConfig().getList("shop.display-type-specifics");
QuickShop.instance.getConfig().getList("shop.display-type-specifics", Lists.newArrayList());
if (typeSections.isEmpty()) {
return DisplayType.fromID(QuickShop.instance.getConfig().getInt("shop.display-type"));
}
for (Object typeSection : typeSections) {
if (typeSection == null) {
continue;
}
// id as key
Util.debugLog(typeSection.toString() + " @ LEVEL 1, " + typeSection.getClass().getName());
if (typeSection instanceof Map) {
Map<?, ?> itemSections = Map.class.cast(typeSection);
for (Entry<?, ?> itemSection : itemSections.entrySet()) {
if (itemSection == null) {
continue;
}
// list
Util.debugLog(itemSection.toString() + " @ LEVEL 2, " + itemSection.getClass().getName());
if (itemSection.getValue() instanceof List) {
List<?> infoSections = List.class.cast(itemSection.getValue());
if (infoSections == null) {
continue;
}
for (Object $infoSection : infoSections) {
if ($infoSection == null) {
continue;
}
// custom name as key
Util.debugLog($infoSection.toString() + " @ LEVEL 3, " + $infoSection.getClass().getName());
if ($infoSection instanceof Map) {
for (Object infoSectiont : Map.class.cast($infoSection).values()) {
if (infoSectiont == null) {
continue;
}
Map<?, Object> infoSection = Map.class.cast(infoSectiont);
Util.debugLog(infoSection.toString() + " @ LEVEL 4, " + infoSection.getClass().getName());
List<Material> type = Lists.newArrayList();
Expand Down
20 changes: 15 additions & 5 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -176,14 +176,24 @@ shop:
#The display type you want use.
#0=Normal Dropped Item, 1=ArmorStand
display-type: 0


# Custom display type depending on item meta
display-type-specifics:
- 0:
- 'test':
type: GLASS
- customType0:
type: AIR
lore: []
strict: true
- customType1:
type:
- AIR_VOID
- AIR_CAVE
- 1:
- 'test2':
type: GRASS
- demo:
type: AIR_VOID
lore:
- A demo item lore
- Another demo lore

#Allow quickshop auto despawn-spawn the display when no-player or player close the shop.
display-auto-despawn: false
Expand Down

0 comments on commit 0b7e740

Please sign in to comment.