1414import me .refracdevelopment .simplegems .utilities .chat .RyMessageUtils ;
1515import me .refracdevelopment .simplegems .utilities .chat .StringPlaceholders ;
1616import org .bukkit .Bukkit ;
17+ import org .bukkit .configuration .ConfigurationSection ;
1718import org .bukkit .entity .Player ;
1819import org .bukkit .inventory .ItemStack ;
1920
@@ -39,55 +40,57 @@ public GemShopItem(String category, String item) {
3940 }
4041
4142 private void setupMenuItemData () {
42- this .material = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getString (getCategory () + ".items." + getItem () + ".material" );
43- this .durability = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getInt (getCategory () + ".items." + getItem () + ".durability" );
44- this .customModelData = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getInt (getCategory () + ".items." + getItem () + ".customModelData" );
45- this .name = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getString (getCategory () + ".items." + getItem () + ".name" );
46- this .lore = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getStringList (getCategory () + ".items." + getItem () + ".lore" );
47- this .actions = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getStringList (getCategory () + ".items." + getItem () + ".action.actions" );
48- this .commands = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getStringList (getCategory () + ".items." + getItem () + ".commands" );
49- this .messageEnabled = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".message.enabled" );
50- this .broadcastMessage = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".message.broadcast" );
51- this .messages = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getStringList (getCategory () + ".items." + getItem () + ".message.text" );
52- this .cost = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getDouble (getCategory () + ".items." + getItem () + ".cost" );
53- this .slot = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getInt (getCategory () + ".items." + getItem () + ".slot" );
54- this .permission = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getString (getCategory () + ".items." + getItem () + ".permission" , "" );
55- this .amount = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getInt (getCategory () + ".items." + getItem () + ".amount" );
56-
57- if (SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".head-database" ) != null )
58- this .headDatabase = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".head-database" , false );
43+ ConfigurationSection section = SimpleGems .getInstance ().getMenus ().GEM_SHOP_CATEGORIES ;
44+
45+ this .material = section .getString (getCategory () + ".items." + getItem () + ".material" );
46+ this .durability = section .getInt (getCategory () + ".items." + getItem () + ".durability" );
47+ this .customModelData = section .getInt (getCategory () + ".items." + getItem () + ".customModelData" );
48+ this .name = section .getString (getCategory () + ".items." + getItem () + ".name" );
49+ this .lore = section .getStringList (getCategory () + ".items." + getItem () + ".lore" );
50+ this .actions = section .getStringList (getCategory () + ".items." + getItem () + ".action.actions" );
51+ this .commands = section .getStringList (getCategory () + ".items." + getItem () + ".commands" );
52+ this .messageEnabled = section .getBoolean (getCategory () + ".items." + getItem () + ".message.enabled" );
53+ this .broadcastMessage = section .getBoolean (getCategory () + ".items." + getItem () + ".message.broadcast" );
54+ this .messages = section .getStringList (getCategory () + ".items." + getItem () + ".message.text" );
55+ this .cost = section .getDouble (getCategory () + ".items." + getItem () + ".cost" );
56+ this .slot = section .getInt (getCategory () + ".items." + getItem () + ".slot" );
57+ this .permission = section .getString (getCategory () + ".items." + getItem () + ".permission" , "" );
58+ this .amount = section .getInt (getCategory () + ".items." + getItem () + ".amount" );
59+
60+ if (section .get (getCategory () + ".items." + getItem () + ".head-database" ) != null )
61+ this .headDatabase = section .getBoolean (getCategory () + ".items." + getItem () + ".head-database" , false );
5962 else
6063 this .headDatabase = false ;
6164
62- if (SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".skulls" ) != null )
63- this .skulls = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".skulls" , false );
65+ if (section .get (getCategory () + ".items." + getItem () + ".skulls" ) != null )
66+ this .skulls = section .getBoolean (getCategory () + ".items." + getItem () + ".skulls" , false );
6467 else
6568 this .skulls = false ;
6669
67- if (SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".customData" ) != null )
68- this .customData = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".customData" , false );
70+ if (section .get (getCategory () + ".items." + getItem () + ".customData" ) != null )
71+ this .customData = section .getBoolean (getCategory () + ".items." + getItem () + ".customData" , false );
6972 else
7073 this .customData = false ;
7174
72- this .skullOwner = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getString (getCategory () + ".items." + getItem () + ".skullOwner" );
75+ this .skullOwner = section .getString (getCategory () + ".items." + getItem () + ".skullOwner" );
7376
74- if (SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".glow" ) != null )
75- this .glow = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".glow" , false );
77+ if (section .get (getCategory () + ".items." + getItem () + ".glow" ) != null )
78+ this .glow = section .getBoolean (getCategory () + ".items." + getItem () + ".glow" , false );
7679 else
7780 this .glow = false ;
7881
79- if (SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".action.enabled" ) != null )
80- this .action = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".action.enabled" , false );
82+ if (section .get (getCategory () + ".items." + getItem () + ".action.enabled" ) != null )
83+ this .action = section .getBoolean (getCategory () + ".items." + getItem () + ".action.enabled" , false );
8184 else
8285 this .action = false ;
8386
84- if (SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".buyable" ) != null )
85- this .buyable = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".buyable" , true );
87+ if (section .get (getCategory () + ".items." + getItem () + ".buyable" ) != null )
88+ this .buyable = section .getBoolean (getCategory () + ".items." + getItem () + ".buyable" , true );
8689 else
8790 this .buyable = true ;
8891
89- if (SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .get (getCategory () + ".items." + getItem () + ".itemsAdder" ) != null )
90- this .itemsAdder = SimpleGems . getInstance (). getMenus (). GEM_SHOP_CATEGORIES .getBoolean (getCategory () + ".items." + getItem () + ".itemsAdder" , false );
92+ if (section .get (getCategory () + ".items." + getItem () + ".itemsAdder" ) != null )
93+ this .itemsAdder = section .getBoolean (getCategory () + ".items." + getItem () + ".itemsAdder" , false );
9194 else
9295 this .itemsAdder = false ;
9396 }
@@ -97,42 +100,36 @@ public void sendMessage(Player player) {
97100 return ;
98101
99102 if (isBroadcastMessage ()) {
100- getMessages ().forEach (message -> {
101- RyMessageUtils .broadcast (player , message
102- .replace ("%item%" , getName ())
103- .replace ("%cost%" , Methods .formatDecimal (getCost ()))
104- .replace ("%price%" , String .valueOf (getCost ())));
105- });
103+ getMessages ().forEach (message -> RyMessageUtils .broadcast (player , message
104+ .replace ("%item%" , getName ())
105+ .replace ("%cost%" , Methods .formatDecimal (getCost ()))
106+ .replace ("%price%" , String .valueOf (getCost ()))));
106107 return ;
107108 }
108109
109- getMessages ().forEach (message -> {
110- RyMessageUtils .sendPlayer (player , message
111- .replace ("%item%" , getName ())
112- .replace ("%cost%" , Methods .formatDecimal (getCost ()))
113- .replace ("%price%" , String .valueOf (getCost ()))
114- );
115- });
110+ getMessages ().forEach (message -> RyMessageUtils .sendPlayer (player , message
111+ .replace ("%item%" , getName ())
112+ .replace ("%cost%" , Methods .formatDecimal (getCost ()))
113+ .replace ("%price%" , String .valueOf (getCost ()))
114+ ));
116115 }
117116
118117 public void runCommands (Player player ) {
119- getCommands ().forEach (command -> {
120- Bukkit .dispatchCommand (Bukkit .getConsoleSender (), Placeholders .setPlaceholders (player , command
121- .replace ("%item%" , getName ())
122- .replace ("%cost%" , String .valueOf (getCost ()))
123- .replace ("%price%" , String .valueOf (getCost ()))
124- ));
125- });
118+ getCommands ().forEach (command ->
119+ Bukkit .dispatchCommand (Bukkit .getConsoleSender (), Placeholders .setPlaceholders (player , command
120+ .replace ("%item%" , getName ())
121+ .replace ("%cost%" , String .valueOf (getCost ()))
122+ .replace ("%price%" , String .valueOf (getCost ())))
123+ ));
126124 }
127125
128126 public void runActions (Player player ) {
129- for (String action : getActions ()) {
130- SimpleGems .getInstance ().getActionManager ().execute (player , Placeholders .setPlaceholders (player , action
131- .replace ("%item%" , getName ())
132- .replace ("%cost%" , String .valueOf (getCost ()))
133- .replace ("%price%" , String .valueOf (getCost ()))
134- ));
135- }
127+ getActions ().forEach (action ->
128+ SimpleGems .getInstance ().getActionManager ().execute (player , Placeholders .setPlaceholders (player , action
129+ .replace ("%item%" , getName ())
130+ .replace ("%cost%" , String .valueOf (getCost ()))
131+ .replace ("%price%" , String .valueOf (getCost ())))
132+ ));
136133 }
137134
138135 public ItemStack getItem (Player player ) {
@@ -166,7 +163,8 @@ public ItemStack getItem(Player player) {
166163 getLore ().forEach (line -> finalItem .addLoreLine (RyMessageUtils .translate (player , line
167164 .replace ("%item%" , getName ())
168165 .replace ("%cost%" , String .valueOf (getCost ()))
169- .replace ("%price%" , String .valueOf (getCost ())))));
166+ .replace ("%price%" , String .valueOf (getCost ()))))
167+ );
170168 finalItem .setDurability (getDurability ());
171169
172170 if (!isSkulls () && !isHeadDatabase ())
0 commit comments