本文整理汇总了Java中org.spongepowered.api.plugin.Plugin类的典型用法代码示例。如果您正苦于以下问题:Java Plugin类的具体用法?Java Plugin怎么用?Java Plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Plugin类属于org.spongepowered.api.plugin包,在下文中一共展示了Plugin类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onServerInitialization
import org.spongepowered.api.plugin.Plugin; //导入依赖的package包/类
@Listener
public void onServerInitialization(GamePreInitializationEvent event) {
instance = this;
log(Level.INFO, "Initializing NamelessMC " + getClass().getAnnotation(Plugin.class).version());
// Luckperms Check
if(game.getPluginManager().isLoaded("luckperms")) {
permissions = new LuckPerms();
}
// Economy Service Initliazation
Optional<EconomyService> eopt = game.getServiceManager().provide(EconomyService.class);
if (eopt.isPresent()) {
System.out.println("economy works");
economy = eopt.get();
}
// Initialize Configuration
try {
Config.initialize();
} catch (IOException e) {
log(Level.ERROR, "Unable to load config.");
e.printStackTrace();
return;
}
if (!checkConnection()) return;
}
示例2: getPluginName
import org.spongepowered.api.plugin.Plugin; //导入依赖的package包/类
private String getPluginName(Object plugin) {
if(plugin == null) {
return null;
}
Class pluginClass = plugin.getClass();
if(pluginClass.isAnnotationPresent(Plugin.class)) {
Plugin annotation = (Plugin) pluginClass.getAnnotation(Plugin.class);
return annotation.name();
}
return null;
}
示例3: run
import org.spongepowered.api.plugin.Plugin; //导入依赖的package包/类
@Override
public void run(CommandSource sender, String[] args) {
sender.sendMessage(Colors.color(I18n.tl("prefix") + " " + I18n.tl("cmd_current_version", plugin.getClass().getAnnotation(Plugin.class).version())));
}
示例4: process
import org.spongepowered.api.plugin.Plugin; //导入依赖的package包/类
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
if (roundEnv.processingOver()) {
if (!roundEnv.errorRaised()) {
finish();
}
return true;
}
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(Plugin.class);
if (elements.size() == 0) {
return false;
}
for (Element e : elements) {
try {
if (e.getKind() != ElementKind.CLASS) {
error("Invalid element of type " + e.getKind() + " annotated with @"
+ Plugin.class.getSimpleName());
continue;
}
Plugin annotation = e.getAnnotation(Plugin.class);
String id = annotation.name().toLowerCase();
if (!plugins.containsKey(id)) {
plugins.put(id, new OsmiumMetaContainer(((TypeElement) e).getQualifiedName().toString(), // new
// OsmiumMetaContainer(Class.forName(((TypeElement)
// e).getQualifiedName().toString()).asSubclass(OsmiumPlugin.class),
annotation.name(), annotation.version(), annotation.description(), annotation.url(),
annotation.authors(), annotation.dependencies()));
info("Generating plugin metafiles for annotation: " + Objects.toClassString(plugins.get(id)));
} else {
error("Plugin with id '" + id + "' already exists!");
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
return true;
}
示例5: getPluginVersion
import org.spongepowered.api.plugin.Plugin; //导入依赖的package包/类
@Override
public String getPluginVersion() {
return plugin.getClass().getAnnotation(Plugin.class).version();
}