implement clickable message base - towards #68

This commit is contained in:
Luck
2016-12-07 21:08:30 +00:00
Unverified
parent d820f153a9
commit 25511f898c
14 changed files with 315 additions and 2 deletions
@@ -31,6 +31,8 @@ import me.lucko.luckperms.common.constants.Permission;
import java.lang.ref.WeakReference;
import java.util.UUID;
import io.github.mkremins.fanciful.FancyMessage;
/**
* Simple implementation of {@link Sender} using a {@link SenderFactory}
*
@@ -60,6 +62,14 @@ public class AbstractSender<T> implements Sender {
}
}
@Override
public void sendMessage(FancyMessage message) {
final T t = ref.get();
if (t != null) {
factory.sendMessage(t, message);
}
}
@Override
public boolean hasPermission(Permission permission) {
if (isConsole()) return true;
@@ -28,6 +28,8 @@ import me.lucko.luckperms.common.constants.Permission;
import java.util.UUID;
import io.github.mkremins.fanciful.FancyMessage;
/**
* Wrapper interface to represent a CommandSender/CommandSource within the common command implementations.
*/
@@ -61,6 +63,13 @@ public interface Sender {
*/
void sendMessage(String s);
/**
* Send a json message to the Sender.
*
* @param message the message to send.
*/
void sendMessage(FancyMessage message);
/**
* Check if the Sender has a permission.
*
@@ -28,6 +28,8 @@ import me.lucko.luckperms.common.LuckPermsPlugin;
import java.util.UUID;
import io.github.mkremins.fanciful.FancyMessage;
/**
* Factory class to make a thread-safe sender instance
*
@@ -43,6 +45,8 @@ public abstract class SenderFactory<T> {
protected abstract void sendMessage(T t, String s);
protected abstract void sendMessage(T t, FancyMessage message);
protected abstract boolean hasPermission(T t, String node);
public final Sender wrap(T t) {
@@ -44,6 +44,8 @@ import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import io.github.mkremins.fanciful.FancyMessage;
/**
* Class to handle import operations
*/
@@ -212,6 +214,11 @@ public class Importer {
instance.logMessage(s);
}
@Override
public void sendMessage(FancyMessage message) {
instance.logMessage(message.toOldMessageFormat());
}
@Override
public boolean hasPermission(Permission permission) {
return true;