Added CG user to chat event
SendChatMessage now takes a ChatMessage param (with a builder) Code cleanup /schrestart error msg added Whole plugin update made async (the plugin list) Javadoc additions
This commit is contained in:
parent
bc24df3840
commit
be6e4acb7e
35 changed files with 154 additions and 173 deletions
|
@ -12,8 +12,6 @@
|
||||||
<orderEntry type="inheritedJdk" />
|
<orderEntry type="inheritedJdk" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
|
||||||
<orderEntry type="module" module-name="ButtonCore (1) (com.github.TBMCPlugins.ButtonCore)" />
|
|
||||||
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||||
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||||
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
<orderEntry type="library" name="Maven: org.javassist:javassist:3.20.0-GA" level="project" />
|
||||||
|
|
|
@ -8,7 +8,7 @@ public class BCUMain {
|
||||||
System.out.println("Getting list of repositories...");
|
System.out.println("Getting list of repositories...");
|
||||||
List<String> plugins = PluginUpdater.GetPluginNames();
|
List<String> plugins = PluginUpdater.GetPluginNames();
|
||||||
System.out.println("Removing non-Maven projects...");
|
System.out.println("Removing non-Maven projects...");
|
||||||
plugins.removeIf(plugin -> !PluginUpdater.isMaven(plugin, "master"));
|
plugins.removeIf(plugin -> PluginUpdater.isNotMaven(plugin, "master"));
|
||||||
System.out.println(plugins.stream().collect(Collectors.joining("\n")));
|
System.out.println(plugins.stream().collect(Collectors.joining("\n")));
|
||||||
for (String plugin : plugins) { //TODO: We don't want to apply it all at once, especially to unused/unowned repos
|
for (String plugin : plugins) { //TODO: We don't want to apply it all at once, especially to unused/unowned repos
|
||||||
} //TODO: Add it to ButtonCore - or actually as a plugin or ButtonProcessor
|
} //TODO: Add it to ButtonCore - or actually as a plugin or ButtonProcessor
|
||||||
|
|
|
@ -29,14 +29,13 @@ public class MainPlugin extends JavaPlugin {
|
||||||
public static boolean Test;
|
public static boolean Test;
|
||||||
public static Essentials ess;
|
public static Essentials ess;
|
||||||
|
|
||||||
private PluginDescriptionFile pdfFile;
|
|
||||||
private Logger logger;
|
private Logger logger;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
// Logs "Plugin Enabled", registers commands
|
// Logs "Plugin Enabled", registers commands
|
||||||
Instance = this;
|
Instance = this;
|
||||||
pdfFile = getDescription();
|
PluginDescriptionFile pdf = getDescription();
|
||||||
logger = getLogger();
|
logger = getLogger();
|
||||||
setupPermissions();
|
setupPermissions();
|
||||||
Test = getConfig().getBoolean("test", true);
|
Test = getConfig().getBoolean("test", true);
|
||||||
|
@ -66,7 +65,7 @@ public class MainPlugin extends JavaPlugin {
|
||||||
}
|
}
|
||||||
ess = Essentials.getPlugin(Essentials.class);
|
ess = Essentials.getPlugin(Essentials.class);
|
||||||
new RandomTP().onEnable(this); //It registers it's command
|
new RandomTP().onEnable(this); //It registers it's command
|
||||||
logger.info(pdfFile.getName() + " has been Enabled (V." + pdfFile.getVersion() + ") Test: " + Test + ".");
|
logger.info(pdf.getName() + " has been Enabled (V." + pdf.getVersion() + ") Test: " + Test + ".");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -53,7 +53,7 @@ public class PlayerListener implements Listener {
|
||||||
public void onSystemChat(TBMCSystemChatEvent event) {
|
public void onSystemChat(TBMCSystemChatEvent event) {
|
||||||
if (event.isHandled())
|
if (event.isHandled())
|
||||||
return; // Only handle here if ButtonChat couldn't
|
return; // Only handle here if ButtonChat couldn't
|
||||||
Bukkit.getOnlinePlayers().stream().filter(p -> event.shouldSendTo(p))
|
Bukkit.getOnlinePlayers().stream().filter(event::shouldSendTo)
|
||||||
.forEach(p -> p.sendMessage(event.getChannel().DisplayName.substring(0, 2) + event.getMessage()));
|
.forEach(p -> p.sendMessage(event.getChannel().DisplayName.substring(0, 2) + event.getMessage()));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -24,6 +24,8 @@ public class ScheduledRestartCommand extends TBMCCommandBase {
|
||||||
if (args.length > 0)
|
if (args.length > 0)
|
||||||
ticks = Integer.parseInt(args[0]);
|
ticks = Integer.parseInt(args[0]);
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
|
sender.sendMessage("§cError: Ticks must be a number.");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (ticks < 20) {
|
if (ticks < 20) {
|
||||||
sender.sendMessage("§cError: Ticks must be more than 20.");
|
sender.sendMessage("§cError: Ticks must be more than 20.");
|
||||||
|
@ -33,14 +35,14 @@ public class ScheduledRestartCommand extends TBMCCommandBase {
|
||||||
restartbar = Bukkit.createBossBar("Server restart in " + ticks / 20f, BarColor.RED, BarStyle.SOLID,
|
restartbar = Bukkit.createBossBar("Server restart in " + ticks / 20f, BarColor.RED, BarStyle.SOLID,
|
||||||
BarFlag.DARKEN_SKY);
|
BarFlag.DARKEN_SKY);
|
||||||
restartbar.setProgress(1);
|
restartbar.setProgress(1);
|
||||||
Bukkit.getOnlinePlayers().stream().forEach(p -> restartbar.addPlayer(p));
|
Bukkit.getOnlinePlayers().forEach(p -> restartbar.addPlayer(p));
|
||||||
sender.sendMessage("Scheduled restart in " + ticks / 20f);
|
sender.sendMessage("Scheduled restart in " + ticks / 20f);
|
||||||
ScheduledServerRestartEvent e = new ScheduledServerRestartEvent(ticks);
|
ScheduledServerRestartEvent e = new ScheduledServerRestartEvent(ticks);
|
||||||
Bukkit.getPluginManager().callEvent(e);
|
Bukkit.getPluginManager().callEvent(e);
|
||||||
restarttask = Bukkit.getScheduler().runTaskTimer(MainPlugin.Instance, () -> {
|
restarttask = Bukkit.getScheduler().runTaskTimer(MainPlugin.Instance, () -> {
|
||||||
if (restartcounter < 0) {
|
if (restartcounter < 0) {
|
||||||
restarttask.cancel();
|
restarttask.cancel();
|
||||||
restartbar.getPlayers().stream().forEach(p -> restartbar.removePlayer(p));
|
restartbar.getPlayers().forEach(p -> restartbar.removePlayer(p));
|
||||||
Bukkit.spigot().restart();
|
Bukkit.spigot().restart();
|
||||||
}
|
}
|
||||||
if (restartcounter % 200 == 0)
|
if (restartcounter % 200 == 0)
|
||||||
|
|
|
@ -20,7 +20,7 @@ public class TestPrepare {
|
||||||
Bukkit.setServer(Mockito.mock(Server.class, new Answer<Object>() {
|
Bukkit.setServer(Mockito.mock(Server.class, new Answer<Object>() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Object answer(InvocationOnMock invocation) throws Throwable {
|
public Object answer(InvocationOnMock invocation) {
|
||||||
if (returns(invocation, String.class))
|
if (returns(invocation, String.class))
|
||||||
return "test";
|
return "test";
|
||||||
if (returns(invocation, Logger.class))
|
if (returns(invocation, Logger.class))
|
||||||
|
|
|
@ -11,23 +11,22 @@ import org.bukkit.command.CommandSender;
|
||||||
public class UpdatePluginCommand extends TBMCCommandBase {
|
public class UpdatePluginCommand extends TBMCCommandBase {
|
||||||
@Override
|
@Override
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||||
if (args.length == 0) {
|
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> {
|
||||||
sender.sendMessage("Downloading plugin names...");
|
if (args.length == 0) {
|
||||||
boolean first = true;
|
sender.sendMessage("Downloading plugin names...");
|
||||||
for (String plugin : PluginUpdater.GetPluginNames()) {
|
boolean first = true;
|
||||||
if (first) {
|
for (String plugin : PluginUpdater.GetPluginNames()) {
|
||||||
sender.sendMessage("§6---- Plugin names ----");
|
if (first) {
|
||||||
first = false;
|
sender.sendMessage("§6---- Plugin names ----");
|
||||||
}
|
first = false;
|
||||||
sender.sendMessage("- " + plugin);
|
}
|
||||||
}
|
sender.sendMessage("- " + plugin);
|
||||||
return true;
|
}
|
||||||
} else {
|
} else {
|
||||||
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, () -> {
|
TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]);
|
||||||
TBMCCoreAPI.UpdatePlugin(args[0], sender, args.length == 1 ? "master" : args[1]);
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -22,11 +22,8 @@ abstract class EventExceptionHandler { // https://gist.github.com/aadnk/5430459
|
||||||
* Represents an event executor that does nothing. This is not really necessary in the current
|
* Represents an event executor that does nothing. This is not really necessary in the current
|
||||||
* implementation of CraftBukkit, but we will take no chances.
|
* implementation of CraftBukkit, but we will take no chances.
|
||||||
*/
|
*/
|
||||||
private static EventExecutor NULL_EXECUTOR = new EventExecutor() {
|
private static final EventExecutor NULL_EXECUTOR = (listener, event) -> {
|
||||||
@Override
|
// Do nothing
|
||||||
public void execute(Listener listener, Event event) throws EventException {
|
|
||||||
// Do nothing
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
private final RegisteredListener delegate;
|
private final RegisteredListener delegate;
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class PluginUpdater {
|
||||||
error(sender, "Can't find branch \"" + branch + "\" for plugin \"" + correctname + "\"");
|
error(sender, "Can't find branch \"" + branch + "\" for plugin \"" + correctname + "\"");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (!isMaven(correctname, correctbranch.get())) {
|
if (isNotMaven(correctname, correctbranch.get())) {
|
||||||
error(sender, "The plugin doesn't appear to have a pom.xml. Make sure it's a Maven project.");
|
error(sender, "The plugin doesn't appear to have a pom.xml. Make sure it's a Maven project.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -98,21 +98,21 @@ public class PluginUpdater {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if pom.xml is present for the project.
|
* Checks if pom.xml is not present for the project.
|
||||||
*
|
*
|
||||||
* @param pluginname
|
* @param pluginname
|
||||||
* Does not have to match case
|
* Does not have to match case
|
||||||
* @param branch
|
* @param branch
|
||||||
* Does not have to match case
|
* Does not have to match case
|
||||||
*/
|
*/
|
||||||
public static boolean isMaven(String pluginname, String branch) {
|
public static boolean isNotMaven(String pluginname, String branch) {
|
||||||
try {
|
try {
|
||||||
return !TBMCCoreAPI
|
return TBMCCoreAPI
|
||||||
.DownloadString(
|
.DownloadString(
|
||||||
"https://raw.githubusercontent.com/TBMCPlugins/" + pluginname + "/" + branch + "/pom.xml")
|
"https://raw.githubusercontent.com/TBMCPlugins/" + pluginname + "/" + branch + "/pom.xml")
|
||||||
.equals("404: Not Found\n");
|
.equals("404: Not Found\n");
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,7 +172,7 @@ public class PluginUpdater {
|
||||||
public static class UpdatedEvent extends Event {
|
public static class UpdatedEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private JsonObject data;
|
private final JsonObject data;
|
||||||
|
|
||||||
public UpdatedEvent(JsonObject data) {
|
public UpdatedEvent(JsonObject data) {
|
||||||
this.data = data;
|
this.data = data;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
|
||||||
public class ScheduledServerRestartEvent extends Event {
|
public class ScheduledServerRestartEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private int restartticks;
|
private final int restartticks;
|
||||||
|
|
||||||
public ScheduledServerRestartEvent(int restartticks) {
|
public ScheduledServerRestartEvent(int restartticks) {
|
||||||
this.restartticks = restartticks;
|
this.restartticks = restartticks;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.lib.chat.Channel;
|
||||||
|
import buttondevteam.lib.player.ChromaGamerBase;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.HandlerList;
|
import org.bukkit.event.HandlerList;
|
||||||
|
@ -15,25 +16,28 @@ import javax.annotation.Nullable;
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public class TBMCChatEvent extends TBMCChatEventBase {
|
public class TBMCChatEvent extends TBMCChatEventBase {
|
||||||
public TBMCChatEvent(CommandSender sender, Channel channel, String message, int score, boolean fromcmd, String groupid) {
|
public TBMCChatEvent(CommandSender sender, ChromaGamerBase user, Channel channel, String message, int score, boolean fromcmd, String groupid) {
|
||||||
super(channel, message, score, groupid);
|
super(channel, message, score, groupid);
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.fromcmd = fromcmd;
|
this.fromcmd = fromcmd;
|
||||||
this.ignoreSenderPermissions = false;
|
this.ignoreSenderPermissions = false;
|
||||||
|
this.user = user;
|
||||||
}
|
}
|
||||||
|
|
||||||
public TBMCChatEvent(CommandSender sender, Channel channel, String message, int score, boolean fromcmd, String groupid, boolean ignoreSenderPermissions) {
|
public TBMCChatEvent(CommandSender sender, ChromaGamerBase user, Channel channel, String message, int score, boolean fromcmd, String groupid, boolean ignoreSenderPermissions) {
|
||||||
super(channel, message, score, groupid);
|
super(channel, message, score, groupid);
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
|
this.user = user;
|
||||||
this.fromcmd = fromcmd;
|
this.fromcmd = fromcmd;
|
||||||
this.ignoreSenderPermissions = ignoreSenderPermissions;
|
this.ignoreSenderPermissions = ignoreSenderPermissions;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
private boolean fromcmd;
|
private final boolean fromcmd;
|
||||||
private final boolean ignoreSenderPermissions;
|
private final boolean ignoreSenderPermissions;
|
||||||
|
private final ChromaGamerBase user;
|
||||||
// TODO: Message object with data?
|
// TODO: Message object with data?
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package buttondevteam.lib;
|
package buttondevteam.lib;
|
||||||
|
|
||||||
import buttondevteam.lib.chat.Channel;
|
import buttondevteam.lib.chat.Channel;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.event.Cancellable;
|
import org.bukkit.event.Cancellable;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
|
@ -13,13 +15,16 @@ import org.bukkit.event.HandlerList;
|
||||||
* @author NorbiPeti
|
* @author NorbiPeti
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@Getter
|
||||||
public class TBMCChatPreprocessEvent extends Event implements Cancellable {
|
public class TBMCChatPreprocessEvent extends Event implements Cancellable {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Channel channel;
|
private final Channel channel;
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
@Setter
|
||||||
private String message;
|
private String message;
|
||||||
private boolean cancelled;
|
@Setter
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) {
|
public TBMCChatPreprocessEvent(CommandSender sender, Channel channel, String message) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
|
@ -31,22 +36,6 @@ public class TBMCChatPreprocessEvent extends Event implements Cancellable {
|
||||||
* public TBMCPlayer getPlayer() { return TBMCPlayer.getPlayer(sender); // TODO: Get Chroma user }
|
* public TBMCPlayer getPlayer() { return TBMCPlayer.getPlayer(sender); // TODO: Get Chroma user }
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public Channel getChannel() {
|
|
||||||
return channel;
|
|
||||||
}
|
|
||||||
|
|
||||||
public CommandSender getSender() {
|
|
||||||
return sender;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage() {
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setMessage(String message) {
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HandlerList getHandlers() {
|
public HandlerList getHandlers() {
|
||||||
return handlers;
|
return handlers;
|
||||||
|
@ -55,14 +44,4 @@ public class TBMCChatPreprocessEvent extends Event implements Cancellable {
|
||||||
public static HandlerList getHandlerList() {
|
public static HandlerList getHandlerList() {
|
||||||
return handlers;
|
return handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,6 @@ import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -21,7 +20,7 @@ import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
public class TBMCCoreAPI {
|
public class TBMCCoreAPI {
|
||||||
static List<String> coders = new ArrayList<String>() {
|
static final List<String> coders = new ArrayList<String>() {
|
||||||
private static final long serialVersionUID = -4462159250738367334L;
|
private static final long serialVersionUID = -4462159250738367334L;
|
||||||
{
|
{
|
||||||
add("Alisolarflare");
|
add("Alisolarflare");
|
||||||
|
@ -59,7 +58,7 @@ public class TBMCCoreAPI {
|
||||||
return PluginUpdater.UpdatePlugin(name, sender, branch);
|
return PluginUpdater.UpdatePlugin(name, sender, branch);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String DownloadString(String urlstr) throws MalformedURLException, IOException {
|
public static String DownloadString(String urlstr) throws IOException {
|
||||||
URL url = new URL(urlstr);
|
URL url = new URL(urlstr);
|
||||||
URLConnection con = url.openConnection();
|
URLConnection con = url.openConnection();
|
||||||
con.setRequestProperty("User-Agent", "TBMCPlugins");
|
con.setRequestProperty("User-Agent", "TBMCPlugins");
|
||||||
|
|
|
@ -5,7 +5,7 @@ import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class TBMCDebugMessageEvent extends Event {
|
public class TBMCDebugMessageEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private String message;
|
private final String message;
|
||||||
private boolean sent;
|
private boolean sent;
|
||||||
|
|
||||||
public TBMCDebugMessageEvent(String message) {
|
public TBMCDebugMessageEvent(String message) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ public class Channel {
|
||||||
*/
|
*/
|
||||||
public final Function<CommandSender, RecipientTestResult> filteranderrormsg;
|
public final Function<CommandSender, RecipientTestResult> filteranderrormsg;
|
||||||
|
|
||||||
private static List<Channel> channels = new ArrayList<>();
|
private static final List<Channel> channels = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a channel.
|
* Creates a channel.
|
||||||
|
@ -66,12 +66,11 @@ public class Channel {
|
||||||
* generated automatically.
|
* generated automatically.
|
||||||
*
|
*
|
||||||
* @param permgroup The group that can access the channel or <b>null</b> to only allow OPs.
|
* @param permgroup The group that can access the channel or <b>null</b> to only allow OPs.
|
||||||
* @return
|
* @return If has access
|
||||||
*/
|
*/
|
||||||
public static Function<CommandSender, RecipientTestResult> inGroupFilter(String permgroup) {
|
public static Function<CommandSender, RecipientTestResult> inGroupFilter(String permgroup) {
|
||||||
return noScoreResult(
|
return noScoreResult(
|
||||||
s -> s.isOp() || (permgroup != null
|
s -> s.isOp() || (permgroup != null && (s instanceof Player && MainPlugin.permission != null && MainPlugin.permission.playerInGroup((Player) s, permgroup))),
|
||||||
? s instanceof Player && MainPlugin.permission != null && MainPlugin.permission.playerInGroup((Player) s, permgroup) : false),
|
|
||||||
"You need to be a(n) " + (permgroup != null ? permgroup : "OP") + " to use this channel.");
|
"You need to be a(n) " + (permgroup != null ? permgroup : "OP") + " to use this channel.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
|
||||||
public class ChatChannelRegisterEvent extends Event {
|
public class ChatChannelRegisterEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private Channel channel;
|
private final Channel channel;
|
||||||
|
|
||||||
public ChatChannelRegisterEvent(Channel channel) {
|
public ChatChannelRegisterEvent(Channel channel) {
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
package buttondevteam.lib.chat;
|
||||||
|
|
||||||
|
import buttondevteam.lib.player.ChromaGamerBase;
|
||||||
|
import lombok.Builder;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.NonNull;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@Builder
|
||||||
|
@Getter
|
||||||
|
public class ChatMessage {
|
||||||
|
/**
|
||||||
|
* The MC channel to send the message to.
|
||||||
|
*/
|
||||||
|
private final Channel channel;
|
||||||
|
/**
|
||||||
|
* The sender which sends the message.
|
||||||
|
*/
|
||||||
|
private final CommandSender sender;
|
||||||
|
/**
|
||||||
|
* The Chroma user which sends the message.
|
||||||
|
*/
|
||||||
|
private final ChromaGamerBase user;
|
||||||
|
/**
|
||||||
|
* The message to send as the user.
|
||||||
|
*/
|
||||||
|
private final String message;
|
||||||
|
/**
|
||||||
|
* Indicates whether the message comes from running a command (like /tableflip). Implemented to be used from Discord.
|
||||||
|
*/
|
||||||
|
private boolean fromCommand;
|
||||||
|
/**
|
||||||
|
* The sender which we should check for permissions. Same as {@link #sender} by default.
|
||||||
|
*/
|
||||||
|
private CommandSender permCheck;
|
||||||
|
|
||||||
|
private static ChatMessageBuilder builder() {
|
||||||
|
return new ChatMessageBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
|
public static ChatMessageBuilder builder(Channel channel, CommandSender sender, ChromaGamerBase user, String message) {
|
||||||
|
return builder().channel(channel).sender(sender).user(user).message(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -6,7 +6,7 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ChatRoom extends Channel {
|
public class ChatRoom extends Channel {
|
||||||
private List<CommandSender> usersInRoom = new ArrayList<>();
|
private final List<CommandSender> usersInRoom = new ArrayList<>();
|
||||||
|
|
||||||
public ChatRoom(String displayname, Color color, String command) {
|
public ChatRoom(String displayname, Color color, String command) {
|
||||||
<ChatRoom>super(displayname, color, command, noScoreResult((this_, s) -> this_.usersInRoom.contains(s),
|
<ChatRoom>super(displayname, color, command, noScoreResult((this_, s) -> this_.usersInRoom.contains(s),
|
||||||
|
|
|
@ -20,7 +20,7 @@ public @interface CommandClass {
|
||||||
*
|
*
|
||||||
* @return If the command is mod only
|
* @return If the command is mod only
|
||||||
*/
|
*/
|
||||||
public boolean modOnly() default false;
|
boolean modOnly() default false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The command's path, or name if top-level command.<br>
|
* The command's path, or name if top-level command.<br>
|
||||||
|
@ -30,10 +30,10 @@ public @interface CommandClass {
|
||||||
*
|
*
|
||||||
* @return The command path, <i>which is the command class name by default</i> (removing any "command" from it)
|
* @return The command path, <i>which is the command class name by default</i> (removing any "command" from it)
|
||||||
*/
|
*/
|
||||||
public String path() default "";
|
String path() default "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exclude this class from the path. Useful if more commands share some property but aren't subcommands of a common command. See {@link CommandClass} for more details.
|
* Exclude this class from the path. Useful if more commands share some property but aren't subcommands of a common command. See {@link CommandClass} for more details.
|
||||||
*/
|
*/
|
||||||
public boolean excludeFromPath() default false;
|
boolean excludeFromPath() default false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,5 +12,5 @@ import java.lang.annotation.*;
|
||||||
@Target(ElementType.TYPE)
|
@Target(ElementType.TYPE)
|
||||||
@Inherited
|
@Inherited
|
||||||
public @interface OptionallyPlayerCommandClass {
|
public @interface OptionallyPlayerCommandClass {
|
||||||
public boolean playerOnly();
|
boolean playerOnly();
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ package buttondevteam.lib.chat;
|
||||||
|
|
||||||
public enum Priority {
|
public enum Priority {
|
||||||
Low(0), Normal(1), High(2);
|
Low(0), Normal(1), High(2);
|
||||||
private int val;
|
private final int val;
|
||||||
|
|
||||||
Priority(int v) {
|
Priority(int v) {
|
||||||
val = v;
|
val = v;
|
||||||
|
|
|
@ -7,6 +7,7 @@ import buttondevteam.lib.TBMCChatPreprocessEvent;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
import buttondevteam.lib.TBMCSystemChatEvent;
|
import buttondevteam.lib.TBMCSystemChatEvent;
|
||||||
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
import buttondevteam.lib.chat.Channel.RecipientTestResult;
|
||||||
|
import lombok.val;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -26,7 +27,7 @@ import java.util.function.Consumer;
|
||||||
|
|
||||||
public class TBMCChatAPI {
|
public class TBMCChatAPI {
|
||||||
|
|
||||||
private static HashMap<String, TBMCCommandBase> commands = new HashMap<String, TBMCCommandBase>();
|
private static final HashMap<String, TBMCCommandBase> commands = new HashMap<>();
|
||||||
|
|
||||||
public static HashMap<String, TBMCCommandBase> GetCommands() {
|
public static HashMap<String, TBMCCommandBase> GetCommands() {
|
||||||
return commands;
|
return commands;
|
||||||
|
@ -77,7 +78,7 @@ public class TBMCChatAPI {
|
||||||
addToCmds.accept("/" + cmd.getKey());
|
addToCmds.accept("/" + cmd.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmds.toArray(new String[cmds.size()]);
|
return cmds.toArray(new String[0]); //Apparently it's faster to use an empty array in modern Java
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -149,7 +150,7 @@ public class TBMCChatAPI {
|
||||||
try {
|
try {
|
||||||
TBMCCommandBase c;
|
TBMCCommandBase c;
|
||||||
if (params.length > 0)
|
if (params.length > 0)
|
||||||
c = thecmdclass.getConstructor(Arrays.stream(params).map(p -> p.getClass()).toArray(Class[]::new))
|
c = thecmdclass.getConstructor(Arrays.stream(params).map(Object::getClass).toArray(Class[]::new))
|
||||||
.newInstance(params);
|
.newInstance(params);
|
||||||
else
|
else
|
||||||
c = thecmdclass.newInstance();
|
c = thecmdclass.newInstance();
|
||||||
|
@ -205,70 +206,31 @@ public class TBMCChatAPI {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.
|
|
||||||
*
|
|
||||||
* @param channel
|
|
||||||
* The channel to send to
|
|
||||||
* @param sender
|
|
||||||
* The sender to send from
|
|
||||||
* @param message
|
|
||||||
* The message to send
|
|
||||||
* @return The event cancelled state
|
|
||||||
*/
|
|
||||||
public static boolean SendChatMessage(Channel channel, CommandSender sender, String message) {
|
|
||||||
return SendChatMessage(channel, sender, message, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.<br>
|
* Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.<br>
|
||||||
* This will also send the error message to the sender, if they can't send the message.
|
* This will also send the error message to the sender, if they can't send the message.
|
||||||
*
|
*
|
||||||
* @param channel The channel to send to
|
* @param cm The message to send
|
||||||
* @param sender The sender to send from
|
|
||||||
* @param message The message to send
|
|
||||||
* @param fromcommand Whether this message comes from running a command, used to determine whether to delete Discord messages for example
|
|
||||||
* @return The event cancelled state
|
* @return The event cancelled state
|
||||||
*/
|
*/
|
||||||
public static boolean SendChatMessage(Channel channel, CommandSender sender, String message, boolean fromcommand) {
|
public static boolean SendChatMessage(ChatMessage cm) {
|
||||||
return sendChatMessageInternal(channel, sender, message, fromcommand, sender);
|
if (!Channel.getChannels().contains(cm.getChannel()))
|
||||||
}
|
throw new RuntimeException("Channel " + cm.getChannel().DisplayName + " not registered!");
|
||||||
|
val permcheck = cm.getPermCheck() == null ? cm.getSender() : cm.getPermCheck();
|
||||||
private static boolean sendChatMessageInternal(Channel channel, CommandSender sender, String message, boolean fromcommand, CommandSender permcheck) {
|
RecipientTestResult rtr = getScoreOrSendError(cm.getChannel(), permcheck);
|
||||||
if (!Channel.getChannels().contains(channel))
|
|
||||||
throw new RuntimeException("Channel " + channel.DisplayName + " not registered!");
|
|
||||||
RecipientTestResult rtr = getScoreOrSendError(channel, permcheck);
|
|
||||||
int score = rtr.score;
|
int score = rtr.score;
|
||||||
if (score == -1 || rtr.groupID == null)
|
if (score == -1 || rtr.groupID == null)
|
||||||
return true;
|
return true;
|
||||||
TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(sender, channel, message);
|
TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(cm.getSender(), cm.getChannel(), cm.getMessage());
|
||||||
Bukkit.getPluginManager().callEvent(eventPre);
|
Bukkit.getPluginManager().callEvent(eventPre);
|
||||||
if (eventPre.isCancelled())
|
if (eventPre.isCancelled())
|
||||||
return true;
|
return true;
|
||||||
TBMCChatEvent event;
|
TBMCChatEvent event;
|
||||||
if (permcheck == sender)
|
event = new TBMCChatEvent(cm.getSender(), cm.getUser(), cm.getChannel(), eventPre.getMessage(), score, cm.isFromCommand(), rtr.groupID, permcheck != cm.getSender());
|
||||||
event = new TBMCChatEvent(sender, channel, eventPre.getMessage(), score, fromcommand, rtr.groupID);
|
|
||||||
else
|
|
||||||
event = new TBMCChatEvent(sender, channel, eventPre.getMessage(), score, fromcommand, rtr.groupID, true);
|
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
return event.isCancelled();
|
return event.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sends a chat message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.<br>
|
|
||||||
* This will not check if the sender has permission.
|
|
||||||
*
|
|
||||||
* @param channel The channel to send to
|
|
||||||
* @param sender The sender to send from
|
|
||||||
* @param message The message to send
|
|
||||||
* @param fromcommand Whether this message comes from running a command, used to determine whether to delete Discord messages for example
|
|
||||||
* @param permcheck The sender to check permissions
|
|
||||||
* @return The event cancelled state
|
|
||||||
*/
|
|
||||||
public static boolean SendChatMessageDontCheckSender(Channel channel, CommandSender sender, String message, boolean fromcommand, CommandSender permcheck) {
|
|
||||||
return sendChatMessageInternal(channel, sender, message, fromcommand, permcheck);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sends a regular message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.
|
* Sends a regular message to Minecraft. Make sure that the channel is registered with {@link #RegisterChatChannel(Channel)}.
|
||||||
*
|
*
|
||||||
|
|
|
@ -40,7 +40,7 @@ public abstract class TBMCCommandBase {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final String getcmdpath() {
|
private String getcmdpath() {
|
||||||
if (!getClass().isAnnotationPresent(CommandClass.class))
|
if (!getClass().isAnnotationPresent(CommandClass.class))
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"No @CommandClass annotation on command class " + getClass().getSimpleName() + "!");
|
"No @CommandClass annotation on command class " + getClass().getSimpleName() + "!");
|
||||||
|
@ -72,11 +72,10 @@ public abstract class TBMCCommandBase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isPlayerOnly() {
|
public final boolean isPlayerOnly() {
|
||||||
return this instanceof PlayerCommandBase ? true
|
return this instanceof PlayerCommandBase ||
|
||||||
: this instanceof OptionallyPlayerCommandBase
|
(this instanceof OptionallyPlayerCommandBase &&
|
||||||
? getClass().isAnnotationPresent(OptionallyPlayerCommandClass.class)
|
(!getClass().isAnnotationPresent(OptionallyPlayerCommandClass.class)
|
||||||
? getClass().getAnnotation(OptionallyPlayerCommandClass.class).playerOnly() : true
|
|| getClass().getAnnotation(OptionallyPlayerCommandClass.class).playerOnly()));
|
||||||
: false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean modonly;
|
private final boolean modonly;
|
||||||
|
@ -88,7 +87,7 @@ public abstract class TBMCCommandBase {
|
||||||
return modonly;
|
return modonly;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final boolean ismodonly() {
|
private boolean ismodonly() {
|
||||||
if (!getClass().isAnnotationPresent(CommandClass.class))
|
if (!getClass().isAnnotationPresent(CommandClass.class))
|
||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"No @CommandClass annotation on command class " + getClass().getSimpleName() + "!");
|
"No @CommandClass annotation on command class " + getClass().getSimpleName() + "!");
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
package buttondevteam.lib.chat;
|
package buttondevteam.lib.chat;
|
||||||
|
|
||||||
public interface TellrawSerializableEnum {
|
public interface TellrawSerializableEnum {
|
||||||
public String getName();
|
String getName();
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,10 +72,10 @@ public abstract class ChromaGamerBase implements AutoCloseable {
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* Loads a user from disk and returns the user object. Make sure to use the subclasses' methods, where possible, like {@link TBMCPlayerBase#getPlayer(java.util.UUID, Class)}
|
* Loads a user from disk and returns the user object. Make sure to use the subclasses' methods, where possible, like {@link TBMCPlayerBase#getPlayer(java.util.UUID, Class)}
|
||||||
*
|
*
|
||||||
* @param fname
|
* @param fname Filename without .yml, usually UUID
|
||||||
* @param cl
|
* @param cl User class
|
||||||
* @return
|
* @return The user object
|
||||||
*/
|
*/
|
||||||
public static <T extends ChromaGamerBase> T getUser(String fname, Class<T> cl) {
|
public static <T extends ChromaGamerBase> T getUser(String fname, Class<T> cl) {
|
||||||
try {
|
try {
|
||||||
|
@ -194,7 +194,7 @@ public abstract class ChromaGamerBase implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private HashMap<String, PlayerData> datamap = new HashMap<>();
|
private final HashMap<String, PlayerData> datamap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use from a data() method, which is in a method with the name of the key. For example, use flair() for the enclosing method of the outer data() to save to and load from "flair"
|
* Use from a data() method, which is in a method with the name of the key. For example, use flair() for the enclosing method of the outer data() to save to and load from "flair"
|
||||||
|
@ -225,7 +225,7 @@ public abstract class ChromaGamerBase implements AutoCloseable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
private HashMap<String, EnumPlayerData> dataenummap = new HashMap<>();
|
private final HashMap<String, EnumPlayerData> dataenummap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Use from a data() method, which is in a method with the name of the key. For example, use flair() for the enclosing method of the outer data() to save to and load from "flair"
|
* Use from a data() method, which is in a method with the name of the key. For example, use flair() for the enclosing method of the outer data() to save to and load from "flair"
|
||||||
|
|
|
@ -3,9 +3,9 @@ package buttondevteam.lib.player;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class EnumPlayerData<T extends Enum<T>> {
|
public class EnumPlayerData<T extends Enum<T>> {
|
||||||
private PlayerData<String> data;
|
private final PlayerData<String> data;
|
||||||
private Class<T> cl;
|
private final Class<T> cl;
|
||||||
private T def;
|
private final T def;
|
||||||
|
|
||||||
public EnumPlayerData(String name, YamlConfiguration yaml, Class<T> cl, T def) {
|
public EnumPlayerData(String name, YamlConfiguration yaml, Class<T> cl, T def) {
|
||||||
data = new PlayerData<String>(name, yaml, "");
|
data = new PlayerData<String>(name, yaml, "");
|
||||||
|
|
|
@ -3,9 +3,9 @@ package buttondevteam.lib.player;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
|
||||||
public class PlayerData<T> {
|
public class PlayerData<T> {
|
||||||
private String name;
|
private final String name;
|
||||||
private YamlConfiguration yaml;
|
private final YamlConfiguration yaml;
|
||||||
private T def;
|
private final T def;
|
||||||
|
|
||||||
public PlayerData(String name, YamlConfiguration yaml, T def) {
|
public PlayerData(String name, YamlConfiguration yaml, T def) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
|
|
@ -19,9 +19,9 @@ import java.util.stream.Collectors;
|
||||||
public class TBMCPlayerGetInfoEvent extends Event {
|
public class TBMCPlayerGetInfoEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private ChromaGamerBase player;
|
private final ChromaGamerBase player;
|
||||||
private List<String> infolines;
|
private final List<String> infolines;
|
||||||
private InfoTarget target;
|
private final InfoTarget target;
|
||||||
|
|
||||||
TBMCPlayerGetInfoEvent(ChromaGamerBase player, InfoTarget target) {
|
TBMCPlayerGetInfoEvent(ChromaGamerBase player, InfoTarget target) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -7,8 +7,8 @@ import org.bukkit.event.HandlerList;
|
||||||
public class TBMCPlayerJoinEvent extends Event {
|
public class TBMCPlayerJoinEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayerBase player;
|
private final TBMCPlayerBase player;
|
||||||
private Player player_;
|
private final Player player_;
|
||||||
|
|
||||||
public TBMCPlayerJoinEvent(TBMCPlayerBase player, Player player_) {
|
public TBMCPlayerJoinEvent(TBMCPlayerBase player, Player player_) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
|
||||||
public class TBMCPlayerLoadEvent extends Event {
|
public class TBMCPlayerLoadEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayerBase player;
|
private final TBMCPlayerBase player;
|
||||||
|
|
||||||
public TBMCPlayerLoadEvent(TBMCPlayerBase player) {
|
public TBMCPlayerLoadEvent(TBMCPlayerBase player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -7,8 +7,8 @@ import org.bukkit.event.HandlerList;
|
||||||
public class TBMCPlayerQuitEvent extends Event {
|
public class TBMCPlayerQuitEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayerBase player;
|
private final TBMCPlayerBase player;
|
||||||
private Player player_;
|
private final Player player_;
|
||||||
|
|
||||||
public TBMCPlayerQuitEvent(TBMCPlayerBase player, Player player_) {
|
public TBMCPlayerQuitEvent(TBMCPlayerBase player, Player player_) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
|
||||||
public class TBMCPlayerSaveEvent extends Event {
|
public class TBMCPlayerSaveEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
private TBMCPlayerBase player;
|
private final TBMCPlayerBase player;
|
||||||
|
|
||||||
public TBMCPlayerSaveEvent(TBMCPlayerBase player) {
|
public TBMCPlayerSaveEvent(TBMCPlayerBase player) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
|
@ -6,7 +6,7 @@ import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
public class TBMCYEEHAWEvent extends Event {
|
public class TBMCYEEHAWEvent extends Event {
|
||||||
private static final HandlerList handlers = new HandlerList();
|
private static final HandlerList handlers = new HandlerList();
|
||||||
private CommandSender sender;
|
private final CommandSender sender;
|
||||||
|
|
||||||
public TBMCYEEHAWEvent(CommandSender sender) {
|
public TBMCYEEHAWEvent(CommandSender sender) {
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
|
|
|
@ -49,9 +49,7 @@ public class DebugPotato {
|
||||||
List<String> tempList = new ArrayList<String>();
|
List<String> tempList = new ArrayList<String>();
|
||||||
for(String line: message){
|
for(String line: message){
|
||||||
tempList = WordWrap(line.toString());
|
tempList = WordWrap(line.toString());
|
||||||
for (String s: tempList){
|
outputList.addAll(tempList);
|
||||||
outputList.add(s);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.message = outputList;
|
this.message = outputList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,13 +32,13 @@ public class PlayerDataTest extends TestCase {
|
||||||
assertEquals("Test", p.PlayerName().get());
|
assertEquals("Test", p.PlayerName().get());
|
||||||
assertEquals(TestEnum.A, p.testenum().get());
|
assertEquals(TestEnum.A, p.testenum().get());
|
||||||
assertEquals((short) 0, (short) p.TestShort().get());
|
assertEquals((short) 0, (short) p.TestShort().get());
|
||||||
assertEquals(false, (boolean) p.TestBool().get());
|
assertFalse(p.TestBool().get());
|
||||||
p.testenum().set(TestEnum.B);
|
p.testenum().set(TestEnum.B);
|
||||||
assertEquals(TestEnum.B, p.testenum().get());
|
assertEquals(TestEnum.B, p.testenum().get());
|
||||||
p.TestShort().set((short) 5);
|
p.TestShort().set((short) 5);
|
||||||
assertEquals((short) 5, (short) p.TestShort().get());
|
assertEquals((short) 5, (short) p.TestShort().get());
|
||||||
p.TestBool().set(true);
|
p.TestBool().set(true);
|
||||||
assertEquals(true, (boolean) p.TestBool().get());
|
assertTrue(p.TestBool().get());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public class PlayerDataTest extends TestCase {
|
||||||
assertEquals("Test", p.PlayerName().get());
|
assertEquals("Test", p.PlayerName().get());
|
||||||
assertEquals(TestEnum.B, p.testenum().get());
|
assertEquals(TestEnum.B, p.testenum().get());
|
||||||
assertEquals((short) 5, (short) p.TestShort().get());
|
assertEquals((short) 5, (short) p.TestShort().get());
|
||||||
assertEquals(true, (boolean) p.TestBool().get());
|
assertTrue(p.TestBool().get());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue