本文整理匯總了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();
}