├── .gitignore
├── .gitmodules
├── CONTRIBUTING.md
├── LICENSE
├── README.md
├── pom.xml
└── src
└── main
├── java
└── net
│ └── glowstone
│ └── bukkit2sponge
│ ├── Bukkit2Sponge.java
│ ├── ShinyGame.java
│ ├── ShinyGameRegistry.java
│ ├── ShinyServer.java
│ ├── block
│ ├── ShinyBlockSnapshot.java
│ ├── ShinyBlockState.java
│ └── ShinyBlockType.java
│ ├── bukkit
│ └── BukkitListener.java
│ ├── command
│ ├── BukkitCommand.java
│ └── ShinyConsoleSource.java
│ ├── event
│ ├── BaseEvent.java
│ ├── EventRegistration.java
│ └── ShinyEventManager.java
│ ├── guice
│ ├── ConfigDirAnnotation.java
│ ├── ConfigFileAnnotation.java
│ ├── ShinyGuiceModule.java
│ └── ShinyPluginGuiceModule.java
│ ├── inventory
│ └── ShinyItemStack.java
│ ├── item
│ ├── ShinyItemType.java
│ └── ShinyItemTypes.java
│ ├── permission
│ └── ShinySubject.java
│ ├── plugin
│ ├── DefaultShader.java
│ ├── GlowstoneConnector.java
│ ├── PluginLoader.java
│ ├── ShinyClassLoader.java
│ ├── ShinyPluginContainer.java
│ └── ShinyPluginManager.java
│ ├── text
│ └── ShinyTranslation.java
│ ├── util
│ └── Unsupported.java
│ └── world
│ └── ShinyWorld.java
└── resources
└── plugin.yml
/.gitignore:
--------------------------------------------------------------------------------
1 | /.classpath
2 | /.project
3 | /.settings
4 | /nbproject
5 | /target
6 | /bin
7 | /dist
8 | /.idea
9 | .*.sw[a-p]
10 | *.iml
11 | /dependency-reduced-pom.xml
12 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "SpongeAPI"]
2 | path = SpongeAPI
3 | url = https://github.com/SpongePowered/SpongeAPI
4 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Bukkit2Sponge an OPEN Open Source Project
2 |
3 | -----------------------------------------
4 |
5 | ## What?
6 |
7 | Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.
8 |
9 | ## Rules
10 |
11 | There are a few basic ground-rules for contributors:
12 |
13 | 1. **No `--force` pushes** or modifying the Git history in any way.
14 | 1. **Non-master branches** ought to be used for ongoing work.
15 | 1. **External API changes and significant modifications** ought to be subject to an **internal pull-request** to solicit feedback from other contributors.
16 | 1. Internal pull-requests to solicit feedback are *encouraged* for any other non-trivial contribution but left to the discretion of the contributor.
17 | 1. Contributors should attempt to adhere to the prevailing code-style.
18 |
19 | ## Releases
20 |
21 | Declaring formal releases remains the prerogative of the project maintainer.
22 |
23 | ## Changes to this arrangement
24 |
25 | This is an experiment and feedback is welcome! This document may also be subject to pull-requests or changes by contributors where you believe you have something valuable to add or change.
26 |
27 | -----------------------------------------
28 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Bukkit2Sponge Copyright (C) 2016-2017 The Glowstone Project
2 | Bukkit2Sponge Copyright (C) 2015 deathcap
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy
5 | of this software and associated documentation files (the "Software"), to deal
6 | in the Software without restriction, including without limitation the rights
7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 | copies of the Software, and to permit persons to whom the Software is
9 | furnished to do so, subject to the following conditions:
10 |
11 | The above copyright notice and this permission notice shall be included in
12 | all copies or substantial portions of the Software.
13 |
14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20 | THE SOFTWARE.
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Bukkit2Sponge
2 | =============
3 |
4 | An implementation of [SpongeAPI](https://github.com/SpongePowered/SpongeAPI) as a Bukkit plugin.
5 |
6 | Bukkit2Sponge allows loading SpongeAPI plugins on Bukkit servers.
7 |
8 | * [Bukkit2Sponge thread on Sponge Forums](https://forums.spongepowered.org/t/bukkit2sponge-an-implementation-of-spongeapi-for-bukkit-servers/6747)
9 | * [Bukkit2Sponge resource on SpigotMC](http://www.spigotmc.org/resources/bukkit2sponge.6368/)
10 |
11 | Warning: very incomplete (bug reports and pull requests appreciated, see [issues](https://github.com/GlowstonePlusPlus/Bukkit2Sponge/issues))
12 |
13 | Usage
14 | -----
15 |
16 | Copy the plugin jar to the `plugins` directory of your Bukkit server.
17 |
18 | Run your server, the first time it will create a `plugins/Bukkit2Sponge/plugins` directory.
19 | You can place your SpongeAPI plugins here.
20 |
21 | If using the [Glowstone](https://github.com/GlowstoneMC/Glowstone)
22 | server, you can alternatively place the SpongeAPI plugins in the top-level `plugins/` directory
23 | and they will be loaded by Bukkit2Sponge as well.
24 |
25 | When starting the server, if configured correctly Bukkit2Sponge should log the SpongeAPI plugins it finds:
26 |
27 | ```
28 | 12:00:00 [INFO] [Bukkit2Sponge] Loading plugins...
29 | 12:00:00 [INFO] [Bukkit2Sponge] Initializing 1 SpongeAPI plugins...
30 | ```
31 |
32 | Downloads
33 | ---------
34 |
35 | Latest builds are available from:
36 | https://bamboo.gserv.me/browse/GSPP-B2S/latestSuccessful/artifact/shared/Plugin-JAR/bukkit2sponge-0.1.0-SNAPSHOT.jar
37 |
38 |
39 | Building from source
40 | --------------------
41 |
42 | 1. After installing the
43 | [Java Development Kit](http://oracle.com/technetwork/java/javase/downloads) and
44 | [Maven](https://maven.apache.org), checkout the source:
45 |
46 | ```
47 | git clone https://github.com/GlowstoneMC/Bukkit2Sponge
48 | cd Bukkit2Sponge
49 | ```
50 |
51 | 2. Build the plugin:
52 |
53 | ```
54 | mvn package
55 | ```
56 |
57 | The plugin jar will be placed in `target/`.
58 |
59 |
60 | See also
61 | --------
62 |
63 | * [SpongeForge](https://github.com/SpongePowered/SpongeForge): SpongeAPI implementation on Minecraft Forge
64 | * [SpongeVanilla](https://github.com/SpongePowered/SpongeVanilla): SpongeAPI implementation on Minecraft
65 | * [Pore](https://github.com/LapisBlue/Pore): a SpongeAPI plugin to load Bukkit plugins (the opposite of Bukkit2Sponge)
66 |
67 | License
68 | -------
69 |
70 | Bukkit2Sponge is open-source software released under the MIT license. Please see
71 | the `LICENSE` file for details.
72 |
73 | Bukkit is open-source software released under the GPL license. Please see
74 | the `LICENSE.txt` file in the Bukkit repository for details.
75 |
76 | Sponge is open-source software released under the MIT license. Please see
77 | the `LICENSE.txt` file in the Sponge repository for details.
78 |
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
3 | 4.0.0
4 | net.glowstone
5 | bukkit2sponge
6 | jar
7 | 0.1.0-SNAPSHOT
8 | Bukkit2Sponge
9 | https://github.com/GlowstoneMC/Bukkit2Sponge
10 |
11 |
12 | UTF-8
13 | 1.12-pre5-SNAPSHOT
14 | 6.0.0
15 | yyyyMMdd-HHmm
16 | 1.8
17 | 1.8
18 |
19 |
20 |
21 | org.sonatype.oss
22 | oss-parent
23 | 9
24 |
25 |
26 |
27 |
28 |
29 | glowstone-repo
30 | https://repo.glowstone.net/repository/internal/
31 |
32 |
33 | sponge-repo
34 | https://repo.spongepowered.org/maven
35 |
36 |
37 |
38 |
39 |
40 | glowstone-upstream
41 | https://repo.glowstone.net/content/repositories/releases/
42 |
43 |
44 | glowstone-upstream
45 | https://repo.glowstone.net/content/repositories/snapshots/
46 |
47 |
48 |
49 |
50 |
51 | org.projectlombok
52 | lombok
53 | 1.14.8
54 | provided
55 |
56 |
57 | net.glowstone
58 | glowkit
59 | ${bukkit.version}
60 | jar
61 | provided
62 |
63 |
64 | org.spongepowered
65 | spongeapi
66 | ${sponge.version}
67 | jar
68 |
69 |
70 | com.google.inject
71 | guice
72 | 4.0
73 |
74 |
75 | ninja.leaping.configurate
76 | configurate-hocon
77 | 3.3
78 |
79 |
80 | org.ow2.asm
81 | asm
82 | 5.0.3
83 |
84 |
85 | org.ow2.asm
86 | asm-commons
87 | 5.0.3
88 |
89 |
90 |
91 |
92 |
93 |
94 | src/main/resources
95 | true
96 |
97 |
98 |
99 |
100 | org.apache.maven.plugins
101 | maven-shade-plugin
102 | 3.0.0
103 |
104 |
105 | package
106 |
107 | shade
108 |
109 |
110 |
111 |
112 | junit:junit
113 |
114 |
115 |
116 |
117 |
118 | com.google.common
119 | net.glowstone.bukkit2sponge.libs.guava17.com.google.common
120 |
121 |
122 |
123 | org.objectweb.asm
124 | net.glowstone.bukkit2sponge.libs.asm5.org.objectweb.asm
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 | org.apache.maven.plugins
134 | maven-jar-plugin
135 | 3.0.2
136 |
137 |
138 |
139 | ${project.name}
140 | ${project.version}
141 | ${sponge.version}
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
--------------------------------------------------------------------------------
/src/main/java/net/glowstone/bukkit2sponge/Bukkit2Sponge.java:
--------------------------------------------------------------------------------
1 |
2 | package net.glowstone.bukkit2sponge;
3 |
4 | import com.google.common.io.PatternFilenameFilter;
5 | import com.google.inject.Guice;
6 | import com.google.inject.Injector;
7 | import net.glowstone.bukkit2sponge.bukkit.BukkitListener;
8 | import net.glowstone.bukkit2sponge.guice.ShinyGuiceModule;
9 | import net.glowstone.bukkit2sponge.plugin.GlowstoneConnector;
10 | import org.bukkit.plugin.java.JavaPlugin;
11 | import org.spongepowered.api.Platform;
12 | import org.spongepowered.api.event.game.state.GameConstructionEvent;
13 | import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
14 | import org.spongepowered.api.event.game.state.GameStateEvent;
15 |
16 | import java.io.File;
17 | import java.io.IOException;
18 | import java.net.MalformedURLException;
19 | import java.net.URL;
20 | import java.util.ArrayList;
21 | import java.util.Collection;
22 | import java.util.List;
23 |
24 | public class Bukkit2Sponge extends JavaPlugin {
25 |
26 | public static Bukkit2Sponge instance = null;
27 | private final BukkitListener bukkitListener = new BukkitListener();
28 |
29 | public Injector getInjector() {
30 | return injector;
31 | }
32 |
33 | private Injector injector;
34 |
35 | private ShinyGame game;
36 |
37 | @Override
38 | public void onDisable() {
39 | getLogger().info("Goodbye world!");
40 | }
41 |
42 | @Override
43 | public void onEnable() {
44 | Bukkit2Sponge.instance = this;
45 | getLogger().info( getDescription().getName() + " v" + getDescription().getVersion() + " is loading...");
46 | load();
47 | }
48 |
49 | private List getPluginURLs() {
50 | // Our own personal plugins directory
51 | File directory = getPluginsDirectory();
52 |
53 | if (!directory.exists()) {
54 | directory.mkdirs();
55 | }
56 |
57 | File[] files = directory.listFiles(new PatternFilenameFilter(".+\\.jar"));
58 |
59 | List urls = new ArrayList<>(files.length);
60 | for (File jar : files) {
61 | try {
62 | urls.add(jar.toURI().toURL());
63 | } catch (MalformedURLException e) {
64 | Bukkit2Sponge.instance.getLogger().warning("Malformed URL: " + jar + e);
65 | }
66 | }
67 |
68 | List gs = GlowstoneConnector.getSpongePlugins(getServer());
69 | if (gs != null) {
70 | Bukkit2Sponge.instance.getLogger().info("Glowstone integration enabled (" + gs.size() + " plugins)");
71 | urls.addAll(gs);
72 | }
73 |
74 | return urls;
75 | }
76 |
77 | private void load() {
78 | Collection loadedPluginURLs;
79 | List urls = getPluginURLs();
80 |
81 | try {
82 | injector = Guice.createInjector(new ShinyGuiceModule());
83 |
84 | /*
85 | CONSTRUCTION,
86 | LOAD_COMPLETE,
87 | PRE_INITIALIZATION,
88 | INITIALIZATION,
89 | POST_INITIALIZATION,
90 | SERVER_ABOUT_TO_START,
91 | SERVER_STARTING,
92 | SERVER_STARTED,
93 | SERVER_STOPPING,
94 | SERVER_STOPPED
95 | */
96 |
97 |
98 | game = injector.getInstance(ShinyGame.class);
99 |
100 | getServer().getPluginManager().registerEvents(bukkitListener, this);
101 |
102 | getLogger().info("SpongeAPI version: " + game.getPlatform().getContainer(Platform.Component.API).getVersion().get());
103 |
104 | getLogger().info("Loading SpongeAPI plugins...");
105 | loadedPluginURLs = game.getPluginManager().loadPlugins(urls);
106 | postState(GameConstructionEvent.class);
107 | getLogger().info("Initializing " + loadedPluginURLs.size() + " SpongeAPI plugins...");
108 | postState(GamePreInitializationEvent.class);
109 | } catch (IOException e) {
110 | throw new RuntimeException(e);
111 | }
112 | }
113 |
114 | public ShinyGame getGame() {
115 | return this.game;
116 | }
117 |
118 | public void postState(Class extends GameStateEvent> type) {
119 |
120 | }
121 |
122 | // Sponge directories relative to our own Bukkit plugin data folder
123 |
124 | public File getPluginsDirectory() {
125 | return new File(this.getDataFolder(), "plugins");
126 | }
127 |
128 | public File getConfigDirectory() {
129 | return new File(this.getDataFolder(), "config");
130 | }
131 | }
--------------------------------------------------------------------------------
/src/main/java/net/glowstone/bukkit2sponge/ShinyGame.java:
--------------------------------------------------------------------------------
1 | package net.glowstone.bukkit2sponge;
2 |
3 | import com.google.inject.Inject;
4 | import com.google.inject.Singleton;
5 | import net.glowstone.bukkit2sponge.plugin.ShinyPluginManager;
6 | import org.bukkit.Bukkit;
7 | import org.spongepowered.api.*;
8 | import org.spongepowered.api.plugin.PluginContainer;
9 | import org.spongepowered.api.service.ServiceManager;
10 | import org.spongepowered.api.service.SimpleServiceManager;
11 | import org.spongepowered.api.world.TeleportHelper;
12 |
13 | import java.nio.file.Path;
14 | import java.util.Map;
15 | import java.util.Optional;
16 |
17 | /**
18 | * Implementation of {@link Game}.
19 | */
20 |
21 | @Singleton
22 | public class ShinyGame implements Game {
23 |
24 | private final ShinyPluginManager pluginManager = new ShinyPluginManager(this);
25 | private final ShinyGameRegistry registry = new ShinyGameRegistry();
26 | private final SimpleServiceManager services = new SimpleServiceManager(pluginManager);
27 | private final ShinyServer server = new ShinyServer(Bukkit.getServer());
28 |
29 | private static final String API_VERSION;
30 | private static final String IMPL_VERSION;
31 |
32 | static {
33 | Package pkg = ShinyGame.class.getPackage();
34 | String apiVersion = pkg.getSpecificationVersion();
35 | API_VERSION = (apiVersion == null) ? "unknown" : apiVersion;
36 | String implVersion = pkg.getImplementationVersion();
37 | IMPL_VERSION = (implVersion == null) ? "unknown" : implVersion;
38 | }
39 |
40 | @Inject
41 | public ShinyGame() {
42 |
43 | }
44 |
45 | // platform information
46 |
47 | @Override
48 | public Platform getPlatform() {
49 | return new Platform() {
50 | @Override
51 | public Type getType() {
52 | return Type.SERVER;
53 | }
54 |
55 | @Override
56 | public Type getExecutionType() {
57 | return Type.SERVER;
58 | }
59 |
60 | @Override
61 | public PluginContainer getContainer(Component component) {
62 | return new PluginContainer() {
63 | @Override
64 | public String getId() {
65 | return "SpongeAPI";
66 | }
67 |
68 | @Override
69 | public Optional getVersion() {
70 | return Optional.ofNullable(ShinyGame.this.getClass().getPackage().getSpecificationVersion());
71 | }
72 | };
73 | }
74 |
75 | @Override
76 | public MinecraftVersion getMinecraftVersion() {
77 | return null;
78 | }
79 |
80 | @Override
81 | public Map asMap() {
82 | return null;
83 | }
84 | };
85 | }
86 |
87 | private GameState state;
88 |
89 | @Override
90 | public GameState getState() {
91 | return state;
92 | }
93 |
94 | public void setState(GameState state) {
95 | this.state = state;
96 | }
97 |
98 | @Override
99 | public Path getGameDirectory() {
100 | return null;
101 | }
102 |
103 | @Override
104 | public Path getSavesDirectory() {
105 | return null;
106 | }
107 |
108 | @Override
109 | public boolean isServerAvailable() {
110 | return false;
111 | }
112 |
113 | @Override
114 | public Server getServer() {
115 | return server;
116 | }
117 |
118 | @Override
119 | public GameDictionary getGameDictionary() {
120 | return null;
121 | }
122 |
123 | @Override
124 | public TeleportHelper getTeleportHelper() {
125 | return null; //To change body of implemented methods use File | Settings | File Templates.
126 | }
127 |
128 | // service access
129 |
130 | @Override
131 | public ShinyPluginManager getPluginManager() {
132 | return pluginManager;
133 | }
134 |
135 | @Override
136 | public GameRegistry getRegistry() {
137 | return registry;
138 | }
139 |
140 | @Override
141 | public ServiceManager getServiceManager() {
142 | return services;
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/src/main/java/net/glowstone/bukkit2sponge/ShinyGameRegistry.java:
--------------------------------------------------------------------------------
1 | package net.glowstone.bukkit2sponge;
2 |
3 | import org.spongepowered.api.CatalogType;
4 | import org.spongepowered.api.GameRegistry;
5 | import org.spongepowered.api.block.BlockType;
6 | import org.spongepowered.api.data.type.Art;
7 | import org.spongepowered.api.data.value.ValueFactory;
8 | import org.spongepowered.api.entity.EntityType;
9 | import org.spongepowered.api.entity.ai.task.AITaskType;
10 | import org.spongepowered.api.entity.ai.task.AbstractAITask;
11 | import org.spongepowered.api.entity.living.Agent;
12 | import org.spongepowered.api.item.ItemType;
13 | import org.spongepowered.api.item.merchant.VillagerRegistry;
14 | import org.spongepowered.api.item.recipe.RecipeRegistry;
15 | import org.spongepowered.api.network.status.Favicon;
16 | import org.spongepowered.api.registry.CatalogRegistryModule;
17 | import org.spongepowered.api.registry.CatalogTypeAlreadyRegisteredException;
18 | import org.spongepowered.api.registry.RegistryModule;
19 | import org.spongepowered.api.registry.RegistryModuleAlreadyRegisteredException;
20 | import org.spongepowered.api.resourcepack.ResourcePack;
21 | import org.spongepowered.api.scoreboard.displayslot.DisplaySlot;
22 | import org.spongepowered.api.statistic.BlockStatistic;
23 | import org.spongepowered.api.statistic.EntityStatistic;
24 | import org.spongepowered.api.statistic.ItemStatistic;
25 | import org.spongepowered.api.statistic.StatisticType;
26 | import org.spongepowered.api.text.format.TextColor;
27 | import org.spongepowered.api.text.selector.SelectorFactory;
28 | import org.spongepowered.api.text.serializer.TextSerializerFactory;
29 | import org.spongepowered.api.text.translation.Translation;
30 | import org.spongepowered.api.util.ResettableBuilder;
31 | import org.spongepowered.api.util.rotation.Rotation;
32 | import org.spongepowered.api.world.extent.ExtentBufferFactory;
33 |
34 | import java.awt.image.BufferedImage;
35 | import java.io.IOException;
36 | import java.io.InputStream;
37 | import java.net.URL;
38 | import java.nio.file.Path;
39 | import java.util.*;
40 | import java.util.function.Supplier;
41 |
42 | /**
43 | * Implementation of {@link GameRegistry}.
44 | */
45 | public class ShinyGameRegistry implements GameRegistry {
46 |
47 | private final Map blocks = new HashMap<>();
48 | private final Map items = new HashMap<>();
49 | private final Map arts = new HashMap<>();
50 | private final Map rotations = new HashMap<>();
51 | private final Map