Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ test {
}

group = 'randomeventhelper'
version = '3.2.0'
version = '3.2.1'

tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.StringSelection;
Expand Down Expand Up @@ -57,6 +56,9 @@ public class SurpriseExamHelper extends PluginModule
@Inject
private ChatMessageManager chatMessageManager;

@Inject
private Gson gson;

@Inject
private SurpriseExamOverlay overlay;

Expand All @@ -80,11 +82,7 @@ public class SurpriseExamHelper extends PluginModule

private List<ExamQuestion> examQuestionHistory;

private static final Gson EXAM_QUESTION_GSON_LOGGER = new GsonBuilder()
.registerTypeAdapterFactory(ExamQuestion.gsonTypeAdapterFactory())
.serializeNulls()
.setPrettyPrinting()
.create();
private Gson gsonExamQuestionLogger;

private static final int[] PATTERNCARDS_INTERFACEIDS_AVAILABLE_CARD_MODELS = {
InterfaceID.PatternCards.CARD_0,
Expand Down Expand Up @@ -153,6 +151,11 @@ public void onStartUp()
this.currentExamQuestion = null;
this.examQuestionHistory = null;
this.relationshipSystem = new OSRSItemRelationshipSystem();
this.gsonExamQuestionLogger = this.gson.newBuilder()
.registerTypeAdapterFactory(ExamQuestion.gsonTypeAdapterFactory())
.serializeNulls()
.setPrettyPrinting()
.create();

if (this.isLoggedIn())
{
Expand Down Expand Up @@ -185,6 +188,7 @@ public void onShutdown()
this.currentExamQuestion = null;
this.examQuestionHistory = null;
this.relationshipSystem = null;
this.gsonExamQuestionLogger = null;
}

@Override
Expand Down Expand Up @@ -474,7 +478,7 @@ public void onCommandExecuted(CommandExecuted executedCommand)
// In case people still use the old command name, lets add support both
if (executedCommand.getCommand().equalsIgnoreCase("exportexampuzzle") || executedCommand.getCommand().equalsIgnoreCase("exportexampuzzles"))
{
String json = EXAM_QUESTION_GSON_LOGGER.toJson(this.examQuestionHistory != null ? this.examQuestionHistory : ImmutableList.of());
String json = gsonExamQuestionLogger.toJson(this.examQuestionHistory != null ? this.examQuestionHistory : ImmutableList.of());
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents(new StringSelection(json), null);
log.info(json);
Expand Down