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

Commit

Permalink
Strip menu/form/accessitem components
Browse files Browse the repository at this point in the history
  • Loading branch information
Konicai committed Jun 4, 2022
1 parent ab554d9 commit 97c0855
Show file tree
Hide file tree
Showing 33 changed files with 166 additions and 2,265 deletions.
22 changes: 5 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,27 @@
[![Discord](https://img.shields.io/discord/853331530004299807?color=7289da&label=discord&logo=discord&logoColor=white)](https://discord.gg/M2SvqCu4e9)
[![License](https://img.shields.io/badge/License-GPL-orange)](https://github.com/ProjectG-Plugins/GeyserUpdater/blob/master/LICENSE)


# GeyserHub
**Note: This plugin has been superseded by [CrossplatForms](https://github.com/ProjectG-Plugins/CrossplatForms). GeyserHub will eventually be stripped of its form, menu, and access item capabilities.**
**Note: This plugin has been superseded by [CrossplatForms](https://github.com/ProjectG-Plugins/CrossplatForms). GeyserHub no longer has form, menu, and access item capabilities.**

A crossplay lobby plugin for Spigot servers that provides server selector and command menus through Bedrock forms for Bedrock players, and inventory menus for Java players, with high customizability. Supports BungeeCord, and Velocity if BungeeCord plugin messaging is enabled in `velocity.toml`.
GeyserHub now only provides server/hub capabilities.

### Other Features:
Anything can be toggled off.
- Fully customizable Bedrock forms and Java inventory menus that can run commands and move players to other servers
- Hotbar items for quick access to different forms/menus
- Full Placeholder API support
- Simple scoreboard
- Welcome messages
- Automatic broadcasts
- World restrictions
- Full Placeholder API support

The legacy simple ServerSelector only for Geyser players can be found [here](https://ci.projectg.dev/job/GeyserHub/job/legacy-selector/).
###### Note: This is NOT an official GeyserMC plugin. It is made to work with Geyser, but it is not maintained or produced by GeyserMC. If you need support with this plugin, please do not ask the Geyser developers — instead, please go to our Discord server which is linked above.

## Installation

GeyserHub is a lobby plugin that must be installed on any backend servers you want the selector on.
[Floodgate](https://github.com/GeyserMC/Floodgate) must be installed on the backend servers, AND properly configured.
See this [guide](https://github.com/GeyserMC/Floodgate/wiki/Setup-and-Usage#installing-floodgate-also-on-spigot-servers-behind-bungeecord-or-velocity) for more information.
###### Note: This is NOT an official GeyserMC plugin, it is not maintained or produced by GeyserMC. If you need support with this plugin, please do not ask the Geyser developers — instead, please go to our Discord server which is linked above.

## Commands:

| Command | Permission | Info |
| ------- | -----------| ---- |
| `ghub` | `geyserhub.main` | Open the default server selector (The help page if console)|
| `ghub form` | `geyserhub.form` | Open a form/menu (The help page if console)|
| `ghub <form> <player>` | `geyserhub.form.others` | Make someone else open a form/menu |
| `ghub reload` | `geyserhub.reload` | Reload the configuration |
| `ghub help` | | View the help menu|

## Permissions:

Expand Down
43 changes: 10 additions & 33 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<groupId>dev.projectg</groupId>
<artifactId>GeyserHub</artifactId>
<name>GeyserHub</name>
<version>1.3.2</version>
<version>2.0.0</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand All @@ -21,57 +21,34 @@
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>opencollab-release-repo</id>
<url>https://repo.opencollab.dev/maven-releases/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>opencollab-snapshot-repo</id>
<url>https://repo.opencollab.dev/maven-snapshots/</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>placeholderapi</id>
<url>https://repo.extendedclip.com/content/repositories/placeholderapi/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.14.4-R0.1-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>org.geysermc.floodgate</groupId>
<artifactId>api</artifactId>
<version>2.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>me.clip</groupId>
<artifactId>placeholderapi</artifactId>
<version>2.11.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<!-- javax nullability annotations -->
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<resources>
<resource>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,8 @@
package dev.projectg.geyserhub;

import dev.projectg.geyserhub.command.GeyserHubCommand;
import dev.projectg.geyserhub.config.ConfigManager;
import dev.projectg.geyserhub.module.menu.AccessItemRegistry;
import dev.projectg.geyserhub.module.menu.InventoryManager;
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.ScoreboardManager;
import dev.projectg.geyserhub.module.teleporter.JoinTeleporter;
import dev.projectg.geyserhub.module.world.WorldSettings;
import dev.projectg.geyserhub.message.Broadcast;
import dev.projectg.geyserhub.message.MessageJoin;
import dev.projectg.geyserhub.utils.FileUtils;
import dev.projectg.geyserhub.utils.bstats.Metrics;
import org.bukkit.Bukkit;
Expand All @@ -21,8 +12,8 @@
import java.util.Objects;
import java.util.Properties;

public class GeyserHubMain extends JavaPlugin {
private static GeyserHubMain plugin;
public class GeyserHub extends JavaPlugin {
private static GeyserHub plugin;

private ConfigManager configManager;

Expand All @@ -31,7 +22,7 @@ public void onEnable() {
long start = System.currentTimeMillis();
plugin = this;
// getting the logger forces the config to load before our loadConfiguration() is called...
SelectorLogger logger = SelectorLogger.getLogger();
Logger logger = Logger.getLogger();

try {
Properties gitProperties = new Properties();
Expand All @@ -55,24 +46,9 @@ public void onEnable() {
// Bungee channel for selector
getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");

// Load forms
AccessItemRegistry accessItemRegistry = new AccessItemRegistry();
BedrockFormRegistry bedrockFormRegistry = new BedrockFormRegistry();
JavaMenuRegistry javaMenuRegistry = new JavaMenuRegistry();
Objects.requireNonNull(getCommand("ghub")).setExecutor(new GeyserHubCommand());

// 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

// Listeners for the Bedrock and Java menus
Bukkit.getServer().getPluginManager().registerEvents(new InventoryManager(accessItemRegistry, bedrockFormRegistry, javaMenuRegistry), this);
Bukkit.getServer().getPluginManager().registerEvents(new JavaMenuListeners(javaMenuRegistry), 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
Expand Down Expand Up @@ -105,7 +81,7 @@ public void initializeScoreboard() {
}, 20L, ScoreboardManager.REFRESH_RATE * 20L);
}

public static GeyserHubMain getInstance() {
public static GeyserHub getInstance() {
return plugin;
}

Expand Down
83 changes: 83 additions & 0 deletions src/main/java/dev/projectg/geyserhub/GeyserHubCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
package dev.projectg.geyserhub;

import com.google.common.collect.ImmutableMap;
import dev.projectg.geyserhub.reloadable.ReloadableRegistry;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

import javax.annotation.Nonnull;
import java.util.Map;
import java.util.Objects;

public class GeyserHubCommand implements CommandExecutor {

private static final Map<Logger.Level, ChatColor> LOGGER_COLORS = ImmutableMap.of(
Logger.Level.INFO, ChatColor.RESET,
Logger.Level.WARN, ChatColor.GOLD,
Logger.Level.SEVERE, ChatColor.RED);

private static final String[] HELP = {
"/ghub - Opens the default form if one exists. If not, shows the help page",
"/ghub - Opens the help page",
"/ghub form <form> - Open a form with the defined name",
"/ghub form <form> <player> - Sends a form to a given player",
"/ghub reload - reloads the selector"
};

private static final String NO_PERMISSION = "Sorry, you don't have permission to run that command!";
private static final String UNKNOWN = "Sorry, that's an unknown command!";

@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (!(commandSender instanceof Player || commandSender instanceof ConsoleCommandSender)) {
return false;
}
// todo: cleanup
if (args.length == 0) {
sendHelp(commandSender);
return true;
}

// At least one arg
switch (args[0]) {
case "reload":
if (commandSender.hasPermission("geyserhub.reload")) {
if (!ReloadableRegistry.reloadAll()) {
sendMessage(commandSender, Logger.Level.SEVERE, "There was an error reloading something! Please check the server console for further information.");
}
} else {
sendMessage(commandSender, Logger.Level.SEVERE, NO_PERMISSION);
}
break;
case "help":
sendHelp(commandSender);
break;
default:
sendMessage(commandSender, Logger.Level.SEVERE, UNKNOWN);
break;
}
return true;
}

private void sendHelp(CommandSender commandSender) {
// todo: only show players with the given permissions certain entries? not sure if it can be integrated any way into spigot command completions
commandSender.sendMessage(HELP);
}

public static void sendMessage(@Nonnull CommandSender sender, @Nonnull Logger.Level level, @Nonnull String message) {
Objects.requireNonNull(sender);
Objects.requireNonNull(level);
Objects.requireNonNull(message);

if (sender instanceof ConsoleCommandSender) {
Logger.getLogger().log(level, message);
} else {
sender.sendMessage("[GeyserHub] " + LOGGER_COLORS.getOrDefault(level, ChatColor.RESET) + message);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package dev.projectg.geyserhub.module.teleporter;
package dev.projectg.geyserhub;

import dev.projectg.geyserhub.GeyserHubMain;
import dev.projectg.geyserhub.config.ConfigId;
import dev.projectg.geyserhub.reloadable.Reloadable;
import dev.projectg.geyserhub.reloadable.ReloadableRegistry;
import dev.projectg.geyserhub.SelectorLogger;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
Expand All @@ -26,7 +24,7 @@ public class JoinTeleporter implements Listener, Reloadable {
private Location location;

public JoinTeleporter() {
FileConfiguration config = GeyserHubMain.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN);
FileConfiguration config = GeyserHub.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN);
ReloadableRegistry.registerReloadable(this);
enabled = load(config);
}
Expand All @@ -44,7 +42,7 @@ public void onPlayerJoin(PlayerJoinEvent event) {
* @return false if there was an error loading or if its disabled in the config
*/
private boolean load(@Nonnull FileConfiguration config) {
SelectorLogger logger = SelectorLogger.getLogger();
Logger logger = Logger.getLogger();

if (!config.contains("Join-Teleporter", true) || !config.isConfigurationSection("Join-Teleporter")) {
logger.warn("Configuration does not contain Join-Teleporter section, skipping module.");
Expand All @@ -71,7 +69,7 @@ private boolean load(@Nonnull FileConfiguration config) {
* @return false if there was an error setting the location
*/
private boolean setLocation(@Nonnull ConfigurationSection section) {
SelectorLogger logger = SelectorLogger.getLogger();
Logger logger = Logger.getLogger();

if (!(section.contains("World", true) && section.isString("World"))) {
logger.severe("Join-Teleporter config section does not contain a valid World string, skipping module!");
Expand Down Expand Up @@ -108,7 +106,7 @@ private boolean setLocation(@Nonnull ConfigurationSection section) {

@Override
public boolean reload() {
enabled = load(GeyserHubMain.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN));
enabled = load(GeyserHub.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN));
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@
import dev.projectg.geyserhub.reloadable.Reloadable;
import dev.projectg.geyserhub.reloadable.ReloadableRegistry;

public class SelectorLogger implements Reloadable {
public class Logger implements Reloadable {

private static final SelectorLogger LOGGER = new SelectorLogger(GeyserHubMain.getInstance());
private static final Logger LOGGER = new Logger(GeyserHub.getInstance());

private final GeyserHubMain plugin;
private final GeyserHub plugin;
private boolean debug;

public static SelectorLogger getLogger() {
public static Logger getLogger() {
return LOGGER;
}

private SelectorLogger(GeyserHubMain plugin) {
private Logger(GeyserHub plugin) {
this.plugin = plugin;
debug = plugin.getConfig().getBoolean("Enable-Debug", false);
ReloadableRegistry.registerReloadable(this);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package dev.projectg.geyserhub.module.scoreboard;
package dev.projectg.geyserhub;

import dev.projectg.geyserhub.GeyserHubMain;
import dev.projectg.geyserhub.config.ConfigId;
import dev.projectg.geyserhub.utils.PlaceholderUtils;
import org.bukkit.Bukkit;
Expand All @@ -14,7 +13,7 @@

public class ScoreboardManager {

public static final int REFRESH_RATE = GeyserHubMain.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN).getInt("Scoreboard.Refresh-rate");
public static final int REFRESH_RATE = GeyserHub.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN).getInt("Scoreboard.Refresh-rate");

public static void addScoreboard() {

Expand All @@ -24,7 +23,7 @@ public static void addScoreboard() {
}

public static void createScoreboard(Player player) {
FileConfiguration config = GeyserHubMain.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN);
FileConfiguration config = GeyserHub.getInstance().getConfigManager().getFileConfiguration(ConfigId.MAIN);
Scoreboard board = Objects.requireNonNull(Bukkit.getServer().getScoreboardManager()).getNewScoreboard();
Objective objective = board.registerNewObjective("GeyserHub", "dummy", PlaceholderUtils.setPlaceholders(player, config.getString("Scoreboard.Title", "GeyserHub")));

Expand Down
Loading

0 comments on commit 97c0855

Please sign in to comment.