Skip to content
This repository was archived by the owner on Oct 30, 2021. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
59 commits
Select commit Hold shift + click to select a range
56be104
Rename package
ParadauxIO Jan 27, 2021
77b1ad4
Rebranding
ParadauxIO Jan 27, 2021
8e45eb9
private!
ParadauxIO Jan 27, 2021
e87288d
Rename package bukkit
ParadauxIO Jan 27, 2021
f26b990
Update HD references in the bukkit config
ParadauxIO Jan 27, 2021
7cde316
Fix main, remove stub commnad
ParadauxIO Jan 27, 2021
34751ca
Package renaming
ParadauxIO Jan 27, 2021
f9e033c
Moving
ParadauxIO Feb 2, 2021
2b4af98
Re-branding maven to conch
ParadauxIO Feb 2, 2021
9e51770
BukkitConch + 2021
ParadauxIO Feb 2, 2021
f9c69ec
BungeeConch + 2021
ParadauxIO Feb 2, 2021
86e9525
More 2021 + branding changes
ParadauxIO Feb 2, 2021
7dcca74
Further 2021 + branding
ParadauxIO Feb 2, 2021
ed7efe4
Velocity Conch + 2021
ParadauxIO Feb 2, 2021
3ffd9eb
Sponge Conch + 2021
ParadauxIO Feb 2, 2021
a24b317
2021 + Automatic rebranding [broken]
ParadauxIO Feb 2, 2021
310efe6
Fix building
ParadauxIO Mar 18, 2021
ba84f08
Remove unused shared chain functionality
ParadauxIO Mar 18, 2021
215b010
Fix taskchain init
ParadauxIO Mar 18, 2021
b3e0812
Renaming some files
ParadauxIO Mar 18, 2021
5acff28
Temporarily disable bungee due to dep errors
ParadauxIO Mar 18, 2021
e38b775
Deploy script
ParadauxIO Mar 18, 2021
2897e56
Manager renaming
ParadauxIO Mar 18, 2021
1ce57bc
Clean up old code
ParadauxIO Mar 18, 2021
d657ea2
Fix dumb event listener loading typo
ParadauxIO Mar 20, 2021
bbd13ff
Actually registering AsyncChat
ParadauxIO Mar 20, 2021
d669a05
Less static abuse
ParadauxIO Mar 20, 2021
39c3022
Changed logging / moved to new discord manager
ParadauxIO Mar 20, 2021
eb9128d
Tidy up
ParadauxIO Mar 20, 2021
3ece070
Changed how placeholders are parsed and events are registered
ParadauxIO Mar 20, 2021
b43d246
Cleaned up configuration loader
ParadauxIO Mar 20, 2021
2f15f73
Add ability to disable/enable UUID hyphen removal
ParadauxIO Mar 20, 2021
ed2f286
Avatars now work
ParadauxIO Mar 20, 2021
180b332
update startup banner
ParadauxIO Mar 20, 2021
2729990
Remove debug output
ParadauxIO Mar 20, 2021
af81478
Discord bot beginnings
ParadauxIO Mar 20, 2021
efbe9d9
Bot Settings now being loaded
ParadauxIO Mar 20, 2021
3b9e2fa
New listener location, because I was stupid and tried to put them in …
ParadauxIO Mar 20, 2021
8ad2d12
Modified how the bot is called upon
ParadauxIO Mar 20, 2021
8816003
Fixed general config issues pertaining to the bot
ParadauxIO Mar 20, 2021
e8e11b6
Changed how events are registered
ParadauxIO Mar 20, 2021
009d162
Fix typo
ParadauxIO Mar 20, 2021
3c28155
Remove debug messages
ParadauxIO Mar 20, 2021
43950cb
disable for now
ParadauxIO Mar 20, 2021
5f674e3
Less static abuse
ParadauxIO Mar 20, 2021
e59c84b
Fix typo
ParadauxIO Mar 20, 2021
7aa49be
Fix message format and change default. plus new placeholders
ParadauxIO Mar 20, 2021
d13c549
Working 2-way communication!
ParadauxIO Mar 20, 2021
a654852
Dev build one state
ParadauxIO Mar 21, 2021
6cc962e
WIP Configuration Updates, Split General into Proxy/Server
ParadauxIO Mar 21, 2021
f64ee0a
Encapsulation!
ParadauxIO Mar 21, 2021
b2f93ea
Modified server setup message (centered)
ParadauxIO Mar 21, 2021
6082046
Changing local deployment setup, implemented velocity
ParadauxIO Mar 21, 2021
3b12842
Support for proxy configuration, modified startup
ParadauxIO Mar 21, 2021
d46be51
Velocity configuration support
ParadauxIO Mar 21, 2021
2b698bf
TaskChain emulator for velocity
ParadauxIO Mar 21, 2021
2a92b58
Preparing 1 way support for velocity
ParadauxIO Mar 21, 2021
ed20643
One-way velocity communication working
ParadauxIO Mar 21, 2021
9e16efd
Beginning to work on discord/minecraft
ParadauxIO Mar 21, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions Bukkit/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Copyright (c) 2020, Rían Errity. All rights reserved.
~ Copyright (c) 2021, Rían Errity. All rights reserved.
~ DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
~
~ This code is free software; you can redistribute it and/or modify it
Expand Down Expand Up @@ -28,17 +28,17 @@
<modelVersion>4.0.0</modelVersion>

