Skip to content

Commit

Permalink
Merge pull request #174 from beanbeanjuice/development
Browse files Browse the repository at this point in the history
v0.5.0 Integration
  • Loading branch information
beanbeanjuice committed Jun 9, 2024
2 parents 2302b71 + 6819ae1 commit 0899e21
Show file tree
Hide file tree
Showing 39 changed files with 977 additions and 70 deletions.
66 changes: 51 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<img src="https://github.com/beanbeanjuice/SimpleProxyChat/blob/master/Images/Finished/SimpleProxyChat.png?raw=true" alt="SimpleProxyChat Logo"/>
</p>
<center>
A simple plugin to allow <b>global</b> <i>cross-server</i> communication and messaging with support for <b>PlaceholderAPI</b>, <b>LuckPerms</b>, <b>LiteBans</b>, <b>AdvancedBan</b>, <b>NetworkManager</b>, and <b>Discord</b>.
This is a Bungeecord Chat Sync, Velocity Chat Sync, and Proxy Chat Sync plugin. It is a simple plugin to allow <b>global</b> <i>cross-server</i> communication and messaging with support for <b>PlaceholderAPI</b>, <b>LuckPerms</b>, <b>LiteBans</b>, <b>AdvancedBan</b>, <b>NetworkManager</b>, and <b>Discord</b>.
</center>

---
Expand Down Expand Up @@ -90,9 +90,11 @@ BOT-TOKEN: "TOKEN_HERE"
CHANNEL-ID: "GLOBAL_CHANNEL_ID"

bot-activity:
# Valid Types: PLAYING, STREAMING, LISTENING, WATCHING, COMPETING
type: "COMPETING"
text: "SimpleProxyChat by beanbeanjuice"
# Valid Types: ONLINE, DO_NOT_DISTURB, IDLE, INVISIBLE
status: ONLINE
# Valid Types: PLAYING, STREAMING, LISTENING, WATCHING, COMPETING
type: "COMPETING"
text: "SimpleProxyChat by beanbeanjuice"

# The amount of seconds to check if a server is online/offline.
# Smaller numbers can cause errors. Beware.
Expand All @@ -102,9 +104,9 @@ server-update-interval: 3
# It MUST be the same name you have in your bungee/velocity config.
# Simply set it to disabled: disabled to disable it.
aliases:
ServerInConfigExample: ServerAliasExample
hub: Hub1
smp: smp1
ServerInConfigExample: ServerAliasExample
hub: Hub1
smp: smp1

# Whether to use the permission system.
# Some permissions (denoted with ➕) are always active even if this is false.
Expand All @@ -117,6 +119,9 @@ aliases:
# simpleproxychat.toggle.chat - Toggle proxy chat for a single server. ➕
# simpleproxychat.toggle.chat.all - Toggle proxy chat for all servers. ➕
# simpleproxychat.reload - Reload the config. ➕
# simpleproxychat.ban - Ban a player from the proxy. ➕
# simpleproxychat.unban - Unban a player from the proxy. ➕
# simpleproxychat.whisper - Whisper to another player on the proxy. ➕
use-permissions: false

# Only messages that start with this character will be sent through the plugin.
Expand All @@ -134,18 +139,32 @@ use-fake-messages: true
# Format: https://docs.oracle.com/javase/8/docs/api/java/time/format/DateTimeFormatter.html
# Timezone: https://www.joda.org/joda-time/timezones.html
timestamp:
# If your server is prone to getting off-sync on the time you can use an API.
# WARNING: Using the API will make messages somewhat longer to send.
# Additionally, the maximum accuracy will only be up to 1 minute, rather than seconds.
use-api: false
format: "hh:mm a"
timezone: "America/Los_Angeles"
# If your server is prone to getting off-sync on the time you can use an API.
# WARNING: Using the API will make messages somewhat longer to send.
# Additionally, the maximum accuracy will only be up to 1 minute, rather than seconds.
use-api: false
format: "hh:mm a"
timezone: "America/Los_Angeles"

# True if you will be using the helper plugin.
use-helper: false

update-notifications: true

# It is HIGHLY recommended to use a more robust proxy-wide banning system such as LiteBans or AdvancedBan.
# However, if you would rather a light-weight, simple, banning system. You can enable it here.
# A FULL PROXY RESTART IS REQUIRED TO USE THIS.
use-simple-proxy-chat-banning-system: false

