15
15
import org .ini4j .Ini ;
16
16
import pokemon .PokeSpawn ;
17
17
import pokemon .Pokemon ;
18
- import raids .Raid ;
19
18
import raids .RaidSpawn ;
20
19
21
20
import java .io .File ;
25
24
import java .time .ZoneId ;
26
25
import java .util .*;
27
26
28
- import static raids .Raid .emotes ;
29
-
30
27
/**
31
28
* Created by Owner on 13/05/2017.
32
29
*/
@@ -48,7 +45,7 @@ public class Config {
48
45
private boolean startupMessage = false ;
49
46
private boolean countLocationsInLimits = true ;
50
47
private ScannerType scannerType = ScannerType .RocketMap ;
51
- private boolean useRmDb = true ;
48
+ private boolean useScanDb = true ;
52
49
private boolean raidsEnabled = true ;
53
50
private boolean pokemonEnabled = true ;
54
51
private boolean raidOrganisationEnabled = true ;
@@ -67,16 +64,19 @@ public class Config {
67
64
private String scanPort = "3306" ;
68
65
private String scanDbName ;
69
66
private String scanProtocol = "mysql" ;
67
+ private String scanUseSSL = "true" ;
70
68
private String nbUser ;
71
69
private String nbPass ;
72
70
private String nbIp ;
73
71
private String nbPort = "3306" ;
74
72
private String nbDbName ;
75
73
private String nbProtocol = "mysql" ;
74
+ private String nbUseSSL = "true" ;
76
75
private long pokePollingDelay = 2 ;
77
76
private long raidPollingDelay = 15 ;
78
77
private int pokemonThreads = 2 ;
79
78
private int raidThreads = 2 ;
79
+ private int maxStoredMessages = 1000000 ;
80
80
private NotificationLimit nonSupporterLimit = new NotificationLimit (null , null , null );
81
81
private ArrayList <String > GMAPS_KEYS = new ArrayList <>();
82
82
private HashMap <GeofenceIdentifier , String > raidChats = new HashMap <>();
@@ -109,7 +109,7 @@ public Config(Ini configIni, NovaBot novaBot) {
109
109
raidBosses .add (Integer .valueOf (s ));
110
110
}
111
111
112
- useRmDb = config .get ("useRmDb " , Boolean .class , useRmDb );
112
+ useScanDb = config .get ("useScanDb " , Boolean .class , useScanDb );
113
113
114
114
scannerType = ScannerType .fromString (config .get ("scannerType" ,scannerType .toString ()));
115
115
@@ -133,10 +133,12 @@ public Config(Ini configIni, NovaBot novaBot) {
133
133
134
134
countLocationsInLimits = config .get ("countLocationsInLimits" , Boolean .class , countLocationsInLimits );
135
135
136
-
137
136
logging = config .get ("logging" , Boolean .class , logging );
138
137
138
+
139
139
if (logging ) {
140
+ maxStoredMessages = config .get ("maxStoredMessages" ,Integer .class , maxStoredMessages );
141
+
140
142
roleLogId = config .get ("roleLogChannel" , roleLogId );
141
143
142
144
userUpdatesId = config .get ("userUpdatesChannel" , userUpdatesId );
@@ -180,6 +182,7 @@ public Config(Ini configIni, NovaBot novaBot) {
180
182
scanPort = scannerDb .get ("port" , scanPort );
181
183
scanDbName = scannerDb .get ("dbName" , scanDbName );
182
184
scanProtocol = scannerDb .get ("protocol" , scanProtocol );
185
+ scanUseSSL = scannerDb .get ("useSSL" ,scanUseSSL );
183
186
184
187
Ini .Section novabotDb = configIni .get ("novabot db" );
185
188
nbUser = novabotDb .get ("user" , nbUser );
@@ -188,6 +191,7 @@ public Config(Ini configIni, NovaBot novaBot) {
188
191
nbPort = novabotDb .get ("port" , nbPort );
189
192
nbDbName = novabotDb .get ("dbName" , nbDbName );
190
193
nbProtocol = novabotDb .get ("protocol" , nbProtocol );
194
+ nbUseSSL = novabotDb .get ("useSSL" ,nbUseSSL );
191
195
192
196
novaBot .novabotLog .info ("Finished loading config.ini" );
193
197
@@ -253,7 +257,11 @@ public ArrayList<String> findMatchingPresets(PokeSpawn pokeSpawn) {
253
257
public String formatStr (HashMap <String , String > properties , String toFormat ) {
254
258
final String [] str = {toFormat };
255
259
256
- properties .forEach ((key , value ) -> str [0 ] = str [0 ].replace (String .format ("<%s>" , key ), value ));
260
+ for (Map .Entry <String , String > stringStringEntry : properties .entrySet ()) {
261
+ str [0 ] = str [0 ].replace (String .format ("<%s>" , stringStringEntry .getKey ()), stringStringEntry .getValue ());
262
+ }
263
+
264
+ // properties.forEach((key, value) -> str[0] = str[0].replace(String.format("<%s>", key), value));
257
265
258
266
return str [0 ];
259
267
}
@@ -483,18 +491,33 @@ public boolean isRaidOrganisationEnabled() {
483
491
}
484
492
485
493
public void loadEmotes () {
486
- for (String type : Raid .TYPES ) {
494
+ for (String type : Types .TYPES ) {
487
495
List <Emote > found = novaBot .jda .getEmotesByName (type , true );
488
496
if (found .size () == 0 ) try {
489
497
novaBot .guild .getController ().createEmote (type , Icon .from (new File ("static/icons/" + type + ".png" ))).queue (emote ->
490
- emotes .put (type , emote ));
498
+ Types .emotes .put (type , emote ));
499
+ } catch (IOException e ) {
500
+ e .printStackTrace ();
501
+ }
502
+ else {
503
+ Types .emotes .put (type , found .get (0 ));
504
+ }
505
+ }
506
+ novaBot .novabotLog .info (String .format ("Finished loading type emojis: %s" , Types .emotes .toString ()));
507
+
508
+ for (Team team : Team .values ()) {
509
+ List <Emote > found = novaBot .jda .getEmotesByName (team .toString ().toLowerCase (), true );
510
+ if (found .size () == 0 ) try {
511
+ novaBot .guild .getController ().createEmote (team .toString ().toLowerCase (), Icon .from (new File ("static/icons/" + team .toString ().toLowerCase () + ".png" ))).queue (emote ->
512
+ Team .emotes .put (team , emote ));
491
513
} catch (IOException e ) {
492
514
e .printStackTrace ();
493
515
}
494
516
else {
495
- emotes .put (type , found .get (0 ));
517
+ Team . emotes .put (team , found .get (0 ));
496
518
}
497
519
}
520
+ novaBot .novabotLog .info (String .format ("Finished loading team emojis: %s" , Team .emotes .toString ()));
498
521
}
499
522
500
523
public boolean loggingEnabled () {
@@ -504,18 +527,23 @@ public boolean loggingEnabled() {
504
527
public static void main (String [] args ) {
505
528
NovaBot novaBot = new NovaBot ();
506
529
novaBot .setup ();
507
- System .out .println (novaBot .config .token );
530
+ System .out .println (Util .getCurrentTime (ZoneId .of ("+02:00" )));
531
+ novaBot .config .matchesFilter (novaBot .config .raidFilters .get ("raidfilter.json" ),new RaidSpawn (383 ,5 ,false ));
508
532
}
509
533
510
534
public boolean matchesFilter (JsonObject filter , RaidSpawn raidSpawn ) {
511
535
String searchStr = (raidSpawn .bossId >= 1 ) ? Pokemon .getFilterName (raidSpawn .bossId ) : "Egg" + raidSpawn .raidLevel ;
512
536
513
537
JsonElement raidFilter = searchFilter (filter , searchStr );
514
538
if (raidFilter == null ) {
539
+ RaidNotificationSender .notificationLog .info (String .format ("couldn't find filter for '%s'" ,searchStr ));
515
540
// System.out.println(String.format("raidFilter %s is null for %s for channel with id %s", channel.filterName, searchStr,channel.channelId));
516
541
raidFilter = searchFilter (filter , "Level" + raidSpawn .raidLevel );
517
542
518
- if (raidFilter == null ) return false ;
543
+ if (raidFilter == null ) {
544
+ RaidNotificationSender .notificationLog .info (String .format ("couldn't find filter for '%s'" ,"Level" + raidSpawn .raidLevel ));
545
+ return false ;
546
+ }
519
547
}
520
548
521
549
if (raidFilter .isJsonObject ()) {
@@ -653,8 +681,8 @@ public boolean useGeofences() {
653
681
return Geofencing .notEmpty ();
654
682
}
655
683
656
- public boolean useRmDb () {
657
- return useRmDb ;
684
+ public boolean useScanDb () {
685
+ return useScanDb ;
658
686
}
659
687
660
688
private void loadFilter (String filterName , HashMap <String , JsonObject > filterMap ) {
@@ -1127,4 +1155,16 @@ public String getNbProtocol() {
1127
1155
public String getScanProtocol () {
1128
1156
return scanProtocol ;
1129
1157
}
1158
+
1159
+ public String getScanUseSSL () {
1160
+ return scanUseSSL ;
1161
+ }
1162
+
1163
+ public String getNbUseSSL () {
1164
+ return nbUseSSL ;
1165
+ }
1166
+
1167
+ public int getMaxStoredMessages () {
1168
+ return maxStoredMessages ;
1169
+ }
1130
1170
}
0 commit comments