<parent>
<artifactId>hiberniadiscord</artifactId>
<groupId>io.paradaux.hiberniadiscord</groupId>
<version>4.0.0</version>
<artifactId>conch</artifactId>
<groupId>io.paradaux.conch</groupId>
<version>1.0.0</version>
</parent>

<artifactId>hiberniadiscord-bukkit</artifactId>
<version>4.0.0</version>
<artifactId>conch-bukkit</artifactId>
<version>1.0.0</version>
<packaging>jar</packaging>

<name>Bukkit</name>
<description>HiberniaDiscord's Bukkit Functionality</description>
<description>Conch's Bukkit Implementation</description>

<build>
<plugins>
Expand Down Expand Up @@ -68,6 +68,7 @@
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>module-info.class</exclude>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
Expand All @@ -78,11 +79,7 @@
<relocations>
<relocation>
<pattern>bstats-bukkit</pattern>
<shadedPattern>io.paradaux.hiberniadiscord.bstats</shadedPattern>
</relocation>
<relocation>
<pattern>hiberniadiscord-common</pattern>
<shadedPattern>io.paradaux.hiberniadiscord.common</shadedPattern>
<shadedPattern>io.paradaux.conch.bstats</shadedPattern>
</relocation>
</relocations>
</configuration>
Expand Down Expand Up @@ -122,15 +119,12 @@
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.8</version>
<scope>compile</scope>
</dependency>

<dependency>
<groupId>io.paradaux.hiberniadiscord</groupId>
<artifactId>hiberniadiscord-common</artifactId>
<version>4.0.0</version>
<scope>compile</scope>
<groupId>io.paradaux.conch</groupId>
<artifactId>conch-common</artifactId>
<version>1.0.0</version>
</dependency>

</dependencies>
</project>
141 changes: 141 additions & 0 deletions Bukkit/src/main/java/io/paradaux/conch/bukkit/BukkitConch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/*
* Copyright (c) 2021, Rían Errity. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 3 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 3 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Rían Errity <rian@paradaux.io> or visit https://paradaux.io
* if you need additional information or have any questions.
* See LICENSE.md for more details.
*/

package io.paradaux.conch.bukkit;

