Skip to content

Commit 87f6199

Browse files
Cleanup + Better random
1 parent 4a97576 commit 87f6199

File tree

1 file changed

+4
-8
lines changed
  • src/main/java/dev/hause/squeakerbot/command/commands

1 file changed

+4
-8
lines changed

src/main/java/dev/hause/squeakerbot/command/commands/CoinFlip.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,21 @@
11
package dev.hause.squeakerbot.command.commands;
22

33
import java.util.Random;
4-
54
import dev.hause.squeakerbot.command.Command;
6-
import net.minecraft.network.play.client.CPacketChatMessage;
5+
import dev.hause.squeakerbot.util.ChatUtil;
76

87
public class CoinFlip extends Command {
98

9+
private static String[] outcomes = {"> [SqueakerBot] The coin flip results in Heads!", "> [SqueakerBot] The coin flip results in Tails!"};
10+
1011
public CoinFlip() {
1112
super("CoinFlip", new String[] {"CoinFlip", "Coin", "Flip"});
1213
}
1314

1415
@Override
1516
public void onRun() {
1617
Random random = new Random();
17-
int randomNum = random.nextInt((1 + 0) + 1) + 0;
18-
if(randomNum == 1) {
19-
mc.player.connection.sendPacket(new CPacketChatMessage("> [SqueakerBot] The coin flip results in Heads!"));
20-
} else if (randomNum == 0){
21-
mc.player.connection.sendPacket(new CPacketChatMessage("> [SqueakerBot] The coin flip results in Tails!"));
22-
}
18+
ChatUtil.sendChatMessage(outcomes[random.nextInt(2)]);
2319
}
2420

2521

0 commit comments

Comments
 (0)