A few fixes
This commit is contained in:
parent
a39fd083be
commit
773277cb27
8 changed files with 65 additions and 134 deletions
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Maven: net.bytebuddy:byte-buddy:1.6.11">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.6.11/byte-buddy-1.6.11.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.6.11/byte-buddy-1.6.11-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy/1.6.11/byte-buddy-1.6.11-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Maven: net.bytebuddy:byte-buddy-agent:1.6.11">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.6.11/byte-buddy-agent-1.6.11.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.6.11/byte-buddy-agent-1.6.11-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/net/bytebuddy/byte-buddy-agent/1.6.11/byte-buddy-agent-1.6.11-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Maven: org.mockito:mockito-core:2.7.20">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/2.7.20/mockito-core-2.7.20.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/2.7.20/mockito-core-2.7.20-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/mockito/mockito-core/2.7.20/mockito-core-2.7.20-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -1,13 +0,0 @@
|
||||||
<component name="libraryTable">
|
|
||||||
<library name="Maven: org.objenesis:objenesis:2.5">
|
|
||||||
<CLASSES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.5/objenesis-2.5.jar!/" />
|
|
||||||
</CLASSES>
|
|
||||||
<JAVADOC>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.5/objenesis-2.5-javadoc.jar!/" />
|
|
||||||
</JAVADOC>
|
|
||||||
<SOURCES>
|
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/objenesis/objenesis/2.5/objenesis-2.5-sources.jar!/" />
|
|
||||||
</SOURCES>
|
|
||||||
</library>
|
|
||||||
</component>
|
|
|
@ -12,23 +12,13 @@
|
||||||
<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="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="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" />
|
||||||
<orderEntry type="library" name="Maven: org.mockito:mockito-core:2.7.20" level="project" />
|
<orderEntry type="library" name="Maven: org.mockito:mockito-core:3.0.0" level="project" />
|
||||||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.bytebuddy:byte-buddy:1.6.11" level="project" />
|
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy:1.9.10" level="project" />
|
||||||
<orderEntry type="library" scope="RUNTIME" name="Maven: net.bytebuddy:byte-buddy-agent:1.6.11" level="project" />
|
<orderEntry type="library" name="Maven: net.bytebuddy:byte-buddy-agent:1.9.10" level="project" />
|
||||||
<orderEntry type="library" scope="RUNTIME" name="Maven: org.objenesis:objenesis:2.5" level="project" />
|
<orderEntry type="library" name="Maven: org.objenesis:objenesis:2.6" level="project" />
|
||||||
<orderEntry type="module" module-name="ButtonProcessor" />
|
<orderEntry type="module" module-name="ButtonProcessor" />
|
||||||
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||||
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||||
|
|
|
@ -160,7 +160,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.mockito</groupId>
|
<groupId>org.mockito</groupId>
|
||||||
<artifactId>mockito-core</artifactId>
|
<artifactId>mockito-core</artifactId>
|
||||||
<version>2.7.20</version>
|
<version>3.0.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package buttondevteam.lib.chat;
|
package buttondevteam.lib.chat;
|
||||||
|
|
||||||
import buttondevteam.core.MainPlugin;
|
import buttondevteam.core.MainPlugin;
|
||||||
import lombok.experimental.var;
|
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
@ -127,7 +126,7 @@ public class Command2MC extends Command2<ICommand2MC, Command2MCSender> implemen
|
||||||
//System.out.println("tab");
|
//System.out.println("tab");
|
||||||
for (int i = commandline.length(); i != -1; i = commandline.lastIndexOf(' ', i - 1)) {
|
for (int i = commandline.length(); i != -1; i = commandline.lastIndexOf(' ', i - 1)) {
|
||||||
String subcommand = commandline.substring(0, i).toLowerCase();
|
String subcommand = commandline.substring(0, i).toLowerCase();
|
||||||
if (subcommand.charAt(0) != '/') subcommand = '/' + subcommand; //Console
|
if (subcommand.length() == 0 || subcommand.charAt(0) != '/') subcommand = '/' + subcommand; //Console
|
||||||
//System.out.println("Subcommand: " + subcommand);
|
//System.out.println("Subcommand: " + subcommand);
|
||||||
SubcommandData<ICommand2MC> sd = subcommands.get(subcommand); //O(1)
|
SubcommandData<ICommand2MC> sd = subcommands.get(subcommand); //O(1)
|
||||||
if (sd == null) continue;
|
if (sd == null) continue;
|
||||||
|
@ -183,7 +182,7 @@ public class Command2MC extends Command2<ICommand2MC, Command2MCSender> implemen
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (paramArr[i1].isVarArgs()) {
|
if (paramArr[i1].isVarArgs()) {
|
||||||
params.add(commandline.substring(j + 1).split(" +"));
|
par0ams.add(commandline.substring(j + 1).split(" +"));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
j = commandline.indexOf(' ', j + 1); //End index
|
j = commandline.indexOf(' ', j + 1); //End index
|
||||||
|
|
|
@ -26,10 +26,11 @@ import java.util.HashMap;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class TBMCChatAPI {
|
public class TBMCChatAPI {
|
||||||
|
|
||||||
private static final HashMap<String, TBMCCommandBase> commands = new HashMap<>();
|
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;
|
||||||
|
@ -38,10 +39,8 @@ public class TBMCChatAPI {
|
||||||
/**
|
/**
|
||||||
* Returns messages formatted for Minecraft chat listing the subcommands of the command.
|
* Returns messages formatted for Minecraft chat listing the subcommands of the command.
|
||||||
*
|
*
|
||||||
* @param command
|
* @param command The command which we want the subcommands of
|
||||||
* The command which we want the subcommands of
|
* @param sender The sender for permissions
|
||||||
* @param sender
|
|
||||||
* The sender for permissions
|
|
||||||
* @return The subcommands
|
* @return The subcommands
|
||||||
*/
|
*/
|
||||||
public static String[] GetSubCommands(TBMCCommandBase command, CommandSender sender) {
|
public static String[] GetSubCommands(TBMCCommandBase command, CommandSender sender) {
|
||||||
|
@ -52,10 +51,8 @@ public class TBMCChatAPI {
|
||||||
* Returns messages formatted for Minecraft chat listing the subcommands of the command.<br>
|
* Returns messages formatted for Minecraft chat listing the subcommands of the command.<br>
|
||||||
* Returns a header if subcommands were found, otherwise returns an empty array.
|
* Returns a header if subcommands were found, otherwise returns an empty array.
|
||||||
*
|
*
|
||||||
* @param command
|
* @param command The command which we want the subcommands of
|
||||||
* The command which we want the subcommands of
|
* @param sender The sender for permissions
|
||||||
* @param sender
|
|
||||||
* The sender for permissions
|
|
||||||
* @return The subcommands
|
* @return The subcommands
|
||||||
*/
|
*/
|
||||||
public static String[] GetSubCommands(String command, CommandSender sender) {
|
public static String[] GetSubCommands(String command, CommandSender sender) {
|
||||||
|
@ -69,7 +66,7 @@ public class TBMCChatAPI {
|
||||||
if (cmd.getKey().startsWith(command + " ")) {
|
if (cmd.getKey().startsWith(command + " ")) {
|
||||||
if (cmd.getValue().isPlayerOnly() && !(sender instanceof Player))
|
if (cmd.getValue().isPlayerOnly() && !(sender instanceof Player))
|
||||||
continue;
|
continue;
|
||||||
if (cmd.getValue().isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp()))
|
if (cmd.getValue().isModOnly() && (MainPlugin.permission != null ? !MainPlugin.permission.has(sender, "tbmc.admin") : !sender.isOp()))
|
||||||
continue;
|
continue;
|
||||||
int ind = cmd.getKey().indexOf(' ', command.length() + 2);
|
int ind = cmd.getKey().indexOf(' ', command.length() + 2);
|
||||||
if (ind >= 0) {
|
if (ind >= 0) {
|
||||||
|
@ -80,7 +77,7 @@ public class TBMCChatAPI {
|
||||||
addToCmds.accept("/" + cmd.getKey());
|
addToCmds.accept("/" + cmd.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return cmds.toArray(new String[0]); //Apparently it's faster to use an empty array in modern Java
|
return cmds.toArray(new String[0]); //Apparently it's faster to use an empty array in modern Java
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -97,21 +94,19 @@ public class TBMCChatAPI {
|
||||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin The caller plugin
|
||||||
* The caller plugin
|
* @param acmdclass A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands.
|
||||||
* @param acmdclass
|
|
||||||
* A command's class to get the package name for commands. The provided class's package and subpackages are scanned for commands.
|
|
||||||
*/
|
*/
|
||||||
public static synchronized void AddCommands(JavaPlugin plugin, Class<? extends TBMCCommandBase> acmdclass) {
|
public static synchronized void AddCommands(JavaPlugin plugin, Class<? extends TBMCCommandBase> acmdclass) {
|
||||||
plugin.getLogger().info("Registering commands from " + acmdclass.getPackage().getName());
|
plugin.getLogger().info("Registering commands from " + acmdclass.getPackage().getName());
|
||||||
Reflections rf = new Reflections(new ConfigurationBuilder()
|
Reflections rf = new Reflections(new ConfigurationBuilder()
|
||||||
.setUrls(ClasspathHelper.forPackage(acmdclass.getPackage().getName(),
|
.setUrls(ClasspathHelper.forPackage(acmdclass.getPackage().getName(),
|
||||||
plugin.getClass().getClassLoader()))
|
plugin.getClass().getClassLoader()))
|
||||||
.addUrls(
|
.addUrls(
|
||||||
ClasspathHelper.forClass(OptionallyPlayerCommandBase.class,
|
ClasspathHelper.forClass(OptionallyPlayerCommandBase.class,
|
||||||
OptionallyPlayerCommandBase.class.getClassLoader()),
|
OptionallyPlayerCommandBase.class.getClassLoader()),
|
||||||
ClasspathHelper.forClass(PlayerCommandBase.class, PlayerCommandBase.class.getClassLoader())) // http://stackoverflow.com/questions/12917417/using-reflections-for-finding-the-transitive-subtypes-of-a-class-when-not-all
|
ClasspathHelper.forClass(PlayerCommandBase.class, PlayerCommandBase.class.getClassLoader())) // http://stackoverflow.com/questions/12917417/using-reflections-for-finding-the-transitive-subtypes-of-a-class-when-not-all
|
||||||
.addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner()));
|
.addClassLoader(plugin.getClass().getClassLoader()).addScanners(new SubTypesScanner()));
|
||||||
Set<Class<? extends TBMCCommandBase>> cmds = rf.getSubTypesOf(TBMCCommandBase.class);
|
Set<Class<? extends TBMCCommandBase>> cmds = rf.getSubTypesOf(TBMCCommandBase.class);
|
||||||
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
for (Class<? extends TBMCCommandBase> cmd : cmds) {
|
||||||
try {
|
try {
|
||||||
|
@ -140,18 +135,16 @@ public class TBMCChatAPI {
|
||||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin The caller plugin
|
||||||
* The caller plugin
|
* @param thecmdclass The command's class to create it (because why let you create the command class)
|
||||||
* @param thecmdclass
|
|
||||||
* The command's class to create it (because why let you create the command class)
|
|
||||||
*/
|
*/
|
||||||
public static void AddCommand(JavaPlugin plugin, Class<? extends TBMCCommandBase> thecmdclass, Object... params) {
|
public static void AddCommand(JavaPlugin plugin, Class<? extends TBMCCommandBase> thecmdclass, Object... params) {
|
||||||
// plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName());
|
// plugin.getLogger().info("Registering command " + thecmdclass.getSimpleName() + " for " + plugin.getName());
|
||||||
try {
|
try {
|
||||||
TBMCCommandBase c;
|
TBMCCommandBase c;
|
||||||
if (params.length > 0)
|
if (params.length > 0)
|
||||||
c = thecmdclass.getConstructor(Arrays.stream(params).map(Object::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();
|
||||||
c.plugin = plugin;
|
c.plugin = plugin;
|
||||||
|
@ -173,10 +166,8 @@ public class TBMCChatAPI {
|
||||||
* <i>Using this method after the server is done loading will have no effect.</i>
|
* <i>Using this method after the server is done loading will have no effect.</i>
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param plugin
|
* @param plugin The caller plugin
|
||||||
* The caller plugin
|
* @param cmd The command to add
|
||||||
* @param cmd
|
|
||||||
* The command to add
|
|
||||||
*/
|
*/
|
||||||
public static void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) {
|
public static void AddCommand(JavaPlugin plugin, TBMCCommandBase cmd) {
|
||||||
try {
|
try {
|
||||||
|
@ -259,14 +250,14 @@ public class TBMCChatAPI {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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 cm The message to send
|
* @param cm The message to send
|
||||||
* @return The event cancelled state
|
* @return The event cancelled state
|
||||||
*/
|
*/
|
||||||
public static boolean SendChatMessage(ChatMessage cm) {
|
public static boolean SendChatMessage(ChatMessage cm) {
|
||||||
return SendChatMessage(cm, cm.getUser().channel().get());
|
return SendChatMessage(cm, cm.getUser().channel().get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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>
|
||||||
|
@ -278,36 +269,40 @@ public class TBMCChatAPI {
|
||||||
*/
|
*/
|
||||||
public static boolean SendChatMessage(ChatMessage cm, Channel channel) {
|
public static boolean SendChatMessage(ChatMessage cm, Channel channel) {
|
||||||
if (!Channel.getChannelList().contains(channel))
|
if (!Channel.getChannelList().contains(channel))
|
||||||
throw new RuntimeException("Channel " + channel.DisplayName().get() + " not registered!");
|
throw new RuntimeException("Channel " + channel.DisplayName().get() + " not registered!");
|
||||||
if (!channel.Enabled().get()) {
|
if (!channel.Enabled().get()) {
|
||||||
cm.getSender().sendMessage("§cThe channel '" + channel.DisplayName().get() + "' is disabled!");
|
cm.getSender().sendMessage("§cThe channel '" + channel.DisplayName().get() + "' is disabled!");
|
||||||
return true; //Cancel sending if channel is disabled
|
return true; //Cancel sending if channel is disabled
|
||||||
}
|
}
|
||||||
val permcheck = cm.getPermCheck();
|
Supplier<Boolean> task = () -> {
|
||||||
RecipientTestResult rtr = getScoreOrSendError(channel, permcheck);
|
val permcheck = cm.getPermCheck();
|
||||||
int score = rtr.score;
|
RecipientTestResult rtr = getScoreOrSendError(channel, permcheck);
|
||||||
if (score == Channel.SCORE_SEND_NOPE || rtr.groupID == null)
|
int score = rtr.score;
|
||||||
return true;
|
if (score == Channel.SCORE_SEND_NOPE || rtr.groupID == null)
|
||||||
TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(cm.getSender(), channel, cm.getMessage());
|
return true;
|
||||||
Bukkit.getPluginManager().callEvent(eventPre);
|
TBMCChatPreprocessEvent eventPre = new TBMCChatPreprocessEvent(cm.getSender(), channel, cm.getMessage());
|
||||||
if (eventPre.isCancelled())
|
Bukkit.getPluginManager().callEvent(eventPre);
|
||||||
return true;
|
if (eventPre.isCancelled())
|
||||||
cm.setMessage(eventPre.getMessage());
|
return true;
|
||||||
TBMCChatEvent event;
|
cm.setMessage(eventPre.getMessage());
|
||||||
event = new TBMCChatEvent(channel, cm, rtr);
|
TBMCChatEvent event;
|
||||||
Bukkit.getPluginManager().callEvent(event);
|
event = new TBMCChatEvent(channel, cm, rtr);
|
||||||
return event.isCancelled();
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
return event.isCancelled();
|
||||||
|
};
|
||||||
|
if (Bukkit.isPrimaryThread())
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(MainPlugin.Instance, task::get);
|
||||||
|
else
|
||||||
|
return task.get();
|
||||||
|
return false; //Not cancelled if async
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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)}.
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel The channel to send to
|
||||||
* The channel to send to
|
* @param rtr The score&group to use to find the group - use {@link RecipientTestResult#ALL} if the channel doesn't have scores
|
||||||
* @param rtr
|
* @param message The message to send
|
||||||
* The score&group to use to find the group - use {@link RecipientTestResult#ALL} if the channel doesn't have scores
|
|
||||||
* @param message
|
|
||||||
* The message to send
|
|
||||||
* @param exceptions Platforms where this message shouldn't be sent (same as {@link ChatMessage#getOrigin()}
|
* @param exceptions Platforms where this message shouldn't be sent (same as {@link ChatMessage#getOrigin()}
|
||||||
* @return The event cancelled state
|
* @return The event cancelled state
|
||||||
*/
|
*/
|
||||||
|
@ -333,8 +328,7 @@ public class TBMCChatAPI {
|
||||||
/**
|
/**
|
||||||
* Register a chat channel. See {@link Channel#Channel(String, Color, String, java.util.function.Function)} for details.
|
* Register a chat channel. See {@link Channel#Channel(String, Color, String, java.util.function.Function)} for details.
|
||||||
*
|
*
|
||||||
* @param channel
|
* @param channel A new {@link Channel} to register
|
||||||
* A new {@link Channel} to register
|
|
||||||
*/
|
*/
|
||||||
public static void RegisterChatChannel(Channel channel) {
|
public static void RegisterChatChannel(Channel channel) {
|
||||||
Channel.RegisterChannel(channel);
|
Channel.RegisterChannel(channel);
|
||||||
|
|
Loading…
Reference in a new issue