import io.paradaux.conch.bukkit.api.BukkitAPI;
import io.paradaux.conch.bukkit.api.BukkitConfigurationManager;
import io.paradaux.conch.bukkit.bot.DiscordMessageListener;
import io.paradaux.conch.bukkit.listeners.AsyncPlayerChatEventListener;
import io.paradaux.conch.bukkit.managers.MetricsManager;
import io.paradaux.conch.bukkit.managers.TaskManager;
import io.paradaux.conch.bukkit.managers.UpdateManager;
import io.paradaux.conch.common.api.DiscordManager;
import io.paradaux.conch.common.api.I18NLogger;
import io.paradaux.conch.common.api.I18NManager;
import io.paradaux.conch.common.api.config.CachedBotSettings;
import io.paradaux.conch.common.api.config.CachedEventSettings;
import io.paradaux.conch.common.api.config.CachedServerSettings;
import io.paradaux.conch.common.api.config.ConfigurationUtil;
import io.paradaux.conch.common.bot.DiscordBot;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.slf4j.LoggerFactory;

import javax.security.auth.login.LoginException;
import java.nio.file.Path;
import java.util.Locale;
import java.util.ResourceBundle;

public class BukkitConch extends JavaPlugin {

private static BukkitAPI API;

private MetricsManager metrics;
private TaskManager tasks;
private UpdateManager updates;
private DiscordManager discord;
private DiscordBot discordBot;

@Override
public void onEnable() {
getLogger().info("Conch: Initialising locale.");
loadLocale();

I18NLogger.rawInfo("Initialising Taskchain");
tasks = new TaskManager(this);

I18NLogger.rawInfo("Loading Configuration");
loadConfiguration();

I18NLogger.rawInfo("Connecting to discord");
connect();

I18NLogger.rawInfo("Registering events");
registerEvents();

I18NLogger.rawInfo("Registering the API");
registerAPI();

I18NLogger.rawInfo("Starting the discord bot");
startDiscordBot();
}

@Override
public void onDisable() {
I18NLogger.info("shutdown.shutdown-message");
}

public void loadLocale() {
// TODO make additional locales available.
Locale locale = new Locale("en_US");

I18NManager i18NManager = new I18NManager(ResourceBundle.getBundle(I18NManager.RESOURCES_PATH, locale));

I18NLogger.setLogger(LoggerFactory.getLogger("io.paradaux.conch"));
I18NLogger.setI18nManager(i18NManager);

I18NLogger.info("startup.loading-message");
}

public void loadConfiguration() {
Path pluginData = this.getDataFolder().toPath();
BukkitConfigurationManager configurationManager = new BukkitConfigurationManager(pluginData);

configurationManager.deployResources();
configurationManager.loadConfigurationFiles();
}

public void connect() {
CachedServerSettings config = ConfigurationUtil.getGeneralSettings();
discord = new DiscordManager(config.getWebhookUrl(), true);
}

public void registerEvents() {
PluginManager pm = this.getServer().getPluginManager();
CachedEventSettings eventSettings = ConfigurationUtil.getEventSettings();

String serverName = ConfigurationUtil.getGeneralSettings().getServerName();
String messagePrefix = null;

boolean debug = ConfigurationUtil.isDebug();
pm.registerEvents(new AsyncPlayerChatEventListener(discord, debug, serverName, messagePrefix, eventSettings.getOnChatMessage()), this);
}

public void startDiscordBot() {
CachedBotSettings config = ConfigurationUtil.getBotSettings();

try {
discordBot = new DiscordBot();
discordBot.connect();
discordBot.addNewListener(new DiscordMessageListener(tasks, config));
} catch (LoginException ok) {
// TODO log
}

}

public void registerAPI() {
API = new BukkitAPI();
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Rían Errity. All rights reserved.
* Copyright (c) 2021, Rían Errity. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,13 +21,12 @@
* See LICENSE.md for more details.
*/

package io.paradaux.hiberniadiscord.bukkit.api;
package io.paradaux.conch.bukkit.api;

import io.paradaux.hiberniadiscord.common.API;
import io.paradaux.hiberniadiscord.common.api.BotManager;
import io.paradaux.hiberniadiscord.common.api.ConfigurationManager;
import io.paradaux.hiberniadiscord.common.api.DiscordManager;
import io.paradaux.hiberniadiscord.common.api.I18NManager;
import io.paradaux.conch.common.API;
import io.paradaux.conch.common.api.ConfigurationManager;
import io.paradaux.conch.common.api.DiscordManager;
import io.paradaux.conch.common.api.I18NManager;

public class BukkitAPI implements API {

Expand All @@ -36,11 +35,6 @@ public DiscordManager getDiscordManager() {
return null;
}

@Override
public BotManager getBotManager() {
return null;
}

@Override
public I18NManager getI18nManager() {
return null;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Rían Errity. All rights reserved.
* Copyright (c) 2021, Rían Errity. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,48 +21,41 @@
* See LICENSE.md for more details.
*/

package io.paradaux.hiberniadiscord.bukkit.api;
package io.paradaux.conch.bukkit.api;

import io.paradaux.hiberniadiscord.common.api.ConfigurationManager;
import io.paradaux.hiberniadiscord.common.api.I18NLogger;
import io.paradaux.hiberniadiscord.common.api.config.*;
import io.paradaux.hiberniadiscord.common.api.exceptions.NoSuchResourceException;
import org.bukkit.plugin.Plugin;
import io.paradaux.conch.common.api.ConfigurationManager;
import io.paradaux.conch.common.api.I18NLogger;
import io.paradaux.conch.common.api.config.CachedBotSettings;
import io.paradaux.conch.common.api.config.CachedEventSettings;
import io.paradaux.conch.common.api.config.CachedServerSettings;
import io.paradaux.conch.common.api.config.ConfigurationLoader;
import io.paradaux.conch.common.api.config.ConfigurationUtil;
import io.paradaux.conch.common.api.exceptions.NoSuchResourceException;
import org.spongepowered.configurate.ConfigurateException;

import java.io.File;
import java.nio.file.Path;

public class BukkitConfigurationManager extends ConfigurationManager {

CachedSettings generalSettings;
CachedEventSettings eventSettings;
CachedBotSettings botSettings;
private CachedServerSettings generalSettings;
private CachedEventSettings eventSettings;
private CachedBotSettings botSettings;

ConfigurationLoader loader = getConfigurationLoader();
Plugin plugin;
private ConfigurationLoader loader = getConfigurationLoader();
private Path configurationDirectory;

/**
* BukkitConfigurationLoader uses Sponge's Configurate to load the HOCON values in the three settings files.
*
* @param configurationDirectory The directory in which the configuration files are being saved to.
*/
public BukkitConfigurationManager(Path configurationDirectory, Plugin plugin) {
public BukkitConfigurationManager(Path configurationDirectory) {
super(configurationDirectory);
this.plugin = plugin;
this.configurationDirectory = configurationDirectory;
}

@Override
public void deployResource() {
File configurationDir = plugin.getDataFolder();
if (!plugin.getDataFolder().exists()) {
boolean result = configurationDir.mkdir();

if (!result) {
I18NLogger.error("configuration.make-plugin-directory-failure");
}
}

public void deployResources() {
try {
if (!loader.doesBotSettingsExist()) {
exportResource(ConfigurationLoader.BOT_SETTINGS_FILE_NAME, loader.getBotSettingsPath().toString());
Expand All @@ -88,12 +81,11 @@ public void loadConfigurationFiles() {
eventSettings = loader.loadEventSettings();
botSettings = loader.loadBotSettings();
} catch (ConfigurateException exception) {
I18NLogger.error("");
I18NLogger.error(""); // TODO add error for failure to load configuration
return;
}
ConfigurationUtil.loadConfigurationValues(generalSettings, eventSettings, botSettings);

System.out.println("Test: " + eventSettings.getOnChatMessage().getEventName());
ConfigurationUtil.loadConfigurationValues(generalSettings, eventSettings, botSettings);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020, Rían Errity. All rights reserved.
* Copyright (c) 2021, Rían Errity. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
Expand All @@ -21,7 +21,7 @@
* See LICENSE.md for more details.
*/

package io.paradaux.hiberniadiscord.bukkit.api;
package io.paradaux.conch.bukkit.api;

import me.clip.placeholderapi.PlaceholderAPI;
import org.bukkit.OfflinePlayer;
Expand Down
Loading