Skip to content

Commit

Permalink
Fix empty console messages, improve usage message, fix dependency issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Siebrenvde committed Jul 30, 2020
1 parent 6f4496e commit f98ee9a
Show file tree
Hide file tree
Showing 22 changed files with 102 additions and 233 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
.idea
target
src/test/
StaffChat.iml
StaffChat.iml
build.sh
output
build-files
21 changes: 6 additions & 15 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>io.github.siebrenvde</groupId>
<artifactId>StaffChat</artifactId>
<version>1.4.3</version>
<version>1.4.4</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
Expand All @@ -21,7 +21,7 @@
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>http://jcenter.bintray.com</url>
<url>https://jcenter.bintray.com</url>
</repository>
<repository>
<id>bungeecord-repo</id>
Expand All @@ -40,9 +40,10 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.8.3_464</version>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>3.8.3_464</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.mcdb</groupId>
Expand All @@ -64,12 +65,6 @@
<type>javadoc</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.moandjiezana.toml</groupId>
<artifactId>toml4j</artifactId>
<version>0.7.2</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -84,10 +79,6 @@
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadedArtifactAttached>true</shadedArtifactAttached>
<shadedClassifierName>jar-with-dependencies</shadedClassifierName> <!-- Any name that makes sense -->
</configuration>
</execution>
</executions>
</plugin>
Expand Down
95 changes: 18 additions & 77 deletions src/main/java/io/github/siebrenvde/staffchat/Bungee.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.siebrenvde.staffchat;

import com.moandjiezana.toml.Toml;
import eu.mcdb.spicord.Spicord;
import io.github.siebrenvde.staffchat.commands.bungee.HelpOp;
import io.github.siebrenvde.staffchat.commands.bungee.Report;
Expand All @@ -25,15 +24,17 @@

