File tree Expand file tree Collapse file tree 2 files changed +10
-6
lines changed
Expand file tree Collapse file tree 2 files changed +10
-6
lines changed Original file line number Diff line number Diff line change @@ -59,15 +59,14 @@ private static void Rank(CommandArgs args)
5959 return ;
6060 }
6161
62- // TODO: Fix rank index if default registration group is not default
6362 if ( args . Parameters [ 0 ] == "up" )
6463 {
6564 if ( ! Utils . Util . CheckPermission ( Permissions . RankUp , args ) ) return ;
6665
6766 // rank index start at 1
68- var player = TShock . Players . FirstOrDefault ( x => x . Name . Equals ( args . Player . Name , StringComparison . OrdinalIgnoreCase ) ) ;
67+ var player = args . Player ;
6968 var regex = new Regex ( @"rank_(\d+)" ) ;
70- var match = regex . Match ( player ! . Account . Group ) ;
69+ var match = regex . Match ( player ! . Group . Name ) ;
7170
7271 int rank = match . Success ? int . Parse ( match . Groups [ 1 ] . Value ) : 0 ;
7372
@@ -88,6 +87,7 @@ private static void Rank(CommandArgs args)
8887 args . Player . SendErrorMessage ( $ "Your balance is not enough to level up. ({ Utils . Util . CurrencyFormat ( ( int ) ( rankCost - balance ) ) } more)") ;
8988 return ;
9089 }
90+
9191 // Give Player Rewards
9292 int highestRank = rankCache . GetValue ( args . Player . Name ) . HighestRank ;
9393
@@ -135,7 +135,11 @@ private static void Rank(CommandArgs args)
135135 }
136136
137137 // start at 1
138- int rank = rankDatabase . GetRank ( args . Player . Name ) ;
138+ var player = args . Player ;
139+ var regex = new Regex ( @"rank_(\d+)" ) ;
140+ var match = regex . Match ( player ! . Group . Name ) ;
141+
142+ int rank = match . Success ? int . Parse ( match . Groups [ 1 ] . Value ) : 0 ;
139143
140144 // start at 0
141145 int nextIndex = ( rank - 2 ) ;
Original file line number Diff line number Diff line change @@ -56,9 +56,9 @@ private void OnPlayerJoin(GreetPlayerEventArgs args)
5656 return ;
5757
5858 if ( ! cache . TryGetValue ( player . Name , out var plrRank ) ) return ;
59- var playerGroup = player . Account . Group ;
59+ var playerGroup = player . Group ;
6060 var regex = new Regex ( @"rank_(\d+)" ) ;
61- var match = regex . Match ( playerGroup ) ;
61+ var match = regex . Match ( playerGroup . Name ) ;
6262
6363 if ( match . Success )
6464 {
You can’t perform that action at this time.
0 commit comments