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
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ java {
}

group = 'me.playbosswar.com'
version = '8.11.5'
version = '8.11.6'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -70,7 +70,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer'
version = '8.11.5'
version = '8.11.6'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java17-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.11.5'
version = '8.11.6'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -63,7 +63,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java17'
version = '8.11.5'
version = '8.11.6'

from components.java
}
Expand Down
4 changes: 2 additions & 2 deletions java21-build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ java {


group = 'me.playbosswar.com'
version = '8.11.5'
version = '8.11.6'
description = 'CommandTimer'

repositories {
Expand Down Expand Up @@ -68,7 +68,7 @@ publishing {
maven(MavenPublication) {
groupId = 'me.playbosswar.com'
artifactId = 'commandtimer-java21'
version = '8.11.5'
version = '8.11.6'
from components.java
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/me/playbosswar/com/tasks/TasksManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ public void disable() {
tasksToStore.forEach(Task::storeInstance);
stopRunner = true;
if(runnerThread != null && runnerThread.isAlive()) {
runnerThread.stop();
runnerThread.interrupt();
}
}
}
6 changes: 5 additions & 1 deletion src/main/java/me/playbosswar/com/utils/Files.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
import org.json.simple.parser.JSONParser;
import org.json.simple.parser.ParseException;

import com.google.gson.JsonParseException;

import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
Expand Down Expand Up @@ -191,8 +193,10 @@ public static List<Task> deserializeJsonFilesIntoCommandTimers() {
}

tasks.add(task);
} catch (JsonParseException e) {
Bukkit.getLogger().log(Level.SEVERE, "Failed to process " + file.getName() + " because of " + e.getMessage());
} catch(ParseException e) {
Bukkit.getLogger().log(Level.SEVERE, "Failed to process " + file.getName());
Bukkit.getLogger().log(Level.SEVERE, "Failed to process " + file.getName() + " because of " + e.getMessage());
}

}
Expand Down
35 changes: 14 additions & 21 deletions src/main/java/me/playbosswar/com/utils/gson/GsonDate.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
package me.playbosswar.com.utils.gson;

import com.google.gson.*;

import java.lang.reflect.Type;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Date;
import java.util.List;


public class GsonDate implements JsonSerializer<Date>, JsonDeserializer<Date> {
Expand All @@ -14,33 +15,25 @@ public class GsonDate implements JsonSerializer<Date>, JsonDeserializer<Date> {
@Override
public Date deserialize(JsonElement jsonElement, Type type,
JsonDeserializationContext jsonDeserializationContext) throws JsonParseException {
SimpleDateFormat formatter = new SimpleDateFormat(FORMAT);
try {
return formatter.parse(jsonElement.getAsString());
} catch(ParseException ex1) {
// Check if maybe it's in the old format
List<SimpleDateFormat> formats = Arrays.asList(
new SimpleDateFormat(FORMAT),
new SimpleDateFormat("MMM d, yyyy, H:mm:ss a"),
new SimpleDateFormat("MMM d, yyyy, HH:mm:ss a"),
new SimpleDateFormat("MMM d, yyyy, HH:mm:ss"),
new SimpleDateFormat("MMM d, yyyy, hh:mm:ss a"));
for (SimpleDateFormat dataFormat : formats) {
try {
SimpleDateFormat oldFormatter = new SimpleDateFormat("MMM d, yyyy, H:mm:ss a");
return oldFormatter.parse(jsonElement.getAsString());
} catch(ParseException ex2) {
try {
SimpleDateFormat oldFormatter = new SimpleDateFormat("MMM d, yyyy, HH:mm:ss a");
return oldFormatter.parse(jsonElement.getAsString());
} catch(ParseException ex3) {
try {
SimpleDateFormat oldFormatter = new SimpleDateFormat("MMM d, yyyy, HH:mm:ss");
return oldFormatter.parse(jsonElement.getAsString());
} catch(ParseException ex4) {
throw new JsonParseException(ex4);
}
}
return dataFormat.parse(jsonElement.getAsString());
} catch (ParseException ex) {
// ignore
}
}
throw new JsonParseException("Can not parse data: " + jsonElement.getAsString());
}

@Override
public JsonElement serialize(Date date, Type type, JsonSerializationContext jsonSerializationContext) {
SimpleDateFormat sdf = new SimpleDateFormat(FORMAT);
return new JsonPrimitive(sdf.format(date));
}
}
}
2 changes: 1 addition & 1 deletion src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
main: me.playbosswar.com.CommandTimerPlugin
name: "CommandTimer"
version: "8.11.5"
version: "8.11.6"
description: "Schedule commands like you want"
author: PlayBossWar
api-version: 1.13
Expand Down