Add in plugin manager
This commit is contained in:
parent
1eaf8369e2
commit
bb23fce01e
@ -12,6 +12,7 @@ repositories {
|
||||
dependencies {
|
||||
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
|
||||
implementation("net.sf.jopt-simple:jopt-simple:6.0-alpha-3")
|
||||
implementation("io.github.astonbitecode:j4rs:0.24.0")
|
||||
}
|
||||
|
||||
java {
|
||||
|
||||
@ -0,0 +1,5 @@
|
||||
package org.patchbukkit;
|
||||
|
||||
import org.astonbitecode.j4rs.api.invocation.NativeCallbackToRustChannelSupport;
|
||||
|
||||
public class NativeCallbacks extends NativeCallbackToRustChannelSupport {}
|
||||
@ -16,7 +16,7 @@ import org.bukkit.plugin.RegisteredListener;
|
||||
import org.bukkit.plugin.UnknownDependencyException;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@SuppressWarnings({ "deprecation", "removal" })
|
||||
public class PatchBukkitPluginLoader implements PluginLoader {
|
||||
|
||||
public static JavaPlugin createPlugin(String jarPath, String mainClass) {
|
||||
|
||||
@ -0,0 +1,292 @@
|
||||
package org.patchbukkit;
|
||||
|
||||
import io.papermc.paper.plugin.PermissionManager;
|
||||
import io.papermc.paper.plugin.configuration.PluginMeta;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jspecify.annotations.NonNull;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public class PatchBukkitPluginManager implements PluginManager {
|
||||
|
||||
@Override
|
||||
public void registerInterface(@NotNull Class<? extends PluginLoader> loader)
|
||||
throws IllegalArgumentException {}
|
||||
|
||||
@Override
|
||||
public @Nullable Plugin getPlugin(@NotNull String name) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getPlugin'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Plugin[] getPlugins() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getPlugins'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(@NotNull String name) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'isPluginEnabled'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPluginEnabled(@Nullable Plugin plugin) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'isPluginEnabled'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Plugin loadPlugin(@NotNull File file)
|
||||
throws InvalidPluginException, InvalidDescriptionException, UnknownDependencyException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'loadPlugin'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Plugin[] loadPlugins(@NotNull File directory) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'loadPlugins'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Plugin[] loadPlugins(@NonNull @NotNull File[] files) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'loadPlugins'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugins() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'disablePlugins'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPlugins() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'clearPlugins'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void callEvent(@NotNull Event event) throws IllegalStateException {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'callEvent'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvents(
|
||||
@NotNull Listener listener,
|
||||
@NotNull Plugin plugin
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'registerEvents'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(
|
||||
@NotNull Class<? extends Event> event,
|
||||
@NotNull Listener listener,
|
||||
@NotNull EventPriority priority,
|
||||
@NotNull EventExecutor executor,
|
||||
@NotNull Plugin plugin
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'registerEvent'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerEvent(
|
||||
@NotNull Class<? extends Event> event,
|
||||
@NotNull Listener listener,
|
||||
@NotNull EventPriority priority,
|
||||
@NotNull EventExecutor executor,
|
||||
@NotNull Plugin plugin,
|
||||
boolean ignoreCancelled
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'registerEvent'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enablePlugin(@NotNull Plugin plugin) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'enablePlugin'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disablePlugin(@NotNull Plugin plugin) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'disablePlugin'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Permission getPermission(@NotNull String name) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getPermission'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermission(@NotNull Permission perm) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'addPermission'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(@NotNull Permission perm) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'removePermission'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePermission(@NotNull String name) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'removePermission'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Permission> getDefaultPermissions(boolean op) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getDefaultPermissions'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recalculatePermissionDefaults(@NotNull Permission perm) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'recalculatePermissionDefaults'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToPermission(
|
||||
@NotNull String permission,
|
||||
@NotNull Permissible permissible
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'subscribeToPermission'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromPermission(
|
||||
@NotNull String permission,
|
||||
@NotNull Permissible permissible
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'unsubscribeFromPermission'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Permissible> getPermissionSubscriptions(
|
||||
@NotNull String permission
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getPermissionSubscriptions'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void subscribeToDefaultPerms(
|
||||
boolean op,
|
||||
@NotNull Permissible permissible
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'subscribeToDefaultPerms'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unsubscribeFromDefaultPerms(
|
||||
boolean op,
|
||||
@NotNull Permissible permissible
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'unsubscribeFromDefaultPerms'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Permissible> getDefaultPermSubscriptions(boolean op) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getDefaultPermSubscriptions'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Set<Permission> getPermissions() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getPermissions'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addPermissions(List<Permission> perm) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'addPermissions'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearPermissions() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'clearPermissions'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useTimings() {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'useTimings'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTransitiveDependency(
|
||||
PluginMeta pluginMeta,
|
||||
PluginMeta dependencyConfig
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'isTransitiveDependency'"
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void overridePermissionManager(
|
||||
@NotNull Plugin plugin,
|
||||
@Nullable PermissionManager permissionManager
|
||||
) {
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'overridePermissionManager'"
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -84,6 +84,7 @@ import org.bukkit.util.CachedServerIcon;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@SuppressWarnings("removal")
|
||||
public class PatchBukkitServer implements Server {
|
||||
|
||||
private final String serverName =
|
||||
@ -442,10 +443,7 @@ public class PatchBukkitServer implements Server {
|
||||
|
||||
@Override
|
||||
public @NotNull PluginManager getPluginManager() {
|
||||
// TODO Auto-generated method stub
|
||||
throw new UnsupportedOperationException(
|
||||
"Unimplemented method 'getPluginManager'"
|
||||
);
|
||||
return new PatchBukkitPluginManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
58
rust/Cargo.lock
generated
58
rust/Cargo.lock
generated
@ -630,6 +630,27 @@ dependencies = [
|
||||
"subtle",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c3e8aa94d75141228480295a7d0e7feb620b1a5ad9f12bc40be62411e38cce4e"
|
||||
dependencies = [
|
||||
"dirs-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "dirs-sys"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"option-ext",
|
||||
"redox_users",
|
||||
"windows-sys 0.59.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "displaydoc"
|
||||
version = "0.2.5"
|
||||
@ -1362,6 +1383,16 @@ version = "0.2.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f9fbbcab51052fe104eb5e5d351cf728d30a5be1fe14d9be8a3b097481fb97de"
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3d0b95e02c851351f877147b7deea7b1afb1df71b63aa5f8270716e0c5720616"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.11.0"
|
||||
@ -1576,6 +1607,12 @@ version = "1.70.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "384b8ab6d37215f3c5301a95a4accb5d64aa607f1fcb26a11b5303878451b4fe"
|
||||
|
||||
[[package]]
|
||||
name = "option-ext"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
|
||||
|
||||
[[package]]
|
||||
name = "p384"
|
||||
version = "0.13.1"
|
||||
@ -2163,6 +2200,17 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "redox_users"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a4e608c6638b9c18977b00b475ac1f28d14e84b27d8d42f70e0bf1e3dec127ac"
|
||||
dependencies = [
|
||||
"getrandom 0.2.17",
|
||||
"libredox",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.12.2"
|
||||
@ -2255,6 +2303,7 @@ dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"rust-embed-utils",
|
||||
"shellexpand",
|
||||
"syn",
|
||||
"walkdir",
|
||||
]
|
||||
@ -2538,6 +2587,15 @@ dependencies = [
|
||||
"digest 0.11.0-rc.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shellexpand"
|
||||
version = "3.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b1fdf65dd6331831494dd616b30351c38e96e45921a27745cf98490458b90bb"
|
||||
dependencies = [
|
||||
"dirs",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "shlex"
|
||||
version = "1.3.0"
|
||||
|
||||
@ -17,7 +17,7 @@ log = "0.4"
|
||||
glob = "0.3.2"
|
||||
j4rs = { version = "0.24" }
|
||||
j4rs_derive = "0.1"
|
||||
rust-embed = "8.9.0"
|
||||
rust-embed = { version = "8.9.0", features = ["interpolate-folder-path"] }
|
||||
walkdir = "2"
|
||||
zip = "7.1"
|
||||
|
||||
|
||||
@ -1,10 +0,0 @@
|
||||
use j4rs::prelude::*;
|
||||
use j4rs_derive::*;
|
||||
|
||||
#[call_from_java("io.github.astonbitecode.j4rs.example.RustSimpleFunctionCall.fnnoargs")]
|
||||
fn my_function_with_no_args() {
|
||||
println!("Hello from the Rust world!");
|
||||
// If you need to have a Jvm here, you need to attach the thread
|
||||
let _jvm = Jvm::attach_thread().unwrap();
|
||||
// Now you may further call Java classes and methods as usual!
|
||||
}
|
||||
@ -1,4 +1,3 @@
|
||||
pub mod jar;
|
||||
pub mod java_to_rust;
|
||||
pub mod jvm;
|
||||
pub mod resources;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user