+ Added stubs and some error checking to prevent lockout.
This commit is contained in:
@@ -19,6 +19,7 @@ import utils.LogFilter;
|
|||||||
public class DewCore
|
public class DewCore
|
||||||
{
|
{
|
||||||
// TODO: Make realm and players both per-realm
|
// TODO: Make realm and players both per-realm
|
||||||
|
public static String responseHeader = "[Dewdrop Forest]";
|
||||||
public static DewRealm realm;
|
public static DewRealm realm;
|
||||||
public static List<KittyAdapterDewPlayer> players;
|
public static List<KittyAdapterDewPlayer> players;
|
||||||
public static List<KittyAdapterDewPlayer> playersCaptured;
|
public static List<KittyAdapterDewPlayer> playersCaptured;
|
||||||
@@ -82,7 +83,10 @@ public class DewCore
|
|||||||
|
|
||||||
if(f != null)
|
if(f != null)
|
||||||
{
|
{
|
||||||
|
Response.GetLastMessage((String last) -> {
|
||||||
|
if(last.contains(responseHeader))
|
||||||
Response.EditLastMessage(f.resString);
|
Response.EditLastMessage(f.resString);
|
||||||
|
});
|
||||||
didRun = true;
|
didRun = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -145,6 +149,7 @@ public class DewCore
|
|||||||
|
|
||||||
// Draw world
|
// Draw world
|
||||||
String out = "";
|
String out = "";
|
||||||
|
out += responseHeader + "\n";
|
||||||
out += "**Realm ID - ** `" + realm.id + "`\n";
|
out += "**Realm ID - ** `" + realm.id + "`\n";
|
||||||
|
|
||||||
for(int y = 0; y < worldBuffer.length; ++y)
|
for(int y = 0; y < worldBuffer.length; ++y)
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package dataStructures;
|
||||||
|
|
||||||
|
public class KittyTrackedResponse
|
||||||
|
{
|
||||||
|
// TODO: Fill this out!
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ package dataStructures;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import net.dv8tion.jda.core.JDA;
|
import net.dv8tion.jda.core.JDA;
|
||||||
import net.dv8tion.jda.core.MessageBuilder;
|
import net.dv8tion.jda.core.MessageBuilder;
|
||||||
@@ -20,7 +21,7 @@ import utils.LogFilter;
|
|||||||
public class Response
|
public class Response
|
||||||
{
|
{
|
||||||
// Last message
|
// Last message
|
||||||
private static Message lastSentMessage = null;
|
private static Message lastSentMessage = new MessageBuilder().append(" ").build();
|
||||||
|
|
||||||
// Variables
|
// Variables
|
||||||
private GuildMessageReceivedEvent event;
|
private GuildMessageReceivedEvent event;
|
||||||
@@ -155,6 +156,7 @@ public class Response
|
|||||||
////////////////////////
|
////////////////////////
|
||||||
|
|
||||||
// Blast that message out and don't do anything else on this thread until sent.
|
// Blast that message out and don't do anything else on this thread until sent.
|
||||||
|
// BLOCKING
|
||||||
protected void respondImmediate(MessageAction toSend)
|
protected void respondImmediate(MessageAction toSend)
|
||||||
{
|
{
|
||||||
synchronized(lastSentMessage)
|
synchronized(lastSentMessage)
|
||||||
@@ -163,7 +165,8 @@ public class Response
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Async thread-safe assignment. Assignment may technically be out of order, so keep that in mind.
|
// thread-safe assignment. Assignment may technically be out of order, so keep that in mind.
|
||||||
|
// ASYNC
|
||||||
protected void respond(MessageAction toSend)
|
protected void respond(MessageAction toSend)
|
||||||
{
|
{
|
||||||
toSend.submit().whenComplete((msg, err) -> {
|
toSend.submit().whenComplete((msg, err) -> {
|
||||||
@@ -174,6 +177,7 @@ public class Response
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// BLOCKING
|
||||||
public static String GetLastMessage()
|
public static String GetLastMessage()
|
||||||
{
|
{
|
||||||
synchronized(lastSentMessage)
|
synchronized(lastSentMessage)
|
||||||
@@ -185,6 +189,19 @@ public class Response
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ASYNC
|
||||||
|
public static void GetLastMessage(Consumer<String> consumer)
|
||||||
|
{
|
||||||
|
synchronized(lastSentMessage)
|
||||||
|
{
|
||||||
|
if(lastSentMessage == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
consumer.accept(lastSentMessage.getContentRaw());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// BLOCKING
|
||||||
public static void EditLastMessage(String newContent)
|
public static void EditLastMessage(String newContent)
|
||||||
{
|
{
|
||||||
synchronized(lastSentMessage)
|
synchronized(lastSentMessage)
|
||||||
|
|||||||
Reference in New Issue
Block a user