99import com .vortex .blackjack .table .BlackjackTable ;
1010import com .vortex .blackjack .table .TableManager ;
1111import com .vortex .blackjack .util .AsyncUtils ;
12+ import com .vortex .blackjack .util .GenericUtils ;
1213import com .vortex .blackjack .util .VersionChecker ;
1314import org .bukkit .command .Command ;
1415import org .bukkit .command .CommandSender ;
@@ -291,6 +292,47 @@ private void createDefaultMessagesFile(File messagesFile) {
291292 messagesConfig .set ("player-left-during-turn" , "&c%player% %reason% during their turn." );
292293 messagesConfig .set ("player-left-table" , "&c%player% %reason%." );
293294
295+ // Game action prompts
296+ messagesConfig .set ("game-action-prompt" , "&7Your turn: " );
297+ messagesConfig .set ("game-action-separator" , "&7 | " );
298+ messagesConfig .set ("post-game-prompt" , "&7Choose: " );
299+
300+ // Betting category labels
301+ messagesConfig .set ("betting-category-small" , "&7Small: " );
302+ messagesConfig .set ("betting-category-medium" , "&7Medium: " );
303+ messagesConfig .set ("betting-category-large" , "&7Large: " );
304+
305+ // Button configuration
306+ messagesConfig .set ("buttons.hit.text" , "&a&l[HIT]" );
307+ messagesConfig .set ("buttons.hit.command" , "/hit" );
308+ messagesConfig .set ("buttons.hit.hover" , "&eClick to take another card" );
309+
310+ messagesConfig .set ("buttons.stand.text" , "&c&l[STAND]" );
311+ messagesConfig .set ("buttons.stand.command" , "/stand" );
312+ messagesConfig .set ("buttons.stand.hover" , "&eClick to end your turn" );
313+
314+ messagesConfig .set ("buttons.double-down.text" , "&6&l[DOUBLE DOWN]" );
315+ messagesConfig .set ("buttons.double-down.command" , "/doubledown" );
316+ messagesConfig .set ("buttons.double-down.hover" , "&eClick to double your bet and take one card" );
317+
318+ messagesConfig .set ("buttons.play-again.text" , "&a&l[Play Again]" );
319+ messagesConfig .set ("buttons.play-again.command" , "/start" );
320+ messagesConfig .set ("buttons.play-again.hover" , "&eClick to start a new game" );
321+
322+ messagesConfig .set ("buttons.leave-table.text" , "&c&l[Leave Table]" );
323+ messagesConfig .set ("buttons.leave-table.command" , "/leave" );
324+ messagesConfig .set ("buttons.leave-table.hover" , "&eClick to leave the table" );
325+
326+ messagesConfig .set ("buttons.custom-bet.text" , "&b&l[CUSTOM BET]" );
327+ messagesConfig .set ("buttons.custom-bet.command" , "/bet " );
328+ messagesConfig .set ("buttons.custom-bet.hover" , "&eClick to enter custom amount" );
329+
330+ // Button color configurations
331+ messagesConfig .set ("buttons.small-bet-color" , "&a" ); // Green for small bets
332+ messagesConfig .set ("buttons.medium-bet-color" , "&e" ); // Yellow for medium bets
333+ messagesConfig .set ("buttons.large-bet-color" , "&c" ); // Red for large bets
334+ messagesConfig .set ("buttons.huge-bet-color" , "&d" ); // Pink for huge bets
335+
294336 messagesConfig .save (messagesFile );
295337
296338 } catch (IOException e ) {
@@ -495,33 +537,18 @@ private boolean handleStart(Player player) {
495537 }
496538
497539 private boolean handleHit (Player player ) {
498- BlackjackTable table = tableManager .getPlayerTable (player );
499- if (table != null ) {
500- table .hit (player );
501- } else {
502- player .sendMessage (configManager .getMessage ("not-at-table" ));
503- }
504- return true ;
540+ return GenericUtils .handleTableAction (player , tableManager , configManager , "hit" ,
541+ table -> table .hit (player ));
505542 }
506543
507544 private boolean handleStand (Player player ) {
508- BlackjackTable table = tableManager .getPlayerTable (player );
509- if (table != null ) {
510- table .stand (player );
511- } else {
512- player .sendMessage (configManager .getMessage ("not-at-table" ));
513- }
514- return true ;
545+ return GenericUtils .handleTableAction (player , tableManager , configManager , "stand" ,
546+ table -> table .stand (player ));
515547 }
516548
517549 private boolean handleDoubleDown (Player player ) {
518- BlackjackTable table = tableManager .getPlayerTable (player );
519- if (table != null ) {
520- table .doubleDown (player );
521- } else {
522- player .sendMessage (configManager .getMessage ("not-at-table" ));
523- }
524- return true ;
550+ return GenericUtils .handleTableAction (player , tableManager , configManager , "doubledown" ,
551+ table -> table .doubleDown (player ));
525552 }
526553
527554 private boolean handleBet (Player player , String [] args ) {
@@ -535,13 +562,11 @@ private boolean handleBet(Player player, String[] args) {
535562 return true ;
536563 }
537564
538- try {
539- int amount = Integer .parseInt (args [1 ]);
540- return processBet (player , amount );
541- } catch (NumberFormatException e ) {
542- player .sendMessage (configManager .getMessage ("invalid-amount" ));
565+ Integer amount = GenericUtils .parseIntegerArgument (args [1 ], player , configManager , "invalid-amount" );
566+ if (amount == null ) {
543567 return true ;
544568 }
569+ return processBet (player , amount );
545570 }
546571
547572 private boolean handleStats (Player player , String [] args ) {
@@ -590,17 +615,7 @@ private boolean handleStats(Player player, String[] args) {
590615
591616 // Load stats for the target player
592617 FileConfiguration statsConfig = YamlConfiguration .loadConfiguration (statsFile );
593- PlayerStats stats = new PlayerStats ();
594- String path = "players." + targetUUID + "." ;
595-
596- stats .setHandsWon (statsConfig .getInt (path + "handsWon" , 0 ));
597- stats .setHandsLost (statsConfig .getInt (path + "handsLost" , 0 ));
598- stats .setHandsPushed (statsConfig .getInt (path + "handsPushed" , 0 ));
599- stats .setCurrentStreak (statsConfig .getInt (path + "currentStreak" , 0 ));
600- stats .setBestStreak (statsConfig .getInt (path + "bestStreak" , 0 ));
601- stats .setTotalWinnings (statsConfig .getDouble (path + "totalWinnings" , 0.0 ));
602- stats .setBlackjacks (statsConfig .getInt (path + "blackjacks" , 0 ));
603- stats .setBusts (statsConfig .getInt (path + "busts" , 0 ));
618+ PlayerStats stats = GenericUtils .loadPlayerStats (statsConfig , targetUUID );
604619
605620 if (stats .getTotalHands () == 0 ) {
606621 if (targetUUID .equals (player .getUniqueId ())) {
@@ -611,21 +626,9 @@ private boolean handleStats(Player player, String[] args) {
611626 return true ;
612627 }
613628
614- String headerMessage = targetUUID .equals (player .getUniqueId ()) ?
615- configManager .getMessage ("stats-header" ) :
616- configManager .formatMessage ("stats-other-player-header" , "player" , targetName );
617-
618- // Use the new formatted messages from config
619- player .sendMessage (headerMessage );
620- player .sendMessage (configManager .formatMessage ("stats-hands-won" , "value" , stats .getHandsWon ()));
621- player .sendMessage (configManager .formatMessage ("stats-hands-lost" , "value" , stats .getHandsLost ()));
622- player .sendMessage (configManager .formatMessage ("stats-hands-pushed" , "value" , stats .getHandsPushed ()));
623- player .sendMessage (configManager .formatMessage ("stats-blackjacks" , "value" , stats .getBlackjacks ()));
624- player .sendMessage (configManager .formatMessage ("stats-busts" , "value" , stats .getBusts ()));
625- player .sendMessage (configManager .formatMessage ("stats-win-rate" , "value" , String .format ("%.1f" , stats .getWinRate ())));
626- player .sendMessage (configManager .formatMessage ("stats-current-streak" , "value" , stats .getCurrentStreak ()));
627- player .sendMessage (configManager .formatMessage ("stats-best-streak" , "value" , stats .getBestStreak ()));
628- player .sendMessage (configManager .formatMessage ("stats-total-winnings" , "value" , String .format ("%.2f" , stats .getTotalWinnings ())));
629+ // Use generic stats display method
630+ GenericUtils .sendStatsToPlayer (player , stats , configManager , targetName ,
631+ targetUUID .equals (player .getUniqueId ()));
629632
630633 return true ;
631634 }
@@ -743,17 +746,7 @@ private void savePlayerStats() {
743746 FileConfiguration statsConfig = YamlConfiguration .loadConfiguration (statsFile );
744747
745748 for (Map .Entry <UUID , PlayerStats > entry : playerStats .entrySet ()) {
746- String path = "players." + entry .getKey () + "." ;
747- PlayerStats stats = entry .getValue ();
748-
749- statsConfig .set (path + "handsWon" , stats .getHandsWon ());
750- statsConfig .set (path + "handsLost" , stats .getHandsLost ());
751- statsConfig .set (path + "handsPushed" , stats .getHandsPushed ());
752- statsConfig .set (path + "currentStreak" , stats .getCurrentStreak ());
753- statsConfig .set (path + "bestStreak" , stats .getBestStreak ());
754- statsConfig .set (path + "totalWinnings" , stats .getTotalWinnings ());
755- statsConfig .set (path + "blackjacks" , stats .getBlackjacks ());
756- statsConfig .set (path + "busts" , stats .getBusts ());
749+ GenericUtils .savePlayerStats (statsConfig , entry .getKey (), entry .getValue ());
757750 }
758751
759752 try {
0 commit comments