Add Data validation for received numbers and statistics. Prevent
crashing and exceptions during run time.
This commit is contained in:
parent
f4cd6cc20b
commit
92c381c01d
BIN
sigIRCv2.jar
BIN
sigIRCv2.jar
Binary file not shown.
@ -57,8 +57,8 @@ public class TwitchModule extends Module{
|
|||||||
FancyNumber viewers_numb;
|
FancyNumber viewers_numb;
|
||||||
FancyNumber followers_numb;
|
FancyNumber followers_numb;
|
||||||
FancyNumber views_numb;
|
FancyNumber views_numb;
|
||||||
Date uptime;
|
Date uptime = Calendar.getInstance().getTime();
|
||||||
String currentlyPlaying="";
|
String currentlyPlaying=" ";
|
||||||
final public static int ARROWTIMER = 3000;
|
final public static int ARROWTIMER = 3000;
|
||||||
public static BufferedImage UPARROWIMAGE;
|
public static BufferedImage UPARROWIMAGE;
|
||||||
public static BufferedImage DOWNARROWIMAGE;
|
public static BufferedImage DOWNARROWIMAGE;
|
||||||
@ -305,16 +305,23 @@ public class TwitchModule extends Module{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAllStreamStatistics(Stream data) {
|
private void UpdateAllStreamStatistics(Stream data) {
|
||||||
currentlyPlaying = data.getGame();
|
if (data!=null) {
|
||||||
uptime = data.getCreatedAt();
|
if (data.getGame()!=null && data.getGame().length()>0) {
|
||||||
viewers_numb.updateValue(data.getViewers());
|
currentlyPlaying = data.getGame();
|
||||||
views_numb.updateValue((int)data.getChannel().getViews());
|
}
|
||||||
followers_numb.updateValue(data.getChannel().getFollowers());
|
if (data.getCreatedAt()!=null) {
|
||||||
|
uptime = data.getCreatedAt();
|
||||||
|
}
|
||||||
|
viewers_numb.updateValue(data.getViewers());
|
||||||
|
views_numb.updateValue((int)data.getChannel().getViews());
|
||||||
|
followers_numb.updateValue(data.getChannel().getFollowers());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
return TwitchModule.streamOnline;
|
return TwitchModule.streamOnline;
|
||||||
//return false;
|
//TwitchModule.streamOnline=true;
|
||||||
|
//return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addFollower(ChannelFollow f, boolean streamOnline, boolean silent) {
|
protected void addFollower(ChannelFollow f, boolean streamOnline, boolean silent) {
|
||||||
@ -395,7 +402,9 @@ public class TwitchModule extends Module{
|
|||||||
g.fillPolygon(new int[]{(int)bounds.getX(),(int)(bounds.getX()+bounds.getWidth()),(int)(bounds.getX()+bounds.getWidth()),(int)bounds.getX()},
|
g.fillPolygon(new int[]{(int)bounds.getX(),(int)(bounds.getX()+bounds.getWidth()),(int)(bounds.getX()+bounds.getWidth()),(int)bounds.getX()},
|
||||||
new int[]{yoffset-4,yoffset-4,yoffset+16,yoffset+16},
|
new int[]{yoffset-4,yoffset-4,yoffset+16,yoffset+16},
|
||||||
4);
|
4);
|
||||||
DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, xoffset, yoffset+TextUtils.calculateStringBoundsFont(currentlyPlaying, sigIRC.panel.userFont).getHeight()/2+3, 2, g.getColor(), new Color(195,195,195), currentlyPlaying);xoffset+=TextUtils.calculateStringBoundsFont(currentlyPlaying, sigIRC.panel.userFont).getWidth()+16;
|
if (currentlyPlaying!=null && currentlyPlaying.length()>0) {
|
||||||
|
DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, xoffset, yoffset+TextUtils.calculateStringBoundsFont(currentlyPlaying, sigIRC.panel.userFont).getHeight()/2+3, 2, g.getColor(), new Color(195,195,195), currentlyPlaying);xoffset+=TextUtils.calculateStringBoundsFont(currentlyPlaying, sigIRC.panel.userFont).getWidth()+16;
|
||||||
|
}
|
||||||
Rectangle offsets = DrawUptime(g, xoffset, yoffset);xoffset+=offsets.getWidth();
|
Rectangle offsets = DrawUptime(g, xoffset, yoffset);xoffset+=offsets.getWidth();
|
||||||
offsets = views_numb.draw(g, xoffset, yoffset);xoffset+=offsets.getWidth();
|
offsets = views_numb.draw(g, xoffset, yoffset);xoffset+=offsets.getWidth();
|
||||||
offsets = followers_numb.draw(g, xoffset, yoffset);xoffset+=offsets.getWidth();
|
offsets = followers_numb.draw(g, xoffset, yoffset);xoffset+=offsets.getWidth();
|
||||||
@ -453,7 +462,9 @@ public class TwitchModule extends Module{
|
|||||||
//g.drawRect(img_startx, img_starty, image_size, image_size);
|
//g.drawRect(img_startx, img_starty, image_size, image_size);
|
||||||
g.drawImage(followerUserLogo, img_startx, img_starty, img_startx+image_size, img_starty+image_size, 0, 0, followerUserLogo.getWidth(), followerUserLogo.getHeight(), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerImgBackgroundColor), sigIRC.panel);
|
g.drawImage(followerUserLogo, img_startx, img_starty, img_startx+image_size, img_starty+image_size, 0, 0, followerUserLogo.getWidth(), followerUserLogo.getHeight(), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerImgBackgroundColor), sigIRC.panel);
|
||||||
}
|
}
|
||||||
DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, bounds.getX()+bounds.getWidth()-ticksPassed*3, bounds.getY()+follower_img.getHeight()+2+8, 2, TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerTextColor), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerShadowTextColor), announcedFollowerUser.getBio());
|
if (announcedFollowerUser.getBio()!=null && announcedFollowerUser.getBio().length()>0) {
|
||||||
|
DrawUtils.drawOutlineText(g, sigIRC.panel.userFont, bounds.getX()+bounds.getWidth()-ticksPassed*3, bounds.getY()+follower_img.getHeight()+2+8, 2, TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerTextColor), TextUtils.convertStringToColor(sigIRC.twitchmodule_newfollowerShadowTextColor), announcedFollowerUser.getBio());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user