mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Code cleanups, more work on API
This commit is contained in:
parent
3afc9f28fb
commit
187d2dbe32
13 changed files with 433 additions and 106 deletions
|
@ -9,4 +9,12 @@
|
|||
<version>${revision}</version>
|
||||
</parent>
|
||||
<artifactId>api</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>1.18.4</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
48
api/src/main/java/org/geysermc/api/Connector.java
Normal file
48
api/src/main/java/org/geysermc/api/Connector.java
Normal file
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.api;
|
||||
|
||||
import org.geysermc.api.command.CommandMap;
|
||||
import org.geysermc.api.logger.Logger;
|
||||
import org.geysermc.api.plugin.PluginManager;
|
||||
|
||||
public interface Connector {
|
||||
|
||||
/**
|
||||
* Returns the logger
|
||||
*
|
||||
* @return the logger
|
||||
*/
|
||||
Logger getLogger();
|
||||
|
||||
/**
|
||||
* Returns the command map
|
||||
*
|
||||
* @return the command map
|
||||
*/
|
||||
CommandMap getCommandMap();
|
||||
|
||||
/**
|
||||
* Returns the plugin manager
|
||||
*
|
||||
* @return the plugin manager
|
||||
*/
|
||||
PluginManager getPluginManager();
|
||||
|
||||
/**
|
||||
* Shuts down the connector
|
||||
*/
|
||||
void shutdown();
|
||||
}
|
|
@ -1,18 +1,55 @@
|
|||
package org.geysermc.api;
|
||||
|
||||
import org.geysermc.api.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.geysermc.api.command.CommandMap;
|
||||
import org.geysermc.api.logger.Logger;
|
||||
import org.geysermc.api.plugin.PluginManager;
|
||||
|
||||
public class Geyser {
|
||||
private static final List<Plugin> plugins = new ArrayList<>();
|
||||
|
||||
public static List<Plugin> getPlugins() {
|
||||
return new ArrayList<>(plugins);
|
||||
private static Connector connector;
|
||||
|
||||
/**
|
||||
* Returns the connector instance for Geyser
|
||||
*
|
||||
* @return the connector instance for Geyser
|
||||
*/
|
||||
public static Connector getConnector() {
|
||||
return connector;
|
||||
}
|
||||
|
||||
public static void add(Plugin p) {
|
||||
plugins.add(p);
|
||||
/**
|
||||
* Sets the connector instance for Geyser
|
||||
*
|
||||
* @param connector the connector instance
|
||||
*/
|
||||
public static void setConnector(Connector connector) {
|
||||
Geyser.connector = connector;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the logger
|
||||
*
|
||||
* @return the logger
|
||||
*/
|
||||
public static Logger getLogger() {
|
||||
return connector.getLogger();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the plugin manager
|
||||
*
|
||||
* @return the plugin manager
|
||||
*/
|
||||
public static PluginManager getPluginManager() {
|
||||
return connector.getPluginManager();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the command map
|
||||
*
|
||||
* @return the command map
|
||||
*/
|
||||
public static CommandMap getCommandMap() {
|
||||
return connector.getCommandMap();
|
||||
}
|
||||
}
|
||||
|
|
42
api/src/main/java/org/geysermc/api/command/CommandMap.java
Normal file
42
api/src/main/java/org/geysermc/api/command/CommandMap.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.api.command;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public interface CommandMap {
|
||||
|
||||
/**
|
||||
* Registers a new command
|
||||
*
|
||||
* @param command the command to register
|
||||
*/
|
||||
void registerCommand(Command command);
|
||||
|
||||
/**
|
||||
* Runs a command for the given command sender
|
||||
*
|
||||
* @param sender the sender to run the command for
|
||||
* @param command the command to run
|
||||
*/
|
||||
void runCommand(CommandSender sender, String command);
|
||||
|
||||
/**
|
||||
* Returns a map of the commands
|
||||
*
|
||||
* @return a map of the commands
|
||||
*/
|
||||
Map<String, Command> getCommands();
|
||||
}
|
46
api/src/main/java/org/geysermc/api/logger/Logger.java
Normal file
46
api/src/main/java/org/geysermc/api/logger/Logger.java
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.api.logger;
|
||||
|
||||
public interface Logger {
|
||||
|
||||
/**
|
||||
* Logs an info message to console
|
||||
*
|
||||
* @param message the message to log
|
||||
*/
|
||||
void info(String message);
|
||||
|
||||
/**
|
||||
* Logs a severe message to console
|
||||
*
|
||||
* @param message the message to log
|
||||
*/
|
||||
void severe(String message);
|
||||
|
||||
/**
|
||||
* Logs a warning message to console
|
||||
*
|
||||
* @param message the message to log
|
||||
*/
|
||||
void warning(String message);
|
||||
|
||||
/**
|
||||
* Logs a debug message to console
|
||||
*
|
||||
* @param message the message to log
|
||||
*/
|
||||
void debug(String message);
|
||||
}
|
|
@ -1,14 +1,31 @@
|
|||
package org.geysermc.api.plugin;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class Plugin {
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean enabled = true;
|
||||
|
||||
/**
|
||||
* Called when a plugin is enabled
|
||||
*/
|
||||
public void onEnable() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a plugin is disabled
|
||||
*/
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when a plugin is loaded
|
||||
*/
|
||||
public void onLoad() {
|
||||
|
||||
}
|
||||
|
|
55
api/src/main/java/org/geysermc/api/plugin/PluginManager.java
Normal file
55
api/src/main/java/org/geysermc/api/plugin/PluginManager.java
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* GNU LESSER GENERAL PUBLIC LICENSE
|
||||
* Version 3, 29 June 2007
|
||||
*
|
||||
* Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
* Everyone is permitted to copy and distribute verbatim copies
|
||||
* of this license document, but changing it is not allowed.
|
||||
*
|
||||
* You can view the LICENCE file for details.
|
||||
*
|
||||
* @author GeyserMC
|
||||
* @link https://github.com/GeyserMC/Geyser
|
||||
*/
|
||||
|
||||
package org.geysermc.api.plugin;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface PluginManager {
|
||||
|
||||
/**
|
||||
* Loads a plugin and all its class files
|
||||
*
|
||||
* @param plugin the plugin to load
|
||||
*/
|
||||
void loadPlugin(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Enables a plugin
|
||||
*
|
||||
* @param plugin the plugin to enable
|
||||
*/
|
||||
void enablePlugin(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Disables a plugin
|
||||
*
|
||||
* @param plugin the plugin to disable
|
||||
*/
|
||||
void disablePlugin(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Unloads a plugin
|
||||
*
|
||||
* @param plugin the plugin to unload
|
||||
*/
|
||||
void unloadPlugin(Plugin plugin);
|
||||
|
||||
/**
|
||||
* Returns a set of the loaded plugins
|
||||
*
|
||||
* @return a set of the loaded plugins
|
||||
*/
|
||||
Set<Plugin> getPlugins();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue