11using Rocket . Components ;
22using Rocket . RocketAPI ;
3+ using Rocket . Logging ;
34using SDG ;
45using Steamworks ;
56using UnityEngine ;
67using System ;
8+ using System . Collections . Generic ;
79
810namespace Zamirathe_HomeCommand
911{
@@ -28,19 +30,52 @@ private void Load()
2830 public void GoHome ( Vector3 bedPos , byte bedRot , Player player )
2931 {
3032 this . waitrestricted = HomeCommand . Instance . Configuration . TeleportWait ;
31- this . waittime = HomeCommand . Instance . Configuration . TeleportWaitTime ;
3233 this . movementrestricted = HomeCommand . Instance . Configuration . MovementRestriction ;
3334 this . p = player ;
3435 this . bedPos = Vector3 . up + bedPos ;
3536 this . bedRot = bedRot ;
3637
3738 if ( this . waitrestricted )
3839 {
39- // We have to wait to teleport.
40+ // We have to wait to teleport now find out how long
4041 this . LastCalledHomeCommand = DateTime . Now ;
42+ if ( HomeCommand . Instance . WaitGroups . ContainsKey ( "all" ) )
43+ {
44+ HomeCommand . Instance . WaitGroups . TryGetValue ( "all" , out this . waittime ) ;
45+ }
46+ else
47+ {
48+ if ( player . SteamChannel . SteamPlayer . IsAdmin && HomeCommand . Instance . WaitGroups . ContainsKey ( "admin" ) )
49+ {
50+ HomeCommand . Instance . WaitGroups . TryGetValue ( "admin" , out this . waittime ) ;
51+ }
52+ else
53+ {
54+ // Either not an admin or they don't get special wait restrictions.
55+ List < Group > hg = player . GetGroups ( ) ;
56+ byte [ ] time2 = new byte [ hg . Count ] ;
57+ for ( byte g = 0 ; g < hg . Count ; g ++ )
58+ {
59+ Group hgr = hg [ g ] ;
60+ HomeCommand . Instance . WaitGroups . TryGetValue ( hgr . Id , out time2 [ g ] ) ;
61+ if ( time2 [ g ] <= 0 )
62+ {
63+ time2 [ g ] = 60 ;
64+ }
65+ }
66+ Array . Sort ( time2 ) ;
67+ // Take the lowest time.
68+ this . waittime = time2 [ 0 ] ;
69+ }
70+ }
4171 if ( this . movementrestricted )
4272 {
4373 this . LastCalledHomePos = this . transform . position ;
74+ RocketChatManager . Say ( player . SteamChannel . SteamPlayer . SteamPlayerID . CSteamID , String . Format ( HomeCommand . Instance . Configuration . FoundBedWaitNoMoveMsg , player . name , this . waittime ) ) ;
75+ }
76+ else
77+ {
78+ RocketChatManager . Say ( player . SteamChannel . SteamPlayer . SteamPlayerID . CSteamID , String . Format ( HomeCommand . Instance . Configuration . FoundBedNowWaitMsg , player . name , this . waittime ) ) ;
4479 }
4580 }
4681 else
0 commit comments