Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Merge pull request #11 from ProjectG-Plugins/1.2.0
Browse files Browse the repository at this point in the history
1.2.0
  • Loading branch information
Konicai authored Jul 2, 2021
2 parents 14e2d53 + a87afef commit c84746d
Show file tree
Hide file tree
Showing 43 changed files with 2,398 additions and 994 deletions.
3 changes: 2 additions & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ pipeline {
stage('Post') {
steps {
archiveArtifacts 'target/GeyserHub*.jar'
discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}]" , footer: 'ProjectG', link: env.BUILD_URL, result: currentBuild.currentResult, title: "ProjectG/GeyserHub", webhookURL: "https://discordapp.com/api/webhooks/853951848948170762/JFgacab-AdmEfjp05MFfb26a0zIN7kdmVL0f3MMcWodNxMX20xFDqs9TGJJG-aH1Iwpu"
discordSend description: "**Build:** [${currentBuild.id}](${env.BUILD_URL})\n**Status:** [${currentBuild.currentResult}]" , footer: 'ProjectG', link: env.BUILD_URL, result: currentBuild.currentResult, title: "ProjectG/GeyserHub/${env.BRANCH_NAME}", webhookURL: "https://discord.com/api/webhooks/829602972098887720/kscr0LGNfA6cyYEtg0Gkfzu0gD4jmun6x-p3xPW2_xhH3BmOQD6ytc7jFx1j6cuTqlRq"

}

}
Expand Down
78 changes: 41 additions & 37 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>dev.projectg</groupId>
<artifactId>GeyserHub</artifactId>
<version>1.1.0-SNAPSHOT</version>
<version>1.2.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -16,10 +16,6 @@
</properties>

<repositories>
<repository>
<id>papermc</id>
<url>https://papermc.io/repo/repository/maven-public/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
Expand All @@ -34,14 +30,6 @@
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>essentials-snapshots</id>
<url>https://repo.essentialsx.net/snapshots/</url>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
<repository>
<id>opencollab-snapshot-repo</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
Expand All @@ -53,8 +41,8 @@
</snapshots>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>
<dependencies>
Expand All @@ -64,34 +52,16 @@
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>2.2.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.essentialsx</groupId>
<artifactId>EssentialsX</artifactId>
<version>2.19.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.geysermc.cumulus</groupId>
<artifactId>api</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<groupId>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand All @@ -100,7 +70,6 @@
<version>2.10.9</version>
<scope>provided</scope>
</dependency>

</dependencies>
<build>
<plugins>
Expand All @@ -113,6 +82,41 @@
<target>11</target>
</configuration>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>4.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<format>properties</format>
<failOnNoGitDirectory>false</failOnNoGitDirectory>
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
<runOnlyOnce>false</runOnlyOnce>
<verbose>true</verbose>
<skipPoms>false</skipPoms>
<excludeProperties>
<excludeProperty>git.user.*</excludeProperty>
<excludeProperty>git.*.user.*</excludeProperty>
<excludeProperty>git.closest.*</excludeProperty>
<excludeProperty>git.commit.id.describe</excludeProperty>
<excludeProperty>git.commit.id.describe-short</excludeProperty>
<excludeProperty>git.commit.message.short</excludeProperty>
</excludeProperties>
<commitIdGenerationMode>flat</commitIdGenerationMode>
<gitDescribe>
<always>true</always>
</gitDescribe>
</configuration>
</plugin>
</plugins>
</build>
</project>
159 changes: 57 additions & 102 deletions src/main/java/dev/projectg/geyserhub/GeyserHubMain.java
Original file line number Diff line number Diff line change
@@ -1,151 +1,106 @@
package dev.projectg.geyserhub;

import dev.projectg.geyserhub.command.ReloadCommand;
import dev.projectg.geyserhub.command.SelectorCommand;
import dev.projectg.geyserhub.module.menu.BedrockMenu;
import dev.projectg.geyserhub.module.listeners.ItemInteract;
import dev.projectg.geyserhub.module.listeners.SelectorInventory;
import dev.projectg.geyserhub.module.listeners.ItemOnJoin;
import dev.projectg.geyserhub.module.message.BroadCast;
import dev.projectg.geyserhub.command.GeyserHubCommand;
import dev.projectg.geyserhub.config.ConfigManager;
import dev.projectg.geyserhub.module.menu.CommonMenuListeners;
import dev.projectg.geyserhub.module.menu.java.JavaMenuListeners;
import dev.projectg.geyserhub.module.menu.bedrock.BedrockFormRegistry;
import dev.projectg.geyserhub.module.menu.java.JavaMenuRegistry;
import dev.projectg.geyserhub.module.message.Broadcast;
import dev.projectg.geyserhub.module.message.MessageJoin;
import dev.projectg.geyserhub.module.scoreboard.Placeholders;
import dev.projectg.geyserhub.module.scoreboard.ScoreboardManager;
import dev.projectg.geyserhub.module.teleporter.JoinTeleporter;
import dev.projectg.geyserhub.module.world.WorldSettings;
import dev.projectg.geyserhub.utils.FileUtils;
import dev.projectg.geyserhub.utils.bstats.Metrics;
import dev.projectg.geyserhub.utils.bstats.SelectorLogger;
import net.milkbowl.vault.economy.Economy;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import java.io.File;
import java.io.IOException;
import java.util.Objects;
import java.util.Properties;

