crwdns131295:0crwdne131295:0
crwdns131297:0crwdne131297:0
import org.spongepowered.api.Sponge;
Sponge.getServiceManager().provide(EventManager.class);
crwdns131299:0crwdne131299:0
crwdns131301:0crwdne131301:0
crwdns131303:0crwdne131303:0
crwdns131305:0crwdne131305:0
crwdns131307:0:doc:crwdne131307:0
Note
crwdns131309:0crwdne131309:0
crwdns131311:0crwdne131311:0
crwdns131313:0:javadoc:crwdne131313:0
Sponge.getServiceManager().setProvider(Object plugin, Class<T> service, T provider);
crwdns131315:0crwdne131315:0
crwdns131317:0crwdne131317:0
Note
crwdns131319:0crwdne131319:0
crwdns131321:0crwdne131321:0
crwdns131323:0crwdne131323: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);
}
crwdns131325:0crwdne131325: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);
}
}
crwdns131327:0crwdne131327:0
crwdns131329:0crwdne131329:0
Sponge.getServiceManager().setProvider(yourPluginInstance, WarpService.class, new SimpleWarpService());
crwdns131331:0crwdne131331:0
Sponge.getServiceManager().provide(WarpService.class);
Tip
crwdns131333:0crwdne131333:0