├── .gitignore
├── .gitmodules
├── .vscode
└── settings.json
├── Cargo.lock
├── Cargo.toml
├── LICENSE
├── README.md
├── additions
├── README.md
├── biconsumer_new.rs_
├── biomeprovider_new.rs
├── blockpopulator_new.rs
├── chunkgenerator_new.rs
├── commandexecutor_new.rs
├── configserializable_new.rs
├── consumer_new.rs
├── conversationcanceller_new.rs
├── conversationprefix_new.rs
├── helptopic_new.rs
├── helptopicfactory_new.rs
├── maprenderer_new.rs
├── metadatavalue_new.rs
├── noisegenerator_new.rs
├── persistentdatatype_new.rs
├── plugin_base_new.rs
├── plugin_loader_new.rs
├── plugin_new.rs
├── plugin_new_extendable.rs
├── prompt_new.rs
├── runnable_new.rs
├── tabcompleter_new.rs
└── tabexecutor_new.rs
├── blackboxmc-rs-bukkit
├── Cargo.toml
├── README.md
└── src
│ ├── advancement
│ └── mod.rs
│ ├── attribute
│ └── mod.rs
│ ├── ban
│ └── mod.rs
│ ├── block
│ ├── banner
│ │ └── mod.rs
│ ├── data
│ │ ├── mod.rs
│ │ └── mod_type
│ │ │ └── mod.rs
│ ├── mod.rs
│ ├── sign
│ │ └── mod.rs
│ ├── spawner
│ │ └── mod.rs
│ └── structure
│ │ └── mod.rs
│ ├── boss
│ └── mod.rs
│ ├── command
│ ├── defaults
│ │ └── mod.rs
│ └── mod.rs
│ ├── configuration
│ ├── file
│ │ └── mod.rs
│ ├── mod.rs
│ └── serialization
│ │ └── mod.rs
│ ├── conversations
│ └── mod.rs
│ ├── damage
│ └── mod.rs
│ ├── enchantments
│ └── mod.rs
│ ├── entity
│ ├── memory
│ │ └── mod.rs
│ ├── minecart
│ │ └── mod.rs
│ └── mod.rs
│ ├── event
│ ├── block
│ │ └── mod.rs
│ ├── enchantment
│ │ └── mod.rs
│ ├── entity
│ │ └── mod.rs
│ ├── hanging
│ │ └── mod.rs
│ ├── inventory
│ │ └── mod.rs
│ ├── mod.rs
│ ├── player
│ │ └── mod.rs
│ ├── raid
│ │ └── mod.rs
│ ├── server
│ │ └── mod.rs
│ ├── vehicle
│ │ └── mod.rs
│ ├── weather
│ │ └── mod.rs
│ └── world
│ │ └── mod.rs
│ ├── generator
│ ├── mod.rs
│ └── structure
│ │ └── mod.rs
│ ├── help
│ └── mod.rs
│ ├── inventory
│ ├── meta
│ │ ├── components
│ │ │ └── mod.rs
│ │ ├── mod.rs
│ │ ├── tags
│ │ │ └── mod.rs
│ │ └── trim
│ │ │ └── mod.rs
│ ├── mod.rs
│ ├── recipe
│ │ └── mod.rs
│ └── view
│ │ └── mod.rs
│ ├── lib.rs
│ ├── loot
│ └── mod.rs
│ ├── map
│ └── mod.rs
│ ├── material
│ ├── mod.rs
│ └── types
│ │ └── mod.rs
│ ├── metadata
│ └── mod.rs
│ ├── packs
│ └── mod.rs
│ ├── permissions
│ └── mod.rs
│ ├── persistence
│ └── mod.rs
│ ├── plugin
│ ├── java
│ │ └── mod.rs
│ ├── messaging
│ │ └── mod.rs
│ └── mod.rs
│ ├── potion
│ └── mod.rs
│ ├── profile
│ └── mod.rs
│ ├── projectiles
│ └── mod.rs
│ ├── scheduler
│ └── mod.rs
│ ├── scoreboard
│ └── mod.rs
│ ├── spawner
│ └── mod.rs
│ ├── structure
│ └── mod.rs
│ └── util
│ ├── io
│ └── mod.rs
│ ├── mod.rs
│ ├── noise
│ └── mod.rs
│ └── permissions
│ └── mod.rs
├── blackboxmc-rs-bungee
├── Cargo.toml
└── src
│ ├── bungee
│ ├── api
│ │ ├── chat
│ │ │ ├── hover
│ │ │ │ ├── content
│ │ │ │ │ └── mod.rs
│ │ │ │ └── mod.rs
│ │ │ └── mod.rs
│ │ └── mod.rs
│ ├── chat
│ │ └── mod.rs
│ └── mod.rs
│ └── lib.rs
├── blackboxmc-rs-general
├── Cargo.toml
└── src
│ ├── lib.rs
│ └── macros
│ ├── memory.rs
│ └── mod.rs
├── blackboxmc-rs-java
├── Cargo.toml
└── src
│ ├── lang
│ ├── lib.rs
│ └── mod.rs
│ ├── lib.rs
│ ├── security
│ └── mod.rs
│ └── util
│ ├── function
│ └── mod.rs
│ ├── lib.rs
│ ├── logging
│ └── mod.rs
│ ├── mod.rs
│ ├── random
│ └── mod.rs
│ └── regex
│ └── mod.rs
├── blackboxmc-rs-proc
├── Cargo.lock
├── Cargo.toml
├── README.md
└── src
│ └── lib.rs
├── examples
├── block-break-event
│ ├── .gitignore
│ ├── Cargo.lock
│ ├── Cargo.toml
│ └── src
│ │ └── lib.rs
└── name-printer
│ ├── .gitignore
│ ├── Cargo.lock
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
├── generate.py
├── pprint.py
└── src
├── lib.rs
└── mod.rs
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | *.json
3 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BlackBoxMC/blackboxmc-rs/7faecca02864dd5612cbeba1db5805a9987b59ac/.gitmodules
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "rust-analyzer.linkedProjects": [
3 | "./Cargo.toml",
4 | "./blackboxmc-rs-proc/Cargo.toml",
5 | "./examples/block-break-event/Cargo.toml",
6 | "./examples/mc-classic-mode/Cargo.toml",
7 | ],
8 | "rust-analyzer.experimental.procAttrMacros" :false
9 | }
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "blackbox_rs"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 |
8 | [workspace]
9 | members = ["blackboxmc-rs-general", "blackboxmc-rs-proc", "blackboxmc-rs-bukkit", "blackboxmc-rs-bungee", "blackboxmc-rs-java", "examples/name-printer", "examples/block-break-event"]
10 |
11 | [dependencies]
12 | eyre = "0.6.8"
13 | jni = "0.21.1"
14 | blackboxmc_proc = {path = "./blackboxmc-rs-proc"}
15 | parking_lot = "0.12.1"
16 | syn = { version = "2.0.27", features = ["full"] }
17 | once_cell = "1.18.0"
18 | color-eyre = "0.6.2"
19 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 |
9 | This version of the GNU Lesser General Public License incorporates
10 | the terms and conditions of version 3 of the GNU General Public
11 | License, supplemented by the additional permissions listed below.
12 |
13 | 0. Additional Definitions.
14 |
15 | As used herein, "this License" refers to version 3 of the GNU Lesser
16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU
17 | General Public License.
18 |
19 | "The Library" refers to a covered work governed by this License,
20 | other than an Application or a Combined Work as defined below.
21 |
22 | An "Application" is any work that makes use of an interface provided
23 | by the Library, but which is not otherwise based on the Library.
24 | Defining a subclass of a class defined by the Library is deemed a mode
25 | of using an interface provided by the Library.
26 |
27 | A "Combined Work" is a work produced by combining or linking an
28 | Application with the Library. The particular version of the Library
29 | with which the Combined Work was made is also called the "Linked
30 | Version".
31 |
32 | The "Minimal Corresponding Source" for a Combined Work means the
33 | Corresponding Source for the Combined Work, excluding any source code
34 | for portions of the Combined Work that, considered in isolation, are
35 | based on the Application, and not on the Linked Version.
36 |
37 | The "Corresponding Application Code" for a Combined Work means the
38 | object code and/or source code for the Application, including any data
39 | and utility programs needed for reproducing the Combined Work from the
40 | Application, but excluding the System Libraries of the Combined Work.
41 |
42 | 1. Exception to Section 3 of the GNU GPL.
43 |
44 | You may convey a covered work under sections 3 and 4 of this License
45 | without being bound by section 3 of the GNU GPL.
46 |
47 | 2. Conveying Modified Versions.
48 |
49 | If you modify a copy of the Library, and, in your modifications, a
50 | facility refers to a function or data to be supplied by an Application
51 | that uses the facility (other than as an argument passed when the
52 | facility is invoked), then you may convey a copy of the modified
53 | version:
54 |
55 | a) under this License, provided that you make a good faith effort to
56 | ensure that, in the event an Application does not supply the
57 | function or data, the facility still operates, and performs
58 | whatever part of its purpose remains meaningful, or
59 |
60 | b) under the GNU GPL, with none of the additional permissions of
61 | this License applicable to that copy.
62 |
63 | 3. Object Code Incorporating Material from Library Header Files.
64 |
65 | The object code form of an Application may incorporate material from
66 | a header file that is part of the Library. You may convey such object
67 | code under terms of your choice, provided that, if the incorporated
68 | material is not limited to numerical parameters, data structure
69 | layouts and accessors, or small macros, inline functions and templates
70 | (ten or fewer lines in length), you do both of the following:
71 |
72 | a) Give prominent notice with each copy of the object code that the
73 | Library is used in it and that the Library and its use are
74 | covered by this License.
75 |
76 | b) Accompany the object code with a copy of the GNU GPL and this license
77 | document.
78 |
79 | 4. Combined Works.
80 |
81 | You may convey a Combined Work under terms of your choice that,
82 | taken together, effectively do not restrict modification of the
83 | portions of the Library contained in the Combined Work and reverse
84 | engineering for debugging such modifications, if you also do each of
85 | the following:
86 |
87 | a) Give prominent notice with each copy of the Combined Work that
88 | the Library is used in it and that the Library and its use are
89 | covered by this License.
90 |
91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license
92 | document.
93 |
94 | c) For a Combined Work that displays copyright notices during
95 | execution, include the copyright notice for the Library among
96 | these notices, as well as a reference directing the user to the
97 | copies of the GNU GPL and this license document.
98 |
99 | d) Do one of the following:
100 |
101 | 0) Convey the Minimal Corresponding Source under the terms of this
102 | License, and the Corresponding Application Code in a form
103 | suitable for, and under terms that permit, the user to
104 | recombine or relink the Application with a modified version of
105 | the Linked Version to produce a modified Combined Work, in the
106 | manner specified by section 6 of the GNU GPL for conveying
107 | Corresponding Source.
108 |
109 | 1) Use a suitable shared library mechanism for linking with the
110 | Library. A suitable mechanism is one that (a) uses at run time
111 | a copy of the Library already present on the user's computer
112 | system, and (b) will operate properly with a modified version
113 | of the Library that is interface-compatible with the Linked
114 | Version.
115 |
116 | e) Provide Installation Information, but only if you would otherwise
117 | be required to provide such information under section 6 of the
118 | GNU GPL, and only to the extent that such information is
119 | necessary to install and execute a modified version of the
120 | Combined Work produced by recombining or relinking the
121 | Application with a modified version of the Linked Version. (If
122 | you use option 4d0, the Installation Information must accompany
123 | the Minimal Corresponding Source and Corresponding Application
124 | Code. If you use option 4d1, you must provide the Installation
125 | Information in the manner specified by section 6 of the GNU GPL
126 | for conveying Corresponding Source.)
127 |
128 | 5. Combined Libraries.
129 |
130 | You may place library facilities that are a work based on the
131 | Library side by side in a single library together with other library
132 | facilities that are not Applications and are not covered by this
133 | License, and convey such a combined library under terms of your
134 | choice, if you do both of the following:
135 |
136 | a) Accompany the combined library with a copy of the same work based
137 | on the Library, uncombined with any other library facilities,
138 | conveyed under the terms of this License.
139 |
140 | b) Give prominent notice with the combined library that part of it
141 | is a work based on the Library, and explaining where to find the
142 | accompanying uncombined form of the same work.
143 |
144 | 6. Revised Versions of the GNU Lesser General Public License.
145 |
146 | The Free Software Foundation may publish revised and/or new versions
147 | of the GNU Lesser General Public License from time to time. Such new
148 | versions will be similar in spirit to the present version, but may
149 | differ in detail to address new problems or concerns.
150 |
151 | Each version is given a distinguishing version number. If the
152 | Library as you received it specifies that a certain numbered version
153 | of the GNU Lesser General Public License "or any later version"
154 | applies to it, you have the option of following the terms and
155 | conditions either of that published version or of any later version
156 | published by the Free Software Foundation. If the Library as you
157 | received it does not specify a version number of the GNU Lesser
158 | General Public License, you may choose any version of the GNU Lesser
159 | General Public License ever published by the Free Software Foundation.
160 |
161 | If the Library as you received it specifies that a proxy can decide
162 | whether future versions of the GNU Lesser General Public License shall
163 | apply, that proxy's public statement of acceptance of any version is
164 | permanent authorization for you to choose that version for the
165 | Library.
166 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # blackbox-rs
2 |
3 | blackbox-rs is a series of Rust crates that is to be paired with [BlackBox](https://github.com/BlackboxMC/Blackbox), which allows you to create Bukkit compatible plugins using compiled langauges such as Rust.
4 |
5 | # Versioning
6 |
7 | Four of the crates are frozen at `0.4.0` due to no longer needing updates. The only one that gets updates is `blackboxmc-rs-bukkit`, which uses semantic versioning but places the patch version at the equivalant Minecraft version. For example, `1.2.21` is version 1.2 of the plugin, with compatibility for 1.21.
8 |
9 | # Contributing
10 |
11 | Due to the massive scale of Spigot's API, BlackBox is automatically generated by the `generate.py` script. There is a system for hand written code to be added via the `additions` folder. I am adverse to using macros or anything that would have the code generated at compile time, because I am a believer that if you are debugging a library, you should be able to go to the repo and have a good idea of what the code is doing.
12 |
13 | A `spigot.json` file is required; it is not in the repo, you have to generate it via [this repo](https://github.com/BlackBoxMC/SpigotJSON).
14 |
--------------------------------------------------------------------------------
/additions/README.md:
--------------------------------------------------------------------------------
1 | This folder contains many files consisting of manually written code that gets injected into the generated code.
2 |
3 | The format for this is as follows:
4 |
5 | ```
6 | //[file_path]#[struct]
7 | [code]
8 | ```
9 |
10 | The struct part is optional, but if you put it in, your code will be appended to the relevant struct instead of just the bottom of the file.
11 |
12 | Simply type the code into appropriately named files, and make sure the first line starts with two slashes and the path (relative to `generate.py`) where the code should be injected
--------------------------------------------------------------------------------
/additions/biconsumer_new.rs_:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-java/src/util/function/mod.rs#JavaBiConsumer
2 |
3 | #[cfg(not(target_arch = "wasm32"))]
4 | pub fn from_rust_fn<'mc2, A, B, C>(
5 | env: &'mc2 blackboxmc_general::SharedJNIEnv<'mc>,
6 | f: A,
7 | ) -> Result>
8 | where
9 | A: Fn(&'mc2 blackboxmc_general::SharedJNIEnv<'mc>, B, C),
10 | B: blackboxmc_general::JNIInstantiatable<'mc>,
11 | C: blackboxmc_general::JNIInstantiatable<'mc>,
12 | {
13 | // Create the closure.
14 | let closure: &_ = Box::leak(Box::new(
15 | move |a: *mut jni::sys::_jobject, b: *mut jni::sys::_jobject| unsafe {
16 | f(
17 | env,
18 | B::from_raw(&env, jni::objects::JObject::from_raw(a)).unwrap(),
19 | C::from_raw(&env, jni::objects::JObject::from_raw(b)).unwrap(),
20 | );
21 | },
22 | ));
23 | let callback = libffi::high::Closure2::new(closure);
24 | let &code = callback.code_ptr();
25 | let ptr: unsafe extern "C" fn(*const jni::sys::jobject) = unsafe { std::mem::transmute(code) };
26 | std::mem::forget(callback);
27 |
28 | // Create the java object.
29 | let obj = env.new_object(
30 | "net/ioixd/blackbox/BiConsumerLink",
31 | "(J)V",
32 | vec![(ptr as i64).into()],
33 | );
34 | let obj = env.translate_error_no_gen(obj)?;
35 |
36 | Self::from_raw(&env, obj)
37 | }
38 |
--------------------------------------------------------------------------------
/additions/biomeprovider_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/generator/mod.rs#BiomeProvider
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "BiomeProvider", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/blockpopulator_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/generator/mod.rs#BlockPopulator
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "BlockPopulator", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/chunkgenerator_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/generator/mod.rs#ChunkGenerator
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "ChunkGenerator", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/commandexecutor_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/command/mod.rs#CommandExecutor
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "CommandExecutor", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/configserializable_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/configuration/serialization/mod.rs#ConfigurationSerializable
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "ConfigSerializable", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/consumer_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/util/mod.rs#Consumer
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "Consumer", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/conversationcanceller_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/conversations/mod.rs#ConversationCanceller
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "ConversationCanceller", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/conversationprefix_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/conversations/mod.rs#ConversationPrefix
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "ConversationPrefix", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/helptopic_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/help/mod.rs#HelpTopic
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "HelpTopic", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/helptopicfactory_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/help/mod.rs#HelpTopicFactory
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "HelpTopicFactory", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/maprenderer_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/map/mod.rs#MapRenderer
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "MapRenderer", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/metadatavalue_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/metadata/mod.rs#MetadataValue
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "MetadataValue", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/noisegenerator_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/util/noise/mod.rs#NoiseGenerator
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "NoiseGenerator", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/persistentdatatype_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/persistence/mod.rs#PersistentDataType
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "PersistentDataType", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/plugin_base_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/plugin/mod.rs#PluginBase
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "PluginBase", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/plugin_loader_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/plugin/mod.rs#PluginLoader
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "PluginLoader", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/plugin_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/plugin/mod.rs#Plugin
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "Plugin", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/plugin_new_extendable.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/plugin/mod.rs#Plugin
2 | /// Return one of the extendable classes that BlackBox supports, based on the value given.
3 | ///
4 | /// ## Safety
5 | /// - It returns a Java Object that you must then cast into the proper object via JNI. You are responsible for the checks yourself.
6 | /// - This function is specific to the BlackboxPlugin class supplied within the plugin, and will error out if you pass a regular JavaPlugin.
7 | pub unsafe fn new_extendable(
8 | &self,
9 | address: i32,
10 | class_name: impl Into
11 | + std::convert::AsRef
12 | + std::convert::AsRef
13 | + std::convert::AsRef,
14 | name: impl Into + std::convert::AsRef + std::convert::AsRef,
15 | lib_name: impl Into + std::convert::AsRef + std::convert::AsRef,
16 | ) -> Result> {
17 | let obj = self.jni_ref().call_method(
18 | &self.1,
19 | "newExtendable",
20 | "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)Ljava/lang/Object;",
21 | vec![
22 | jni::objects::JValueGen::Int(address),
23 | jni::objects::JValueGen::from(jni::objects::JObject::from(
24 | self.jni_ref().new_string(class_name).unwrap(),
25 | )),
26 | jni::objects::JValueGen::from(jni::objects::JObject::from(
27 | self.jni_ref().new_string(name).unwrap(),
28 | )),
29 | jni::objects::JValueGen::from(jni::objects::JObject::from(
30 | self.jni_ref().new_string(lib_name).unwrap(),
31 | )),
32 | #[cfg(target_arch = "wasm32")]
33 | jni::objects::JValueGen::Bool(true.into()),
34 | #[cfg(not(target_arch = "wasm32"))]
35 | jni::objects::JValueGen::Bool(false.into()),
36 | ],
37 | );
38 | let obj = self.jni_ref().translate_error(obj)?;
39 | Ok(jni::objects::JObject::from_raw(*obj.l()?))
40 | }
41 |
--------------------------------------------------------------------------------
/additions/prompt_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/conversations/mod.rs#Prompt
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "Prompt", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/runnable_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/scheduler/mod.rs#BukkitRunnable
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "BukkitRunnable", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/tabcompleter_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/command/mod.rs#TabCompleter
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "TabCompleter", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/additions/tabexecutor_new.rs:
--------------------------------------------------------------------------------
1 | // blackboxmc-rs-bukkit/src/command/mod.rs#TabExecutor
2 | pub fn from_extendable(
3 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
4 | plugin: &'mc crate::plugin::Plugin,
5 | address: i32,
6 | lib_name: String,
7 | name: String,
8 | ) -> Result> {
9 | let obj = unsafe { plugin.new_extendable(address, "TabExecutor", name, lib_name) }?;
10 | Self::from_raw(env, obj)
11 | }
12 |
--------------------------------------------------------------------------------
/blackboxmc-rs-bukkit/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "blackboxmc_bukkit"
3 | version = "1.0.21"
4 | edition = "2021"
5 | license = "LGPL-2.0-or-later"
6 | description = "BlackboxMC bindings for org.bukkit"
7 |
8 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
9 |
10 | [dependencies]
11 | color-eyre = "0.6.2"
12 | eyre = "0.6.8"
13 | jni = "0.21.1"
14 | blackboxmc_general = { version = "0.4.0", path = "../blackboxmc-rs-general" }
15 | blackboxmc_bungee = { version = "0.4.0", path = "../blackboxmc-rs-bungee" }
16 | blackboxmc_java = { version = "0.4.0", path = "../blackboxmc-rs-java" }
17 |
18 | [build-dependencies]
19 | lazy_static = "1.4.0"
20 | quote = "1.0.35"
21 | regex = "1.10.4"
22 | serde = "1.0.197"
23 | serde_derive = "1.0.197"
24 | serde_json = "1.0.115"
25 |
--------------------------------------------------------------------------------
/blackboxmc-rs-bukkit/README.md:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/BlackBoxMC/blackboxmc-rs/7faecca02864dd5612cbeba1db5805a9987b59ac/blackboxmc-rs-bukkit/README.md
--------------------------------------------------------------------------------
/blackboxmc-rs-bukkit/src/ban/mod.rs:
--------------------------------------------------------------------------------
1 | #![allow(deprecated)]
2 | use blackboxmc_general::JNIInstantiatable;
3 | use blackboxmc_general::JNIRaw;
4 | use color_eyre::eyre::Result;
5 | #[repr(C)]
6 | pub struct IpBanList<'mc>(
7 | pub(crate) blackboxmc_general::SharedJNIEnv<'mc>,
8 | pub(crate) jni::objects::JObject<'mc>,
9 | );
10 |
11 | impl<'mc> JNIRaw<'mc> for IpBanList<'mc> {
12 | fn jni_ref(&self) -> blackboxmc_general::SharedJNIEnv<'mc> {
13 | self.0.clone()
14 | }
15 | fn jni_object(&self) -> jni::objects::JObject<'mc> {
16 | unsafe { jni::objects::JObject::from_raw(self.1.clone()) }
17 | }
18 | }
19 | impl<'mc> JNIInstantiatable<'mc> for IpBanList<'mc> {
20 | fn from_raw(
21 | env: &blackboxmc_general::SharedJNIEnv<'mc>,
22 | obj: jni::objects::JObject<'mc>,
23 | ) -> Result> {
24 | if obj.is_null() {
25 | return Err(eyre::eyre!("Tried to instantiate IpBanList from null object.").into());
26 | }
27 | let (valid, name) = env.validate_name(&obj, "org/bukkit/ban/IpBanList")?;
28 | if !valid {
29 | Err(eyre::eyre!(
30 | "Invalid argument passed. Expected a IpBanList object, got {}",
31 | name
32 | )
33 | .into())
34 | } else {
35 | Ok(Self(env.clone(), obj))
36 | }
37 | }
38 | }
39 |
40 | impl<'mc> IpBanList<'mc> {
41 | /// Gets a {@link BanEntry} by target.
42 | pub fn get_ban_entry(
43 | &self,
44 | target: jni::objects::JObject<'mc>,
45 | ) -> Result