public class GeyserHubMain extends JavaPlugin {
private static GeyserHubMain plugin;
private SelectorLogger logger;

public static final int configVersion = 3;
private ConfigManager configManager;

@Override
public void onEnable() {
plugin = this;
new Metrics(this, 11427);
logger = SelectorLogger.getLogger();
if (!loadConfiguration()) {
logger.severe("Disabling due to configuration error. Fix the formatting or regenerate a new one");
// getting the logger forces the config to load before our loadConfiguration() is called...
SelectorLogger logger = SelectorLogger.getLogger();
if (!Bukkit.getServer().getPluginManager().isPluginEnabled("PlaceholderAPI")) {
logger.warn("This plugin works best with PlaceholderAPI! Since you don't have it installed, only %player_name% and %player_uuid% will work in the GeyserHub config!");
}

try {
Properties gitProperties = new Properties();
gitProperties.load(FileUtils.getResource("git.properties"));
logger.info("Branch: " + gitProperties.getProperty("git.branch", "Unknown") + ", Commit: " + gitProperties.getProperty("git.commit.id.abbrev", "Unknown"));
} catch (IOException e) {
logger.warn("Unable to load resource: git.properties");
e.printStackTrace();
}

configManager = new ConfigManager();
if (!configManager.loadAllConfigs()) {
logger.severe("Disabling due to configuration error.");
return;
}

// Bungee channel for selector
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");

new BedrockMenu();
// Load forms
BedrockFormRegistry bedrockFormRegistry = new BedrockFormRegistry();
JavaMenuRegistry javaMenuRegistry = new JavaMenuRegistry();

// todo: and add command suggestions/completions, help pages that only shows available commands
Objects.requireNonNull(getCommand("ghub")).setExecutor(new GeyserHubCommand(bedrockFormRegistry, javaMenuRegistry));

// todo: sort all of this, and make checking for enable value in config consistent

Objects.requireNonNull(getCommand("ghteleporter")).setExecutor(new SelectorCommand());
Objects.requireNonNull(getCommand("ghreload")).setExecutor(new ReloadCommand());
// Listeners for the Bedrock and Java menus
Bukkit.getServer().getPluginManager().registerEvents(new CommonMenuListeners(bedrockFormRegistry, javaMenuRegistry), this);
Bukkit.getServer().getPluginManager().registerEvents(new JavaMenuListeners(javaMenuRegistry), this);

Bukkit.getServer().getPluginManager().registerEvents(new ItemInteract(), this);
Bukkit.getServer().getPluginManager().registerEvents(new SelectorInventory(), this);
Bukkit.getServer().getPluginManager().registerEvents(new ItemOnJoin(), this);
// Listener the Join Teleporter module
Bukkit.getServer().getPluginManager().registerEvents(new JoinTeleporter(), this);

// Listener for world settings
Bukkit.getServer().getPluginManager().registerEvents(new WorldSettings(), this);

// load the scoreboard if enabled
if (getConfig().getBoolean("Scoreboard.Enable", false)) {
enableScoreboards();
initializeScoreboard();
}

// Enable the join message if enabled
if (getConfig().getBoolean("Enable-Join-Message", false)) {
Bukkit.getServer().getPluginManager().registerEvents(new MessageJoin(), this);
}
BroadCast.startBroadcastTimer(getServer().getScheduler());
}

@Override
public void onDisable() {
}

private void enableScoreboards() {
if (this.getServer().getPluginManager().getPlugin("Vault") == null) {
Placeholders.vault = 0;
} else {
this.setupPermissions();
}
if (this.getServer().getPluginManager().getPlugin("PlaceholderAPI") == null) {
Placeholders.PAPI = 0;
}
if (this.getServer().getPluginManager().getPlugin("Essentials") == null) {
Placeholders.essentials = 0;
} else {
this.setupEconomy();
}
this.Scheduler();
Bukkit.getServer().getPluginManager().registerEvents(new ScoreboardManager(), this);
// The random interval broadcast module
Broadcast.startBroadcastTimer(getServer().getScheduler());
}

public boolean loadConfiguration() {
File configFile = new File(getDataFolder(), "config.yml");
if (!configFile.exists()) {
try {
configFile.getParentFile().mkdirs();
} catch (SecurityException e) {
e.printStackTrace();
return false;
}
saveResource("config.yml", false);
}
// Get the config but don't actually load it into the main memory config
FileConfiguration config = new YamlConfiguration();
try {
config.load(configFile);
if (!config.contains("Config-Version", true)) {
logger.severe("Config-Version does not exist!");
return false;
} else if (!config.isInt("Config-Version")) {
logger.severe("Config-Version is not an integer!");
return false;
} else if (!(config.getInt("Config-Version") == configVersion)) {
logger.severe("Mismatched config version!");
return false;
} else {
reloadConfig();
return true;
}
} catch (IOException | InvalidConfigurationException e) {
e.printStackTrace();
return false;
}
}
public void Scheduler() {
public void initializeScoreboard() {
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, () -> {
try {
ScoreboardManager.addScoreboard();
} catch (Exception var2) {
var2.printStackTrace();
}
}, 20L, Placeholders.isb * 20L);
}

// todo: I think we can just set vault as a softdepend instead of doing this?

private void setupEconomy() {
RegisteredServiceProvider economyProvider = getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
Placeholders.economy = (Economy) economyProvider.getProvider();
}
}

private void setupPermissions() {
RegisteredServiceProvider permissionProvider = this.getServer().getServicesManager().getRegistration(Permission.class);
if (permissionProvider != null) {
Placeholders.permission = (Permission) permissionProvider.getProvider();
}
}, 20L, ScoreboardManager.REFRESH_RATE * 20L);
}

public static GeyserHubMain getInstance() {
return plugin;
}

}
public ConfigManager getConfigManager() {
return configManager;
}
}
Loading

0 comments on commit c84746d

Please sign in to comment.