# These require a restart in order to take place.
commands:
whisper-aliases:
- "spc-msg"
reply-aliases:
- "spc-r"

# DO NOT TOUCH THIS
file-version: 10
file-version: 12
```

**messages.yml**
Expand All @@ -171,10 +190,15 @@ minecraft:
chat:
enabled: true
message: "&8[&3%server%&8] &e%player% &9» &7%message%"
vanished: "&cYou cannot send proxy messages while vanished. Your message must end with a '&e/&c' to speak."
switch:
enabled: true
default: "&e%player% &7moved from &c%from% &7to &a%to%&7."
no-from: "&e%player% &7moved &7to &a%to%&7."
whisper:
send: "&8[&dyou&8] &f⇒ &8[&d%receiver%&8] &9» &e%message%"
receive: "&8[&d%sender%&8] &f⇒ &8[&dyou&8] &9» &e%message%"
error: "&c/spc-whisper (user) (message)"
discord:
enabled: true
message: "**%server%** %player% » %message%"
Expand All @@ -197,6 +221,11 @@ minecraft:
all:
locked: "%plugin-prefix% &cAll servers will no longer send proxy chat messages."
unlocked: "%plugin-prefix% &aAll servers will now send proxy chat messages."
proxy-ban:
usage: "%plugin-prefix% &c/(un)ban (player)"
banned: "%plugin-prefix% &c%player% &7has been banned."
unbanned: "%plugin-prefix% &c%player% &7has been unbanned."
login-message: "&cYou have been banned from the proxy."

# Discord Stuff
discord:
Expand Down Expand Up @@ -243,7 +272,7 @@ console:
update-message: "&7There is an update! You are on &c%old%. New version is &a%new%&7: &6%link%"

# DO NOT TOUCH THIS
file-version: 7
file-version: 8
```

---
Expand All @@ -254,6 +283,8 @@ file-version: 7

* `/spc-reload` - Reloads the config files.
* `/spc-chat` - Lock/unlock the chat.
* `/spc-whipser` - Send a private message to someone.
* `/spc-reply` - Reply to a private message without specifying a user.

---

Expand All @@ -270,6 +301,9 @@ file-version: 7
* `simpleproxychat.toggle.chat` - Toggle proxy chat for a single server.
* `simpleproxychat.toggle.chat.all` - Toggle proxy chat for all servers.
* `simpleproxychat.reload` - Reload the config.
* `simpleproxychat.ban` - Ban someone.
* `simpleproxychat.unban` - Unban someone.
* `simpleproxychat.whisper` - Private messaging permissions.

---

Expand All @@ -285,6 +319,8 @@ file-version: 7
* `%from%` - The server the player just disconnected from. Uses the alias if one is specified.
* `%original_from%` - Same as `%from%`, but does not use the alias.
* `%player%` - The player's Minecraft username.
* `%sender%` - (PRIVATE MESSAGING ONLY) The person sending the private message.
* `%receiver%` - (PRIVATE MESSAGING ONLY) The person receiving the private message.
* `%user%` - The player's Discord username.
* `%nick%` - The player's Discord nickname.
* `%role%` - The player's Discord role.
Expand Down
10 changes: 9 additions & 1 deletion SimpleProxyChatHelper/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ plugins {
}

group = "com.beanbeanjuice"
version = "0.0.1"
version = "0.0.2"

