@@ -2746,97 +2746,99 @@ public void execute(CommandSender sender, String[] args) {
27462746 }
27472747 });
27482748
2749- if (plugin .getShopFile ().isVoteShopEnabled ()) {
2750- plugin .getVoteCommand ().add (new CommandHandler (plugin , new String [] { "Shop" },
2751- "VotingPlugin.Commands.Vote.Shop|" + playerPerm , "Open VoteShop GUI" , false ) {
2749+ plugin .getVoteCommand ().add (new CommandHandler (plugin , new String [] { "Shop" },
2750+ "VotingPlugin.Commands.Vote.Shop|" + playerPerm , "Open VoteShop GUI" , false ) {
27522751
2753- @ Override
2754- public void execute (CommandSender sender , String [] args ) {
2755- new VoteShop (plugin , sender ,
2756- plugin .getVotingPluginUserManager ().getVotingPluginUser ((Player ) sender )).open ();
2752+ @ Override
2753+ public void execute (CommandSender sender , String [] args ) {
2754+ if (!plugin .getShopFile ().isVoteShopEnabled ()) {
2755+ sender .sendMessage (MessageAPI .colorize ("&cVote shop disabled" ));
2756+ return ;
27572757 }
2758- });
2759- plugin .getVoteCommand ().add (new CommandHandler (plugin , new String [] { "Shop" , "(Text)" },
2760- "VotingPlugin.Commands.Vote.Shop|" + playerPerm , "Open VoteShop GUI" , false ) {
2758+ new VoteShop (plugin , sender , plugin .getVotingPluginUserManager ().getVotingPluginUser ((Player ) sender ))
2759+ .open ();
27612760
2762- @ Override
2763- public void execute (CommandSender sender , String [] args ) {
2764- if (!plugin .getShopFile ().isVoteShopEnabled ()) {
2765- sender .sendMessage (MessageAPI .colorize ("&cVote shop disabled" ));
2766- return ;
2767- }
2761+ }
2762+ });
2763+ plugin .getVoteCommand ().add (new CommandHandler (plugin , new String [] { "Shop" , "(Text)" },
2764+ "VotingPlugin.Commands.Vote.Shop|" + playerPerm , "Open VoteShop GUI" , false ) {
27682765
2769- String identifier = args [1 ];
2770- Set <String > identifiers = plugin .getShopFile ().getShopIdentifiers ();
2771- if (ArrayUtils .containsIgnoreCase (identifiers , identifier )) {
2772- for (String ident : identifiers ) {
2773- if (ident .equalsIgnoreCase (args [1 ])) {
2774- identifier = ident ;
2775- }
2776- }
2766+ @ Override
2767+ public void execute (CommandSender sender , String [] args ) {
2768+ if (!plugin .getShopFile ().isVoteShopEnabled ()) {
2769+ sender .sendMessage (MessageAPI .colorize ("&cVote shop disabled" ));
2770+ return ;
2771+ }
27772772
2778- String perm = plugin . getShopFile (). getVoteShopPermission ( identifier ) ;
2779- boolean hasPerm = false ;
2780- if (perm . isEmpty ( )) {
2781- hasPerm = true ;
2782- } else {
2783- hasPerm = sender . hasPermission ( perm ) ;
2773+ String identifier = args [ 1 ] ;
2774+ Set < String > identifiers = plugin . getShopFile (). getShopIdentifiers () ;
2775+ if (ArrayUtils . containsIgnoreCase ( identifiers , identifier )) {
2776+ for ( String ident : identifiers ) {
2777+ if ( ident . equalsIgnoreCase ( args [ 1 ])) {
2778+ identifier = ident ;
27842779 }
2780+ }
27852781
2786- int limit = plugin .getShopFile ().getShopIdentifierLimit (identifier );
2787-
2788- VotingPluginUser user = plugin .getVotingPluginUserManager ()
2789- .getVotingPluginUser (sender .getName ());
2790- boolean limitPass = true ;
2791- if (limit > 0 ) {
2792-
2793- if (user .getVoteShopIdentifierLimit (identifier ) >= limit ) {
2794- limitPass = false ;
2795- }
2796- }
2782+ String perm = plugin .getShopFile ().getVoteShopPermission (identifier );
2783+ boolean hasPerm = false ;
2784+ if (perm .isEmpty ()) {
2785+ hasPerm = true ;
2786+ } else {
2787+ hasPerm = sender .hasPermission (perm );
2788+ }
27972789
2798- if (!plugin .getShopFile ().getVoteShopNotBuyable (identifier )) {
2799- if (hasPerm ) {
2800- if (plugin .getConfigFile ().isExtraVoteShopCheck ()) {
2801- user .cache ();
2802- }
2803- int points = plugin .getShopFile ().getShopIdentifierCost (identifier );
2804- if (identifier != null ) {
2790+ int limit = plugin .getShopFile ().getShopIdentifierLimit (identifier );
28052791
2806- if (limitPass ) {
2807- HashMap <String , String > placeholders = new HashMap <>();
2808- placeholders .put ("identifier" , identifier );
2809- placeholders .put ("points" , "" + points );
2810- placeholders .put ("limit" , "" + limit );
2811- if (user .removePoints (points , true )) {
2792+ VotingPluginUser user = plugin .getVotingPluginUserManager ().getVotingPluginUser (sender .getName ());
2793+ boolean limitPass = true ;
2794+ if (limit > 0 ) {
28122795
2813- plugin .getRewardHandler ().giveReward (user , plugin .getShopFile ().getData (),
2814- plugin .getShopFile ().getShopIdentifierRewardsPath (identifier ),
2815- new RewardOptions ().setPlaceholders (placeholders ));
2796+ if (user .getVoteShopIdentifierLimit (identifier ) >= limit ) {
2797+ limitPass = false ;
2798+ }
2799+ }
28162800
2817- user .sendMessage (PlaceholderUtils .replacePlaceHolder (
2818- plugin .getConfigFile ().getFormatShopPurchaseMsg (), placeholders ));
2819- if (limit > 0 ) {
2820- user .setVoteShopIdentifierLimit (identifier ,
2821- user .getVoteShopIdentifierLimit (identifier ) + 1 );
2822- }
2823- } else {
2824- user .sendMessage (PlaceholderUtils .replacePlaceHolder (
2825- plugin .getConfigFile ().getFormatShopFailedMsg (), placeholders ));
2801+ if (!plugin .getShopFile ().getVoteShopNotBuyable (identifier )) {
2802+ if (hasPerm ) {
2803+ if (plugin .getConfigFile ().isExtraVoteShopCheck ()) {
2804+ user .cache ();
2805+ }
2806+ int points = plugin .getShopFile ().getShopIdentifierCost (identifier );
2807+ if (identifier != null ) {
2808+
2809+ if (limitPass ) {
2810+ HashMap <String , String > placeholders = new HashMap <>();
2811+ placeholders .put ("identifier" , identifier );
2812+ placeholders .put ("points" , "" + points );
2813+ placeholders .put ("limit" , "" + limit );
2814+ if (user .removePoints (points , true )) {
2815+
2816+ plugin .getRewardHandler ().giveReward (user , plugin .getShopFile ().getData (),
2817+ plugin .getShopFile ().getShopIdentifierRewardsPath (identifier ),
2818+ new RewardOptions ().setPlaceholders (placeholders ));
2819+
2820+ user .sendMessage (PlaceholderUtils .replacePlaceHolder (
2821+ plugin .getConfigFile ().getFormatShopPurchaseMsg (), placeholders ));
2822+ if (limit > 0 ) {
2823+ user .setVoteShopIdentifierLimit (identifier ,
2824+ user .getVoteShopIdentifierLimit (identifier ) + 1 );
28262825 }
28272826 } else {
2828- user .sendMessage (plugin .getShopFile ().getVoteShopLimitReached ());
2827+ user .sendMessage (PlaceholderUtils .replacePlaceHolder (
2828+ plugin .getConfigFile ().getFormatShopFailedMsg (), placeholders ));
28292829 }
2830+ } else {
2831+ user .sendMessage (plugin .getShopFile ().getVoteShopLimitReached ());
28302832 }
2831-
28322833 }
2834+
28332835 }
2834- } else {
2835- sendMessage (sender , "&cWrong voteshop item" );
28362836 }
2837+ } else {
2838+ sendMessage (sender , "&cWrong voteshop item" );
28372839 }
2838- });
2839- }
2840+ }
2841+ });
28402842
28412843 plugin .getVoteCommand ().add (new CommandHandler (plugin , new String [] { "URL" , "(SiteName)" },
28422844 "VotingPlugin.Commands.Vote.URL.VoteSite" , "Open VoteURL GUI for VoteSite" , false ) {
0 commit comments