mirror of
https://git.krews.org/morningstar/Arcturus-Community.git
synced 2024-11-23 15:20:52 +01:00
Fixed ArrayIndexOutOfBoundsException in WordQuizCommand
See merge request morningstar/Arcturus-Community!304
This commit is contained in:
commit
87ead4c00a
@ -2,6 +2,9 @@ package com.eu.habbo.habbohotel.commands;
|
|||||||
|
|
||||||
import com.eu.habbo.Emulator;
|
import com.eu.habbo.Emulator;
|
||||||
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
import com.eu.habbo.habbohotel.gameclients.GameClient;
|
||||||
|
import com.eu.habbo.habbohotel.rooms.RoomChatMessageBubbles;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class WordQuizCommand extends Command {
|
public class WordQuizCommand extends Command {
|
||||||
public WordQuizCommand() {
|
public WordQuizCommand() {
|
||||||
@ -11,21 +14,21 @@ public class WordQuizCommand extends Command {
|
|||||||
@Override
|
@Override
|
||||||
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
public boolean handle(GameClient gameClient, String[] params) throws Exception {
|
||||||
if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) {
|
if (!gameClient.getHabbo().getHabboInfo().getCurrentRoom().hasActiveWordQuiz()) {
|
||||||
|
if(params.length == 1) {
|
||||||
|
gameClient.getHabbo().whisper(Emulator.getTexts().getValue("commands.description.cmd_word_quiz"), RoomChatMessageBubbles.ALERT);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
StringBuilder question = new StringBuilder();
|
StringBuilder question = new StringBuilder();
|
||||||
int duration = 60;
|
int duration = 60;
|
||||||
|
|
||||||
if (params.length > 2) {
|
try {
|
||||||
for (int i = 1; i < params.length - 1; i++) {
|
duration = Integer.parseInt(params[params.length-1]);
|
||||||
question.append(" ").append(params[i]);
|
params = Arrays.copyOf(params, params.length-1);
|
||||||
}
|
}
|
||||||
|
catch (Exception e) {}
|
||||||
|
|
||||||
try {
|
for (int i = 1; i < params.length; i++) {
|
||||||
duration = Integer.valueOf(params[params.length - 1]);
|
question.append(" ").append(params[i]);
|
||||||
} catch (Exception e) {
|
|
||||||
question.append(" ").append(params[params.length - 1]);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
question = new StringBuilder(params[1]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question.toString(), duration * 1000);
|
gameClient.getHabbo().getHabboInfo().getCurrentRoom().startWordQuiz(question.toString(), duration * 1000);
|
||||||
|
Loading…
Reference in New Issue
Block a user