Now using SecureRandom.
This commit is contained in:
parent
ec753fdbd6
commit
7db6d76eea
3 changed files with 29 additions and 27 deletions
|
@ -34,7 +34,7 @@ package net.thauvin.erik.mobibot.modules;
|
||||||
import net.thauvin.erik.mobibot.Mobibot;
|
import net.thauvin.erik.mobibot.Mobibot;
|
||||||
import net.thauvin.erik.mobibot.Utils;
|
import net.thauvin.erik.mobibot.Utils;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Dice module.
|
* The Dice module.
|
||||||
|
@ -66,7 +66,7 @@ final public class Dice extends AbstractModule {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
|
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
|
||||||
final Random r = new Random();
|
final SecureRandom r = new SecureRandom();
|
||||||
|
|
||||||
int i = r.nextInt(6) + 1;
|
int i = r.nextInt(6) + 1;
|
||||||
int y = r.nextInt(6) + 1;
|
int y = r.nextInt(6) + 1;
|
||||||
|
|
|
@ -39,6 +39,7 @@ import java.io.BufferedReader;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Joke module.
|
* The Joke module.
|
||||||
|
@ -90,7 +91,8 @@ final public class Joke extends AbstractModule {
|
||||||
final URLConnection conn = url.openConnection();
|
final URLConnection conn = url.openConnection();
|
||||||
|
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
try (final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()))) {
|
try (final BufferedReader reader =
|
||||||
|
new BufferedReader(new InputStreamReader(conn.getInputStream(), StandardCharsets.UTF_8))) {
|
||||||
String line;
|
String line;
|
||||||
while ((line = reader.readLine()) != null) {
|
while ((line = reader.readLine()) != null) {
|
||||||
sb.append(line);
|
sb.append(line);
|
||||||
|
|
|
@ -33,9 +33,9 @@ package net.thauvin.erik.mobibot.modules;
|
||||||
|
|
||||||
import net.thauvin.erik.mobibot.Mobibot;
|
import net.thauvin.erik.mobibot.Mobibot;
|
||||||
|
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Ping module.
|
* The Ping module.
|
||||||
|
@ -78,7 +78,7 @@ public class Ping extends AbstractModule {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
|
public void commandResponse(final Mobibot bot, final String sender, final String args, final boolean isPrivate) {
|
||||||
final Random r = new Random();
|
final SecureRandom r = new SecureRandom();
|
||||||
|
|
||||||
bot.action(PINGS.get(r.nextInt(PINGS.size())));
|
bot.action(PINGS.get(r.nextInt(PINGS.size())));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue