crwdns150561:0crwdne150561:0
crwdns150563:0crwdne150563:0
import org.spongepowered.api.Sponge;
Sponge.getServiceManager().provide(EventManager.class);
crwdns150565:0crwdne150565:0
crwdns150567:0crwdne150567:0
crwdns150569:0crwdne150569:0
crwdns150571:0crwdne150571:0
crwdns150573:0:doc:crwdne150573:0
Note
crwdns150575:0crwdne150575:0
crwdns150577:0crwdne150577:0
crwdns150579:0:javadoc:crwdne150579:0
Sponge.getServiceManager().setProvider(Object plugin, Class<T> service, T provider);
crwdns150581:0crwdne150581:0
crwdns150583:0crwdne150583:0
Note
crwdns150585:0crwdne150585:0
crwdns150587:0crwdne150587:0
crwdns150589:0crwdne150589:0
import org.spongepowered.api.world.Location;
import org.spongepowered.api.world.World;
import java.util.Optional;
public interface WarpService {
void setWarp(String name, Location<World> location);
Optional<Location<World>> getWarp(String name);
}
crwdns150591:0crwdne150591:0
import java.util.HashMap;
public class SimpleWarpService implements WarpService {
HashMap<String, Location<World>> warpMap = new HashMap<String, Location<World>>();
@Override
public Optional<Location<World>> getWarp(String name) {
if(!warpMap.containsKey(name)) {
return Optional.empty();
} else {
return Optional.of(warpMap.get(name));
}
}
@Override
public void setWarp(String name, Location<World> location) {
warpMap.put(name, location);
}
}
crwdns150593:0crwdne150593:0
crwdns150595:0crwdne150595:0
Sponge.getServiceManager().setProvider(yourPluginInstance, WarpService.class, new SimpleWarpService());
crwdns150597:0crwdne150597:0
Sponge.getServiceManager().provide(WarpService.class);
Tip
crwdns150599:0crwdne150599:0