Use command channels and fix dependencies

This commit is contained in:
Norbi Peti 2020-03-15 03:10:27 +01:00
parent 45a1ba4fe1
commit 1b747ab99f
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56
4 changed files with 10 additions and 30 deletions

20
pom.xml
View file

@ -55,7 +55,7 @@
<excludes>
</excludes> <!-- http://stackoverflow.com/questions/28458058/maven-shade-plugin-exclude-a-dependency-and-all-its-transitive-dependencies -->
</artifactSet>
<minimizeJar>true</minimizeJar>
<!-- <minimizeJar>true</minimizeJar> Tried using filters but we need pretty much all of that 12 MB -->
<relocations>
<relocation>
<pattern>io.netty</pattern>
@ -176,12 +176,6 @@
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.spigotmc..</groupId>
<artifactId>spigot</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.discord4j/Discord4J -->
<dependency>
<groupId>com.discord4j</groupId>
@ -225,13 +219,6 @@
</exclusion>
</exclusions>
</dependency> -->
<!-- https://mvnrepository.com/artifact/org.objenesis/objenesis -->
<dependency>
<groupId>org.objenesis</groupId>
<artifactId>objenesis</artifactId>
<version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.vdurmont</groupId>
<artifactId>emoji-java</artifactId>
@ -249,6 +236,11 @@
<version>v4.4</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>3.0.0</version>
</dependency>
</dependencies>
<profiles>

View file

@ -83,7 +83,7 @@ public class PlayerListWatcher {
tpt = icbcl.getMethod("getString");
}
val toPlainText = tpt;
mock = Mockito.mock(dplc, new Answer() { // Cannot call super constructor
mock = Mockito.mock(dplc, Mockito.withSettings().defaultAnswer(new Answer<>() { // Cannot call super constructor
@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
final Method method = invocation.getMethod();
@ -140,7 +140,7 @@ public class PlayerListWatcher {
TBMCCoreAPI.SendException("Failed to broadcast message sent to all players - hacking failed.", e);
}
}
});
}).stubOnly());
plist = currentPL;
for (var plc = dplc; plc != null; plc = plc.getSuperclass()) { //Set all fields
for (var f : plc.getDeclaredFields()) {

View file

@ -1,4 +0,0 @@
package buttondevteam.discordplugin.listeners;
public interface DiscordListener {
}

View file

@ -361,19 +361,13 @@ public class MCChatListener implements Listener {
+ "ou can access all of your regular commands (even offline) in private chat: DM me `mcchat`!");
return true;
}
val ev = new TBMCCommandPreprocessEvent(dsender, dmessage);
val channel = clmd == null ? user.channel().get() : clmd.mcchannel;
val ev = new TBMCCommandPreprocessEvent(dsender, channel, dmessage, clmd == null ? dsender : clmd.dcp);
Bukkit.getScheduler().runTask(DiscordPlugin.plugin, () -> Bukkit.getPluginManager().callEvent(ev));
if (ev.isCancelled())
return true;
int spi = cmdlowercased.indexOf(' ');
final String topcmd = spi == -1 ? cmdlowercased : cmdlowercased.substring(0, spi);
Bukkit.getScheduler().runTask(DiscordPlugin.plugin, //Commands need to be run sync
() -> {
val channel = user.channel();
val chtmp = channel.get();
if (clmd != null) {
channel.set(clmd.mcchannel); //Hack to send command in the channel
} //TODO: Permcheck isn't implemented for commands
try {
String mcpackage = Bukkit.getServer().getClass().getPackage().getName();
if (mcpackage.contains("1_12"))
@ -386,8 +380,6 @@ public class MCChatListener implements Listener {
TBMCCoreAPI.SendException("A class is not found when trying to run command " + cmd + "!", e);
}
Bukkit.getLogger().info(dsender.getName() + " issued command from Discord: /" + cmd);
if (clmd != null)
channel.set(chtmp);
});
return false;
}