Migrate to new Hytale plugin template structure
Replaces the previous Kotlin-based Gradle build and template files with a new Java-based Gradle build system and updated example plugin code. Removes old build scripts, plugin template, and configuration, and introduces a new ExamplePlugin with updated manifest, command, and recipe example. Updates documentation and project configuration to match the new structure and usage.
This commit is contained in:
@@ -1,54 +0,0 @@
|
||||
package com.example.templateplugin;
|
||||
|
||||
/**
|
||||
* Main plugin class.
|
||||
*
|
||||
* TODO: Implement your plugin logic here.
|
||||
*
|
||||
* @author YourName
|
||||
* @version 1.0.0
|
||||
*/
|
||||
public class TemplatePlugin {
|
||||
|
||||
private static TemplatePlugin instance;
|
||||
|
||||
/**
|
||||
* Constructor - Called when plugin is loaded.
|
||||
*/
|
||||
public TemplatePlugin() {
|
||||
instance = this;
|
||||
System.out.println("[TemplatePlugin] Plugin loaded!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when plugin is enabled.
|
||||
*/
|
||||
public void onEnable() {
|
||||
System.out.println("[TemplatePlugin] Plugin enabled!");
|
||||
|
||||
// TODO: Initialize your plugin here
|
||||
// - Load configuration
|
||||
// - Register event listeners
|
||||
// - Register commands
|
||||
// - Start services
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when plugin is disabled.
|
||||
*/
|
||||
public void onDisable() {
|
||||
System.out.println("[TemplatePlugin] Plugin disabled!");
|
||||
|
||||
// TODO: Cleanup your plugin here
|
||||
// - Save data
|
||||
// - Stop services
|
||||
// - Close connections
|
||||
}
|
||||
|
||||
/**
|
||||
* Get plugin instance.
|
||||
*/
|
||||
public static TemplatePlugin getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
29
src/main/java/org/example/plugin/ExampleCommand.java
Normal file
29
src/main/java/org/example/plugin/ExampleCommand.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.example.plugin;
|
||||
|
||||
import com.hypixel.hytale.protocol.GameMode;
|
||||
import com.hypixel.hytale.server.core.Message;
|
||||
import com.hypixel.hytale.server.core.command.system.CommandContext;
|
||||
import com.hypixel.hytale.server.core.command.system.basecommands.CommandBase;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This is an example command that will simply print the name of the plugin in chat when used.
|
||||
*/
|
||||
public class ExampleCommand extends CommandBase {
|
||||
|
||||
private final String pluginName;
|
||||
private final String pluginVersion;
|
||||
|
||||
public ExampleCommand(String pluginName, String pluginVersion) {
|
||||
super("test", "Prints a test message from the " + pluginName + " plugin.");
|
||||
this.setPermissionGroup(GameMode.Adventure); // Allows the command to be used by anyone, not just OP
|
||||
this.pluginName = pluginName;
|
||||
this.pluginVersion = pluginVersion;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void executeSync(@Nonnull CommandContext ctx) {
|
||||
ctx.sendMessage(Message.raw("Hello from the " + pluginName + " v" + pluginVersion + " plugin!"));
|
||||
}
|
||||
}
|
||||
27
src/main/java/org/example/plugin/ExamplePlugin.java
Normal file
27
src/main/java/org/example/plugin/ExamplePlugin.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package org.example.plugin;
|
||||
|
||||
import com.hypixel.hytale.logger.HytaleLogger;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPlugin;
|
||||
import com.hypixel.hytale.server.core.plugin.JavaPluginInit;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
/**
|
||||
* This class serves as the entrypoint for your plugin. Use the setup method to register into game registries or add
|
||||
* event listeners.
|
||||
*/
|
||||
public class ExamplePlugin extends JavaPlugin {
|
||||
|
||||
private static final HytaleLogger LOGGER = HytaleLogger.forEnclosingClass();
|
||||
|
||||
public ExamplePlugin(@Nonnull JavaPluginInit init) {
|
||||
super(init);
|
||||
LOGGER.atInfo().log("Hello from " + this.getName() + " version " + this.getManifest().getVersion().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setup() {
|
||||
LOGGER.atInfo().log("Setting up plugin " + this.getName());
|
||||
this.getCommandRegistry().registerCommand(new ExampleCommand(this.getName(), this.getManifest().getVersion().toString()));
|
||||
}
|
||||
}
|
||||
22
src/main/resources/Server/Item/Recipes/Example_Recipe.json
Normal file
22
src/main/resources/Server/Item/Recipes/Example_Recipe.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"Input": [
|
||||
{
|
||||
"ItemId": "Soil_Dirt",
|
||||
"Quantity": 10
|
||||
}
|
||||
],
|
||||
"PrimaryOutput": {
|
||||
"ItemId": "Soil_Dirt",
|
||||
"Quantity": 1
|
||||
},
|
||||
"BenchRequirement": [
|
||||
{
|
||||
"Id": "Fieldcraft",
|
||||
"Type": "Crafting",
|
||||
"Categories": [
|
||||
"Tools"
|
||||
]
|
||||
}
|
||||
],
|
||||
"Seconds": 1
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
{
|
||||
"pluginName": "TemplatePlugin",
|
||||
"version": "1.0.0",
|
||||
"debugMode": false
|
||||
}
|
||||
@@ -1,19 +1,22 @@
|
||||
{
|
||||
"Group": "TemplatePlugin",
|
||||
"Name": "TemplatePlugin",
|
||||
"Version": "1.0.0",
|
||||
"Description": "A Hytale plugin template",
|
||||
"Authors": [
|
||||
{
|
||||
"Name": "YourName",
|
||||
"Email": "your.email@example.com",
|
||||
"Url": "https://your-website.com"
|
||||
}
|
||||
],
|
||||
"Website": "https://github.com/yourusername/hytale-plugin-template",
|
||||
"Main": "com.example.templateplugin.TemplatePlugin",
|
||||
"ServerVersion": "*",
|
||||
"Dependencies": {},
|
||||
"OptionalDependencies": {},
|
||||
"DisabledByDefault": false
|
||||
}
|
||||
"Group": "Example",
|
||||
"Name": "ExamplePlugin",
|
||||
"Version": "0.0.2",
|
||||
"Description": "An example plugin for HyTale!",
|
||||
"Authors": [
|
||||
{
|
||||
"Name": "It's you!"
|
||||
}
|
||||
],
|
||||
"Website": "example.org",
|
||||
"ServerVersion": "*",
|
||||
"Dependencies": {
|
||||
|
||||
},
|
||||
"OptionalDependencies": {
|
||||
|
||||
},
|
||||
"DisabledByDefault": false,
|
||||
"Main": "org.example.plugin.ExamplePlugin",
|
||||
"IncludesAssetPack": true
|
||||
}
|
||||
Reference in New Issue
Block a user