mirror of
https://github.com/EssentialsX/Essentials.git
synced 2025-01-05 16:08:14 +01:00
Add API packages (#3938)
Adds packages for future EssentialsX 2.x API and services.
This commit is contained in:
parent
9ce839c9d8
commit
eee1c0628b
@ -0,0 +1,4 @@
|
|||||||
|
/**
|
||||||
|
* API classes, services, and events provided by EssentialsX 2.x.
|
||||||
|
*/
|
||||||
|
package net.essentialsx.api.v2;
|
@ -0,0 +1,7 @@
|
|||||||
|
/**
|
||||||
|
* API services provided by EssentialsX. These are registered with Bukkit's ServicesManager, and can be accessed from there without getting an instance of EssentialsX first.
|
||||||
|
*
|
||||||
|
* @see org.bukkit.Server#getServicesManager()
|
||||||
|
* @see org.bukkit.plugin.ServicesManager#load(java.lang.Class)
|
||||||
|
*/
|
||||||
|
package net.essentialsx.api.v2.services;
|
@ -56,6 +56,8 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.PluginLoader;
|
import org.bukkit.plugin.PluginLoader;
|
||||||
import org.bukkit.plugin.PluginManager;
|
import org.bukkit.plugin.PluginManager;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.bukkit.plugin.ServicePriority;
|
||||||
import org.bukkit.plugin.ServicesManager;
|
import org.bukkit.plugin.ServicesManager;
|
||||||
import org.bukkit.plugin.UnknownDependencyException;
|
import org.bukkit.plugin.UnknownDependencyException;
|
||||||
import org.bukkit.plugin.messaging.Messenger;
|
import org.bukkit.plugin.messaging.Messenger;
|
||||||
@ -80,10 +82,11 @@ import java.util.concurrent.Future;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
@SuppressWarnings({"NullableProblems", "ConstantConditions", "Contract"})
|
||||||
public class FakeServer implements Server {
|
public class FakeServer implements Server {
|
||||||
private final List<World> worlds = new ArrayList<>();
|
private final List<World> worlds = new ArrayList<>();
|
||||||
private final PluginManager pluginManager = new FakePluginManager();
|
private final PluginManager pluginManager = new FakePluginManager();
|
||||||
private List<Player> players = new ArrayList<>();
|
private final List<Player> players = new ArrayList<>();
|
||||||
|
|
||||||
FakeServer() {
|
FakeServer() {
|
||||||
if (Bukkit.getServer() == null) {
|
if (Bukkit.getServer() == null) {
|
||||||
@ -106,10 +109,6 @@ public class FakeServer implements Server {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnlinePlayers(final List<Player> players) {
|
|
||||||
this.players = players;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getMaxPlayers() {
|
public int getMaxPlayers() {
|
||||||
return 100;
|
return 100;
|
||||||
@ -355,7 +354,57 @@ public class FakeServer implements Server {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServicesManager getServicesManager() {
|
public ServicesManager getServicesManager() {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
return new ServicesManager() {
|
||||||
|
@Override
|
||||||
|
public <T> void register(Class<T> service, T provider, Plugin plugin, ServicePriority priority) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregisterAll(Plugin plugin) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregister(Class<?> service, Object provider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void unregister(Object provider) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> T load(Class<T> service) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> RegisteredServiceProvider<T> getRegistration(Class<T> service) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<RegisteredServiceProvider<?>> getRegistrations(Plugin plugin) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> Collection<RegisteredServiceProvider<T>> getRegistrations(Class<T> service) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<Class<?>> getKnownServices() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T> boolean isProvidedFor(Class<T> service) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -369,12 +418,6 @@ public class FakeServer implements Server {
|
|||||||
return w;
|
return w;
|
||||||
}
|
}
|
||||||
|
|
||||||
public World createWorld(final String string, final Environment e, final long l) {
|
|
||||||
final World w = new FakeWorld(string, e);
|
|
||||||
worlds.add(w);
|
|
||||||
return w;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld(final String string) {
|
public World getWorld(final String string) {
|
||||||
for (final World world : worlds) {
|
for (final World world : worlds) {
|
||||||
@ -459,10 +502,6 @@ public class FakeServer implements Server {
|
|||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
public World getWorld(final long l) {
|
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public World getWorld(final UUID uuid) {
|
public World getWorld(final UUID uuid) {
|
||||||
throw new UnsupportedOperationException("Not supported yet.");
|
throw new UnsupportedOperationException("Not supported yet.");
|
||||||
|
Loading…
Reference in New Issue
Block a user