Remove: pumpkin-plugin

We will focus on other things by now. And extism just slows down compile and indexing times extremly
This commit is contained in:
Snowiiii
2024-10-14 17:58:19 +02:00
parent 3eacf1e6c0
commit 3ca472c2ba
8 changed files with 30 additions and 1768 deletions

1692
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,7 +6,6 @@ members = [
"pumpkin-entity",
"pumpkin-inventory",
"pumpkin-macros/",
"pumpkin-plugin",
"pumpkin-protocol/",
"pumpkin-registry/",
"pumpkin-world",

View File

@@ -1,13 +0,0 @@
[package]
name = "pumpkin-plugin"
version.workspace = true
edition.workspace = true
[features]
default = []
plugins = ["dep:extism"]
[dependencies]
serde.workspace = true
log.workspace = true
extism = { version = "1.6.0", optional = true }

View File

@@ -1,17 +0,0 @@
#[cfg(feature = "plugins")]
use extism::{convert::Msgpack, host_fn, FromBytes, ToBytes};
/// Used to keep track of things created by plugins.
/// This can include things like events, commands, etc.
#[derive(Hash, PartialEq, Eq, ToBytes, FromBytes, serde::Serialize, serde::Deserialize)]
#[cfg(feature = "plugins")]
#[encoding(Msgpack)] // TODO: Switch to protocal buffers for smaller size
struct Identifier {
namespace: String,
path: String,
}
#[cfg(feature = "plugins")]
host_fn!(new(namespace: String, path: String) -> Result<Identifier, _> {
Ok(Identifier { namespace, path })
});

View File

@@ -1 +0,0 @@
mod identifer;

View File

@@ -1,65 +0,0 @@
mod api;
#[cfg(feature = "plugins")]
use extism::{Manifest, Plugin, Wasm};
pub const PLUGIN_DIR: &str = "plugins";
pub struct PumpkinPlugin {
#[cfg(feature = "plugins")]
_plugin: Plugin,
}
pub struct PluginLoader {
plugins: Vec<PumpkinPlugin>,
}
impl PluginLoader {
pub fn load() -> Self {
#[cfg(feature = "plugins")]
{
use std::path::Path;
let plugin_dir = Path::new(PLUGIN_DIR);
if !plugin_dir.exists() || !plugin_dir.is_dir() {
log::info!("Creating plugins dir...");
std::fs::create_dir(plugin_dir).expect("Failed to create Plugin dir");
return Self { plugins: vec![] };
}
let files = std::fs::read_dir(plugin_dir).expect("Failed to read plugin dir");
let mut plugins = Vec::new();
for file in files {
let file = file.expect("Failed to get Plugin file");
let path = file.path();
if path
.extension()
.expect("Failed to get Plugin file extension")
== "wasm"
{
log::info!(
"Loading Plugin {:?}",
path.file_name().expect("Failed to get Plugin file name")
);
let wasm = Wasm::file(path);
let manifest = Manifest::new([wasm]);
let mut plugin = Plugin::new(&manifest, [], true).unwrap();
plugin
.call::<(), ()>("on_enable", ())
.expect("Failed to call on_enable funcation");
let pumpkin_plugin = PumpkinPlugin { _plugin: plugin };
plugins.push(pumpkin_plugin);
}
}
Self { plugins }
}
#[cfg(not(feature = "plugins"))]
Self {
plugins: Vec::new(),
}
}
pub fn plugins(&mut self) -> &mut Vec<PumpkinPlugin> {
&mut self.plugins
}
}

View File

@@ -4,15 +4,10 @@ version = "0.1.0-dev"
description = "Empowering everyone to host fast and efficient Minecraft servers."
edition = "2021"
[features]
default = ["plugins"]
plugins = ["pumpkin-plugin/plugins"]
[dependencies]
# pumpkin
pumpkin-core = { path = "../pumpkin-core" }
pumpkin-config = { path = "../pumpkin-config" }
pumpkin-plugin = { path = "../pumpkin-plugin" }
pumpkin-inventory = { path = "../pumpkin-inventory" }
pumpkin-world = { path = "../pumpkin-world" }
pumpkin-entity = { path = "../pumpkin-entity" }

View File

@@ -7,7 +7,6 @@ use pumpkin_core::GameMode;
use pumpkin_entity::EntityId;
use pumpkin_inventory::drag_handler::DragHandler;
use pumpkin_inventory::{Container, OpenContainer};
use pumpkin_plugin::PluginLoader;
use pumpkin_protocol::client::login::CEncryptionRequest;
use pumpkin_protocol::client::status::CStatusResponse;
use pumpkin_protocol::{client::config::CPluginMessage, ClientPacket};
@@ -38,7 +37,6 @@ pub struct Server {
key_store: KeyStore,
server_listing: CachedStatus,
server_branding: CachedBranding,
pub plugin_loader: PluginLoader,
pub command_dispatcher: Arc<CommandDispatcher<'static>>,
pub worlds: Vec<Arc<World>>,
@@ -73,14 +71,12 @@ impl Server {
// First register default command, after that plugins can put in their own
let command_dispatcher = default_dispatcher();
log::info!("Loading Plugins");
let plugin_loader = PluginLoader::load();
let world = World::load(Dimension::OverWorld.into_level(
// TODO: load form config
"./world".parse().unwrap(),
));
Self {
plugin_loader,
cached_registry: Registry::get_static(),
open_containers: RwLock::new(HashMap::new()),
drag_handler: DragHandler::new(),