public class Bungee extends Plugin {

public BungeeAddon addon;

public List<ProxiedPlayer> toggledPlayers;

public void onEnable() {
addon = new BungeeAddon(this);
toggledPlayers = new ArrayList<>();
registerCommands();
registerConfig();
getProxy().getPluginManager().registerListener(this, new BungeeMessageEvent(this));
Spicord.getInstance().getAddonManager().registerAddon(new BungeeAddon(this));
Spicord.getInstance().getAddonManager().registerAddon(addon);
}

private void registerCommands(){
Expand Down Expand Up @@ -67,120 +68,60 @@ private void registerConfig() {
}

public String generalLayout(String msg, String player, String playerDN, String server) {

String ccMsg = BungeeUtils.translateCC(msg);

String rawMsg = config.getString("general-layout")
return BungeeUtils.translateCC(config.getString("general-layout")
.replace("%displayname%", playerDN)
.replace("%username%", player)
.replace("%server%", server)
.replace("%message%", ccMsg);

String message = BungeeUtils.translateCC(rawMsg);

return message;
.replace("%message%", msg));
}

public String minecraftLayout(String msg, User user) {

String p = BungeeUtils.spicordPrefix();
String p = addon.prefix;
String dscMsg = msg.replaceFirst(p + "sc ", "").replaceFirst(p + "staffchat ", "").replaceFirst(p + "schat ", "").replaceFirst(p + "staffc ", "");

String rawMsg = config.getString("minecraft-layout")
return BungeeUtils.translateCC(config.getString("minecraft-layout")
.replace("%username%", user.getName())
.replace("%usertag%", user.getAsTag())
.replace("%message%", dscMsg);

String message = BungeeUtils.translateCC(rawMsg);

return message;
.replace("%message%", dscMsg));
}

public String discordLayout(String msg, String player, String playerDN, String server) {

String dscMsg = BungeeUtils.removeCC(msg);

String message = config.getString("discord-layout")
return config.getString("discord-layout")
.replace("%displayname%", playerDN)
.replace("%username%", player)
.replace("%server%", server)
.replace("%message%", dscMsg);

return message;
.replace("%message%", BungeeUtils.removeCC(msg));
}

public String rmdLayout(String msg, String reporter, String reported, String server) {

String dscMsg = BungeeUtils.removeCC(msg);

String message = config.getString("report-message-discord")
return config.getString("report-message-discord")
.replace("%reporter%", reporter)
.replace("%reported%", reported)
.replace("%server%", server)
.replace("%reason%", dscMsg);

return message;
.replace("%reason%", BungeeUtils.removeCC(msg));
}

public String rmLayout(String msg, String reporter, String reported, String server) {

String ccMsg = BungeeUtils.translateCC(msg);

String rawMsg = config.getString("report-message")
return BungeeUtils.translateCC(config.getString("report-message")
.replace("%reporter%", reporter)
.replace("%reported%", reported)
.replace("%server%", server)
.replace("%reason%", ccMsg);

String message = BungeeUtils.translateCC(rawMsg);

return message;
.replace("%reason%", msg));
}

public String homdLayout(String msg, String player, String server) {

String dscMsg = BungeeUtils.removeCC(msg);

String message = config.getString("helpop-message-discord")
return config.getString("helpop-message-discord")
.replace("%player%", player)
.replace("%server%", server)
.replace("%message%", dscMsg);

return message;
.replace("%message%", BungeeUtils.removeCC(msg));
}

public String homLayout(String msg, String player, String server) {

String ccMsg = BungeeUtils.translateCC(msg);

String rawMsg = config.getString("helpop-message")
return BungeeUtils.translateCC(config.getString("helpop-message")
.replace("%player%", player)
.replace("%server%", server)
.replace("%message%", ccMsg);

String message = BungeeUtils.translateCC(rawMsg);

return message;
}

public static Integer configNum() {
File spFile;
spFile = new File(ProxyServer.getInstance().getPluginsFolder() + "/Spicord/config.toml");
Toml cfg = new Toml().read(spFile);

int num = 0;
int i = 0;

while(i == 0) {
if(cfg.getList("bots[" + num + "].addons").contains("staffchat")) {
i++;
}
else {
num++;
}
return num;
}
return num;
.replace("%message%", msg));
}

}
98 changes: 19 additions & 79 deletions src/main/java/io/github/siebrenvde/staffchat/Spigot.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package io.github.siebrenvde.staffchat;

import com.moandjiezana.toml.Toml;
import eu.mcdb.spicord.Spicord;
import io.github.siebrenvde.staffchat.commands.spigot.HelpOp;
import io.github.siebrenvde.staffchat.commands.spigot.Report;
Expand All @@ -9,25 +8,26 @@
import io.github.siebrenvde.staffchat.events.SpigotMessageEvent;
import io.github.siebrenvde.staffchat.util.SpigotUtils;
import net.dv8tion.jda.core.entities.User;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

public class Spigot extends JavaPlugin {

public SpigotAddon addon;

public List<Player> toggledPlayers;

public void onEnable() {
addon = new SpigotAddon(this);
toggledPlayers = new ArrayList<>();
saveDefaultConfig();
registerCommands();
getServer().getPluginManager().registerEvents(new SpigotMessageEvent(this), this);
Spicord.getInstance().getAddonManager().registerAddon(new SpigotAddon(this));
Spicord.getInstance().getAddonManager().registerAddon(addon);
}

private void registerCommands() {
Expand All @@ -39,114 +39,54 @@ private void registerCommands() {
private FileConfiguration config = getConfig();

public String generalLayout(String msg, String player, String playerDN) {

String ccMsg = SpigotUtils.translateCC(msg);

String rawMsg = config.getString("general-layout")
return SpigotUtils.translateCC(config.getString("general-layout")
.replace("%displayname%", playerDN)
.replace("%username%", player)
.replace("%message%", ccMsg);

String message = SpigotUtils.translateCC(rawMsg);

return message;
.replace("%message%", msg));
}

public String minecraftLayout(String msg, User user) {

String p = SpigotUtils.spicordPrefix();
String p = addon.prefix;
String dscMsg = msg.replaceFirst(p + "sc ", "").replaceFirst(p + "staffchat ", "").replaceFirst(p + "schat ", "").replaceFirst(p + "staffc ", "");

String rawMsg = config.getString("minecraft-layout")
return SpigotUtils.translateCC(config.getString("minecraft-layout")
.replace("%username%", user.getName())
.replace("%usertag%", user.getAsTag())
.replace("%message%", dscMsg);

String message = SpigotUtils.translateCC(rawMsg);

return message;
.replace("%message%", dscMsg));
}

public String discordLayout(String msg, String player, String playerDN) {

String dscMsg = SpigotUtils.removeCC(msg);

String message = config.getString("discord-layout")
return config.getString("discord-layout")
.replace("%displayname%", playerDN)
.replace("%username%", player)
.replace("%message%", dscMsg);

return message;
.replace("%message%", SpigotUtils.removeCC(msg));
}

public String rmdLayout(String msg, String reporter, String reported) {

String dscMsg = SpigotUtils.removeCC(msg);

String message = config.getString("report-message-discord")
return config.getString("report-message-discord")
.replace("%reporter%", reporter)
.replace("%reported%", reported)
.replace("%reason%", dscMsg);

return message;
.replace("%reason%", SpigotUtils.removeCC(msg));
}

public String rmLayout(String msg, String reporter, String reported) {

String ccMsg = SpigotUtils.translateCC(msg);

String rawMsg = config.getString("report-message")
return SpigotUtils.translateCC(config.getString("report-message")
.replace("%reporter%", reporter)
.replace("%reported%", reported)
.replace("%reason%", ccMsg);

String message = SpigotUtils.translateCC(rawMsg);

return message;
.replace("%reason%", msg));
}

public String homdLayout(String msg, String player) {

String dscMsg = SpigotUtils.removeCC(msg);

String message = config.getString("helpop-message-discord")
return config.getString("helpop-message-discord")
.replace("%player%", player)
.replace("%message%", dscMsg);

return message;
.replace("%message%", SpigotUtils.removeCC(msg));
}

public String homLayout(String msg, String player) {

String ccMsg = SpigotUtils.translateCC(msg);

String rawMsg = config.getString("helpop-message")
return SpigotUtils.translateCC(config.getString("helpop-message")
.replace("%player%", player)
.replace("%message%", ccMsg);

String message = SpigotUtils.translateCC(rawMsg);

return message;
}

public static Integer configNum() {
File spFile;
spFile = new File(Bukkit.getPluginManager().getPlugin("Spicord").getDataFolder() + "/config.toml");
Toml cfg = new Toml().read(spFile);

int num = 0;
int i = 0;

while(i == 0) {
if(cfg.getList("bots[" + num + "].addons").contains("staffchat")) {
i++;
}
else {
num++;
}
return num;
}
return num;
.replace("%message%", msg));
}

}
Loading

0 comments on commit f98ee9a

Please sign in to comment.