diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4323eb4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,27 @@ +# Compiled class file +*.class + +# Log file +*.log + +# BlueJ files +*.ctxt + +# Mobile Tools for Java (J2ME) +.mtj.tmp/ + +# Package Files # +*.jar +*.war +*.nar +*.ear +*.zip +*.tar.gz +*.rar + +# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml +hs_err_pid* + +.gradle/ +.idea/ +build \ No newline at end of file diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml deleted file mode 100644 index 5555dd2..0000000 --- a/.idea/codeStyleSettings.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 34c19d0..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 01c7096..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__aopalliance_aopalliance_1_0.xml b/.idea/libraries/Gradle__aopalliance_aopalliance_1_0.xml deleted file mode 100644 index dfd1af5..0000000 --- a/.idea/libraries/Gradle__aopalliance_aopalliance_1_0.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_flowpowered_flow_math_1_0_3.xml b/.idea/libraries/Gradle__com_flowpowered_flow_math_1_0_3.xml deleted file mode 100644 index 5c95809..0000000 --- a/.idea/libraries/Gradle__com_flowpowered_flow_math_1_0_3.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__com_flowpowered_flow_noise_1_0_1_SNAPSHOT.xml b/.idea/libraries/Gradle__com_flowpowered_flow_noise_1_0_1_SNAPSHOT.xml deleted file mode 100644 index 893e81b..0000000 --- a/.idea/libraries/Gradle__com_flowpowered_flow_noise_1_0_1_SNAPSHOT.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml b/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml deleted file mode 100644 index 62012ea..0000000 --- a/.idea/libraries/Gradle__javax_inject_javax_inject_1.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 2c9b45b..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 189204e..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/uiDesigner.xml b/.idea/uiDesigner.xml deleted file mode 100644 index e96534f..0000000 --- a/.idea/uiDesigner.xml +++ /dev/null @@ -1,124 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/AnswerTrivia.java b/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/AnswerTrivia.java index 7d8f5da..1c77bcb 100644 --- a/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/AnswerTrivia.java +++ b/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/AnswerTrivia.java @@ -1,7 +1,7 @@ package com.mcsimonflash.sponge.triviaquest.commands; +import com.mcsimonflash.sponge.triviaquest.managers.Config; import com.mcsimonflash.sponge.triviaquest.managers.Trivia; - import com.mcsimonflash.sponge.triviaquest.managers.Util; import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandResult; @@ -14,9 +14,9 @@ public class AnswerTrivia implements CommandExecutor { @Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { if (Trivia.trivia == null) { - throw new CommandException(Util.toText("Oh no! There isn't an active trivia question!")); + throw new CommandException(Util.toText(Config.commandAnswerTriviaNoActive)); } else if (!Trivia.processAnswer(src, args.getOne("answer").get())) { - src.sendMessage(Trivia.prefix.concat(Util.toText("Oh no! That wasn't the answer :("))); + src.sendMessage(Trivia.prefix.concat(Util.toText(Config.commandAnswerTriviaWrongAnswer))); } return CommandResult.success(); } diff --git a/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/PostTrivia.java b/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/PostTrivia.java index 7af1e52..34ab2a0 100644 --- a/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/PostTrivia.java +++ b/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/PostTrivia.java @@ -1,7 +1,7 @@ package com.mcsimonflash.sponge.triviaquest.commands; +import com.mcsimonflash.sponge.triviaquest.managers.Config; import com.mcsimonflash.sponge.triviaquest.managers.Trivia; - import com.mcsimonflash.sponge.triviaquest.managers.Util; import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandResult; @@ -14,7 +14,7 @@ public class PostTrivia implements CommandExecutor { @Override public CommandResult execute(CommandSource src, CommandContext args) throws CommandException { if (Trivia.trivia != null) { - throw new CommandException(Util.toText("A trivia question is currently active!")); + throw new CommandException(Util.toText(Config.answerAlreadyActive)); } else if (Trivia.runnerTask != null) { Trivia.runnerTask.cancel(); } diff --git a/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/ToggleRunner.java b/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/ToggleRunner.java index 30dce5e..7506759 100644 --- a/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/ToggleRunner.java +++ b/src/main/java/com/mcsimonflash/sponge/triviaquest/commands/ToggleRunner.java @@ -1,9 +1,8 @@ package com.mcsimonflash.sponge.triviaquest.commands; +import com.mcsimonflash.sponge.triviaquest.managers.Config; import com.mcsimonflash.sponge.triviaquest.managers.Trivia; - import com.mcsimonflash.sponge.triviaquest.managers.Util; -import org.spongepowered.api.command.CommandException; import org.spongepowered.api.command.CommandResult; import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.command.args.CommandContext; @@ -16,7 +15,7 @@ public CommandResult execute(CommandSource src, CommandContext args) { if (Trivia.runnerEnabled = !Trivia.runnerEnabled) { Trivia.startRunner(); } - src.sendMessage(Trivia.prefix.concat(Util.toText("The trivia runner has been &d" + (Trivia.runnerEnabled ? "enabled" : "disabled") + "&f!"))); + src.sendMessage(Trivia.prefix.concat(Util.toText(Trivia.runnerEnabled ? Config.commandTriviaRunnerEnable : Config.commandTriviaRunnerDisable))); return CommandResult.success(); } diff --git a/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Config.java b/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Config.java index b07144b..01c1950 100644 --- a/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Config.java +++ b/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Config.java @@ -35,6 +35,15 @@ public class Config { public static String completionAnswer; public static String scrambleQuestion; public static String scrambleAnswer; + public static String answerAlreadyActive; + public static String getAnswer; + public static String answerCorrect; + public static String commandTriviaRunnerEnable; + public static String commandTriviaRunnerDisable; + public static String commandAnswerTriviaNoActive; + public static String commandAnswerTriviaWrongAnswer; + public static String onlyPlayerCanReceive; + public static String timesUp; public static List enabledPacks = Lists.newArrayList(); public static Map rewardCommands = Maps.newHashMap(); @@ -59,6 +68,18 @@ public static void readConfig() { enableTriviaCount = root.getNode("config", "enable-trivia-count").getInt(0); triviaInterval = root.getNode("config", "trivia-interval").getInt(300); triviaLength = root.getNode("config", "trivia-length").getInt(30); + + // messages + getAnswer = root.getNode("message", "get-answer").getString("The answer was "); + answerAlreadyActive = root.getNode("message", "answer-already-active").getString("A trivia question is currently active!"); + answerCorrect = root.getNode("message", "answer-correct").getString("&d&f got it! The word was ."); + timesUp = root.getNode("message", "times-up").getString("Times up! The word was , Better luck next time!"); + onlyPlayerCanReceive = root.getNode("message", "only-player-can-receive").getString("Sorry! Only a player can receive a reward!"); + commandTriviaRunnerEnable = root.getNode("message", "command-trivia-runner-enable").getString("The trivia runner has been &aEnable&f"); + commandTriviaRunnerDisable = root.getNode("message", "command-trivia-runner-disable").getString("The trivia runner has been &cDisable&f"); + commandAnswerTriviaNoActive = root.getNode("message", "command-answer-trivia-no-active").getString("Oh no! There isn't an active trivia question!"); + commandAnswerTriviaWrongAnswer = root.getNode("message", "command-answer-trivia-wrong-answer").getString("Oh no! That's the wrong answer."); + if (triviaInterval < 1 || triviaLength < 1) { TriviaQuest.getLogger().error("Interval and length must be at least 1! | Interval:[" + triviaInterval + "] Length:[" + triviaLength + "]"); triviaInterval = 300; diff --git a/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Trivia.java b/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Trivia.java index a86d0bb..a3a1a1a 100644 --- a/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Trivia.java +++ b/src/main/java/com/mcsimonflash/sponge/triviaquest/managers/Trivia.java @@ -1,7 +1,6 @@ package com.mcsimonflash.sponge.triviaquest.managers; import com.google.common.collect.Lists; - import com.mcsimonflash.sponge.triviaquest.TriviaQuest; import org.spongepowered.api.Sponge; import org.spongepowered.api.command.CommandSource; @@ -58,7 +57,7 @@ public static void askQuestion(boolean override) { public static void closeQuestion(boolean answered) { if (!answered) { - Sponge.getServer().getBroadcastChannel().send(prefix.concat(Util.toText("Times up! " + (Config.showAnswers ? trivia.getAnswer() : "Better luck next time!")))); + Sponge.getServer().getBroadcastChannel().send(prefix.concat(Util.toText(Config.timesUp.replace("", trivia.getAnswer())))); } trivia = null; if (runnerTask != null) { @@ -80,14 +79,15 @@ public static boolean shouldTriviaRun(boolean override) { public static boolean processAnswer(CommandSource src, String answer) { if (trivia.checkAnswer(answer)) { - Sponge.getServer().getBroadcastChannel().send(prefix.concat(Util.toText("&d" + src.getName() + "&f got it! " + (Config.showAnswers ? trivia.getAnswer() : "Better luck next time!")))); + + Sponge.getServer().getBroadcastChannel().send(prefix.concat(Util.toText(Config.answerCorrect.replace("", src.getName()).replace("", trivia.getAnswer())))); if (Sponge.getServer().getOnlinePlayers().size() >= Config.enableRewardsCount) { String rewardCmd = Util.getReward().orElse(null); if (rewardCmd != null && !rewardCmd.isEmpty()) { if (src instanceof Player) { Sponge.getCommandManager().process(Sponge.getServer().getConsole(), rewardCmd.replace("", src.getName())); } else { - src.sendMessage(prefix.concat(Util.toText("Sorry! Only a player can receive a reward!"))); + src.sendMessage(prefix.concat(Util.toText(Config.onlyPlayerCanReceive))); } } } diff --git a/src/main/java/com/mcsimonflash/sponge/triviaquest/objects/Question.java b/src/main/java/com/mcsimonflash/sponge/triviaquest/objects/Question.java index fca526f..f0b3ca0 100644 --- a/src/main/java/com/mcsimonflash/sponge/triviaquest/objects/Question.java +++ b/src/main/java/com/mcsimonflash/sponge/triviaquest/objects/Question.java @@ -1,5 +1,7 @@ package com.mcsimonflash.sponge.triviaquest.objects; +import com.mcsimonflash.sponge.triviaquest.managers.Config; + import java.util.List; public class Question implements Trivia { @@ -19,7 +21,7 @@ public String getQuestion() { @Override public String getAnswer() { - return "The answer" + (Answers.size() > 1 ? "s were " : " was ") + String.join(", ", Answers); + return Config.getAnswer.replace("", String.join(", ", Answers)); } @Override diff --git a/src/main/resources/assets/triviaquest/triviaquest.core b/src/main/resources/assets/triviaquest/triviaquest.core index 386ae5b..1e9f2cb 100644 --- a/src/main/resources/assets/triviaquest/triviaquest.core +++ b/src/main/resources/assets/triviaquest/triviaquest.core @@ -31,6 +31,21 @@ config { # Prefix before trivia messages. trivia-prefix="&8&l[&5TriviaQuest&8&l]&f " } + +message { + # (use for the word) + get-answer="The answer was " + answer-already-active="A trivia question is currently active!" + # (use for the player, use for the answer) + answer-correct="&d&f got it! The word was " + only-player-can-receive="Sorry! Only a player can receive a reward!" + times-up="Times up! The word was , Better luck next time!" + command-trivia-runner-enable="The trivia runner has been &aEnable&f" + command-trivia-runner-disable="The trivia runner has been &cDisable&f" + command-answer-trivia-no-active="Oh no! There isn't an active trivia question!" + command-answer-trivia-wrong-answer="Oh no! That's the wrong answer." +} + # List of enabled Trivia Packs # enabled-packs=[ "trivia"