java {
sourceCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -47,6 +47,12 @@ dependencies {
// Lombok
compileOnly("org.projectlombok", "lombok", "1.18.32")
annotationProcessor("org.projectlombok", "lombok", "1.18.32")

// bStats
implementation("org.bstats", "bstats-bukkit", "3.0.2")

// Artifact Version Comparison
implementation("org.apache.maven", "maven-artifact", "3.9.7")
}

configure<ProcessResources>("processResources") {
Expand All @@ -61,6 +67,8 @@ inline fun <reified C> Project.configure(name: String, configuration: C.() -> Un

tasks.withType<ShadowJar> {
minimize()
relocate("org.bstats", "com.beanbeanjuice.simpleproxychathelper.libs.org.bstats")
relocate("org.apache.maven", "com.beanbeanjuice.simpleproxychathelper.libs.org.apache.maven")
archiveBaseName.set(rootProject.name)
archiveClassifier.set("")
archiveVersion.set(version as String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@
import com.beanbeanjuice.simpleproxychathelper.utility.UpdateChecker;
import lombok.Getter;

import net.md_5.bungee.api.ChatMessageType;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;

import java.util.concurrent.TimeUnit;

public final class SimpleProxyChatHelper extends JavaPlugin {

private Metrics metrics;
@Getter private Config options;
@Getter private static final String subChannel = "SimpleProxyChat";

Expand All @@ -28,6 +27,7 @@ public void onEnable() {

this.getLogger().info("The plugin has been enabled!");

metrics = new Metrics(this, 22052);
startUpdateChecker();
}

Expand All @@ -46,7 +46,7 @@ private void startUpdateChecker() {
(message) -> this.getLogger().info(message)
);

Bukkit.getScheduler().runTaskTimerAsynchronously(this, updateChecker::checkUpdate, 0, 20 * 60 * 12);
Bukkit.getScheduler().runTaskTimerAsynchronously(this, updateChecker::checkUpdate, 0, 864000); // 864000 ticks = 12 hours
}

private void setupPluginMessaging() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.beanbeanjuice.simpleproxychathelper.utility;

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;

import java.io.IOException;
import java.io.InputStream;
import java.net.URI;
Expand Down Expand Up @@ -27,9 +29,9 @@ public Optional<String> getUpdate() {

public void checkUpdate() {
getUpdate().ifPresent((spigotVersion) -> {
if (currentVersion.equalsIgnoreCase(spigotVersion)) return;
if (compare(currentVersion, spigotVersion) >= 0) return;

String message = String.format("[SimpleProxyChat] There is an update! You are on %s. The new one is %s! %s",
String message = String.format("There is an update! You are on %s. The new one is %s! %s",
currentVersion,
spigotVersion,
"https://www.spigotmc.org/resources/116966/");
Expand All @@ -38,4 +40,11 @@ public void checkUpdate() {
});
}

public static int compare(final String version1, final String version2) {
DefaultArtifactVersion v1 = new DefaultArtifactVersion(version1);
DefaultArtifactVersion v2 = new DefaultArtifactVersion(version2);

return v1.compareTo(v2);
}

}
1 change: 1 addition & 0 deletions SimpleProxyChatHelper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ depend: [PlaceholderAPI]
authors: [beanbeanjuice]
description: A helper plugin for the SimpleProxyChat proxy plugin.
website: https://www.github.com/beanbeanjuice/SimpleProxyChat
api-version: 1.20
9 changes: 6 additions & 3 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ plugins {
}

group = "com.beanbeanjuice"
version = "0.4.2"
version = "0.5.0"

java {
sourceCompatibility = JavaVersion.VERSION_17
Expand Down Expand Up @@ -101,6 +101,9 @@ dependencies {

// Timestamp
implementation("joda-time", "joda-time", "2.12.7")

// Artifact Version Comparison
implementation("org.apache.maven", "maven-artifact", "3.9.7")
}

configure<ProcessResources>("processResources") {
Expand Down Expand Up @@ -234,9 +237,9 @@ hangarPublish {

tasks.withType<ShadowJar> {
minimize()
relocate("dev.dejvokep.boostedyaml", "com.beanbeanjuice.simpleproxychat.libs.dev.dejvokep.boostedyaml")
relocate("org.bstats", "com.beanbeanjuice.simpleproxychat.libs.org.bstats")
relocate("net.dv8tion", "com.beanbeanjuice.simpleproxychat.libs.net.dv8tion")
relocate("dev.dejvokep", "com.beanbeanjuice.simpleproxychat.libs.dev.dejvokep")
relocate("org.bstats", "com.beanbeanjuice.simpleproxychat.libs.org.bstats")
archiveBaseName.set(rootProject.name)
archiveClassifier.set("")
archiveVersion.set(version as String)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.beanbeanjuice.simpleproxychat;

import com.beanbeanjuice.simpleproxychat.commands.bungee.BungeeChatToggleCommand;
import com.beanbeanjuice.simpleproxychat.commands.bungee.BungeeReloadCommand;
import com.beanbeanjuice.simpleproxychat.commands.bungee.*;
import com.beanbeanjuice.simpleproxychat.commands.bungee.ban.BungeeBanCommand;
import com.beanbeanjuice.simpleproxychat.commands.bungee.ban.BungeeUnbanCommand;
import com.beanbeanjuice.simpleproxychat.socket.bungee.BungeeCordPluginMessagingListener;
import com.beanbeanjuice.simpleproxychat.utility.Helper;
import com.beanbeanjuice.simpleproxychat.utility.helper.Helper;
import com.beanbeanjuice.simpleproxychat.utility.helper.WhisperHandler;
import com.beanbeanjuice.simpleproxychat.utility.BanHelper;
import com.beanbeanjuice.simpleproxychat.utility.config.Permission;
import com.beanbeanjuice.simpleproxychat.utility.epoch.EpochHelper;
import com.beanbeanjuice.simpleproxychat.utility.listeners.bungee.BungeeServerListener;
Expand Down Expand Up @@ -34,6 +37,8 @@ public final class SimpleProxyChatBungee extends Plugin {
@Getter private Bot discordBot;
@Getter private Metrics metrics;
@Getter private BungeeServerListener serverListener;
@Getter private WhisperHandler whisperHandler;
@Getter private BanHelper banHelper;

@Override
public void onEnable() {
Expand Down Expand Up @@ -73,8 +78,7 @@ public void onEnable() {

// bStats Stuff
this.getLogger().info("Starting bStats... (IF ENABLED)");
int pluginId = 21146;
this.metrics = new Metrics(this, pluginId);
this.metrics = new Metrics(this, 21146);

startPluginMessaging();

Expand Down Expand Up @@ -103,6 +107,8 @@ private void startUpdateChecker() {
config,
currentVersion,
(message) -> {
if (!config.getAsBoolean(ConfigDataKey.UPDATE_NOTIFICATIONS)) return;

this.getLogger().info(Helper.sanitize(message));

Component minimessage = MiniMessage.miniMessage().deserialize(config.getAsString(ConfigDataKey.PLUGIN_PREFIX) + message);
Expand Down Expand Up @@ -149,6 +155,15 @@ private void hookPlugins() {
config.overwrite(ConfigDataKey.NETWORKMANAGER_ENABLED, true);
getLogger().info("NetworkManager support has been enabled.");
}

// Registering the Simple Ban System
if (!config.getAsBoolean(ConfigDataKey.LITEBANS_ENABLED) && !config.getAsBoolean(ConfigDataKey.ADVANCEDBAN_ENABLED) && config.getAsBoolean(ConfigDataKey.USE_SIMPLE_PROXY_CHAT_BANNING_SYSTEM)) {
getLogger().info("LiteBans and AdvancedBan not found. Using the built-in banning system for SimpleProxyChat...");
banHelper = new BanHelper(this.getDataFolder());
banHelper.initialize();
} else {
config.overwrite(ConfigDataKey.USE_SIMPLE_PROXY_CHAT_BANNING_SYSTEM, false);
}
}

private void registerListeners() {
Expand All @@ -163,11 +178,21 @@ private void registerListeners() {

serverListener = new BungeeServerListener(this, chatHandler);
this.getProxy().getPluginManager().registerListener(this, serverListener);

whisperHandler = new WhisperHandler();
}

private void registerCommands() {
this.getProxy().getPluginManager().registerCommand(this, new BungeeReloadCommand(this, config));
this.getProxy().getPluginManager().registerCommand(this, new BungeeChatToggleCommand(this, config));
this.getProxy().getPluginManager().registerCommand(this, new BungeeWhisperCommand(this, config, config.getAsArrayList(ConfigDataKey.WHISPER_ALIASES).toArray(new String[0])));
this.getProxy().getPluginManager().registerCommand(this, new BungeeReplyCommand(this, config, config.getAsArrayList(ConfigDataKey.REPLY_ALIASES).toArray(new String[0])));

// Only enable when needed.
if (config.getAsBoolean(ConfigDataKey.USE_SIMPLE_PROXY_CHAT_BANNING_SYSTEM)) {
this.getProxy().getPluginManager().registerCommand(this, new BungeeBanCommand(this));
this.getProxy().getPluginManager().registerCommand(this, new BungeeUnbanCommand(this));
}
}

private void startPluginMessaging() {
Expand Down
Loading

0 comments on commit 0899e21

Please sign in to comment.