1212 * Hope it will make your streams funnier :)
1313 */
1414
15- namespace StreamIntegration
15+ namespace DonationIntegration
1616{
1717 [ ApiVersion ( 2 , 1 ) ]
1818 public class Plugin : TerrariaPlugin
@@ -37,22 +37,31 @@ public Plugin(Main game) : base(game)
3737 public override void Initialize ( )
3838 {
3939 /* Gets the ini config with auth code */
40- if ( File . Exists ( @FilePath ) )
40+ if ( Directory . Exists ( FolderPath ) )
4141 {
42- IniParser parser = new IniParser ( @FilePath ) ;
43- Config . authCode = parser . GetSetting ( "authconfig" , "authcode" ) ;
44- } else {
42+ if ( File . Exists ( @FilePath ) )
43+ {
44+ IniParser parser = new IniParser ( @FilePath ) ;
45+ Config . authCode = parser . GetSetting ( "DonationAlerts" , "authcode" ) ;
4546
46- }
47- /* ================================== */
48-
49- if ( Config . authCode . Length != 0 )
50- {
51- DAPI donateAPI = new DAPI ( ) ; // Initilization of the DonationAlerts API
52- random = new Random ( ) ;
47+ Debugger . messageOutput ( Config . authCode ) ;
48+
49+ DAPI donateAPI = new DAPI ( ) ; // Initilization of the DonationAlerts API
50+ random = new Random ( ) ;
51+
52+ parser . AddSetting ( " DonationAlerts" , "refreshtoken" , Config . refresh_token ) ;
53+ }
5354 } else {
55+ Directory . CreateDirectory ( FolderPath ) ;
56+
57+ string path = @FilePath ;
58+ string text = "[DonationAlerts]" + Environment . NewLine + "authcode=" ;
59+
60+ File . WriteAllText ( @FilePath , text ) ;
61+
5462 Debugger . errorOutput ( "You have to install authcode in your config file" ) ;
5563 }
64+ /* ================================== */
5665 }
5766
5867 protected override void Dispose ( bool disposing )
@@ -84,7 +93,7 @@ public static void handleDonate(string name, string currencyCode, int amount)
8493
8594 int badThings = random . Next ( 1 , 10 ) ;
8695
87- int playerID = 0 ;
96+ int playerID = random . Next ( 1 , TShock . Players . Length ) ;
8897 int spamCount = 30 ;
8998 int zombieCount = 30 ;
9099 int batsCount = 50 ;
@@ -95,8 +104,6 @@ public static void handleDonate(string name, string currencyCode, int amount)
95104 break ;
96105
97106 case 2 :
98- playerID = random . Next ( 1 , TShock . Players . Length ) ;
99-
100107 NPC eye = TShock . Utils . GetNPCById ( 4 ) ;
101108 TSPlayer . Server . SetTime ( false , 0.0 ) ;
102109 TSPlayer . Server . SpawnNPC ( eye . type , name , 1 , TShock . Players [ playerID ] . TileX , TShock . Players [ playerID ] . TileY ) ;
@@ -110,8 +117,6 @@ public static void handleDonate(string name, string currencyCode, int amount)
110117 break ;
111118
112119 case 4 :
113- playerID = random . Next ( 1 , TShock . Players . Length ) ;
114-
115120 NPC prime = TShock . Utils . GetNPCById ( 127 ) ;
116121 TSPlayer . Server . SetTime ( false , 0.0 ) ;
117122 TSPlayer . Server . SpawnNPC ( prime . type , name , 1 , TShock . Players [ playerID ] . TileX , TShock . Players [ playerID ] . TileY ) ;
@@ -122,7 +127,6 @@ public static void handleDonate(string name, string currencyCode, int amount)
122127 break ;
123128
124129 case 6 :
125- playerID = random . Next ( 1 , TShock . Players . Length ) ;
126130 TShock . Players [ playerID ] . Kick ( "SORRY FOR DONATION :)" , false , true ) ;
127131 break ;
128132
@@ -134,7 +138,6 @@ public static void handleDonate(string name, string currencyCode, int amount)
134138 break ;
135139
136140 case 8 :
137- playerID = random . Next ( 1 , TShock . Players . Length ) ;
138141
139142 for ( int i = 0 ; i < zombieCount ; i ++ )
140143 {
@@ -149,8 +152,6 @@ public static void handleDonate(string name, string currencyCode, int amount)
149152 break ;
150153
151154 case 10 :
152- playerID = random . Next ( 1 , TShock . Players . Length ) ;
153-
154155 for ( int i = 0 ; i < batsCount ; i ++ )
155156 {
156157 NPC zombies = TShock . Utils . GetNPCById ( 51 ) ;
0 commit comments