本文整理汇总了Java中org.spongepowered.api.plugin.PluginContainer类的典型用法代码示例。如果您正苦于以下问题:Java PluginContainer类的具体用法?Java PluginContainer怎么用?Java PluginContainer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PluginContainer类属于org.spongepowered.api.plugin包,在下文中一共展示了PluginContainer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: validateSpongeVersion
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
private boolean validateSpongeVersion() {
PluginContainer container = Sponge.getPlatform().getContainer(Platform.Component.IMPLEMENTATION);
if (container.getName().equals("SpongeForge")) {
try {
String version = container.getVersion().orElseThrow(Exception::new);
version = version.substring(Math.max(version.length() - 4, 0));
int spongeVersion = Integer.parseInt(version);
if (spongeVersion < 2132) {
this.logger.error(String.format("Failed to initialize StickyChunk due to outdated SpongeForge (%s). StickyChunk requires SF 2132+", spongeVersion));
return false;
}
} catch (Exception ignored) {
}
}
return true;
}
示例2: VirtualTool
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
@Inject
public VirtualTool(@ConfigDir(sharedRoot = true) Path path, Logger logger, PluginContainer container) {
this.dataDir = Sponge.getGame().getSavesDirectory().resolve(PluginData.id);
this.pluginContainer = container;
this.logger = new VTLogger(CText.get(CText.Colors.BLUE, 1, "V") + CText.get(CText.Colors.MAGENTA, 0, "T"));
this.configdirpath = path.resolve(PluginData.id);
this.backpackDir = Paths.get(this.getConfigPath().toString(), "backpacks");
this.configfullpath = Paths.get(this.getConfigPath().toString(), "config.json");
this.settings = new Settings();
}
示例3: SpongeStats
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
public SpongeStats(MCMarketApi marketApi, PluginContainer plugin) {
super(marketApi);
Sponge.getEventManager().registerListeners(plugin, this);
Timer timer = new Timer(true);
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (!Sponge.getPluginManager().isLoaded(plugin.getId())) {
timer.cancel();
return;
}
Sponge.getScheduler().createTaskBuilder().execute(() -> runEventsSender()).submit(plugin);
}
}, 1000 * 10, 1000 * 60);
}
示例4: testMapping
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
private CommandMapping testMapping(String alias, CommandMapping mapping)
{
if (!commandManager.get(alias).get().equals(mapping))
{
PluginContainer pluginContainer = commandManager.get(alias).flatMap(commandManager::getOwner).get();
this.plugin.getLogger().warn("The command '" + alias + "' is not actually registered because " +
"it conflicts with the command '" + pluginContainer.getId() + ":" + alias + "'.");
this.plugin.getLogger().warn("Because of the low priority this command could only be used with " +
"a prefix such as '" + VirtualChestPlugin.PLUGIN_ID + ":" + alias + "'.");
this.plugin.getLogger().warn("Please configure the part of command aliases in " +
"'config/sponge/global.conf' to enable it manually:");
this.plugin.getLogger().warn("commands {");
this.plugin.getLogger().warn(" aliases {");
this.plugin.getLogger().warn(" " + alias + "=" + VirtualChestPlugin.PLUGIN_ID);
this.plugin.getLogger().warn(" }");
this.plugin.getLogger().warn("}");
this.plugin.getLogger().warn("For more information about command priorities, please refer to:");
this.plugin.getLogger().warn("https://docs.spongepowered.org/" +
"stable/en/server/getting-started/configuration/sponge-conf.html");
}
return mapping;
}
示例5: getDump
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
@Override
public JsonObject getDump() {
JsonObject platformSpecific = new JsonObject();
List<PluginInfo> plugins = new ArrayList<>();
for (PluginContainer p : game.getPluginManager().getPlugins()) {
plugins.add(new PluginInfo(
true,
p.getName(),
p.getVersion().orElse("Unknown Version"),
p.getInstance().isPresent() ? p.getInstance().get().getClass().getCanonicalName() : "Unknown",
p.getAuthors()
));
}
platformSpecific.add("plugins", GsonUtil.getGson().toJsonTree(plugins));
return platformSpecific;
}
示例6: parse
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
public static TextureId parse(String textureId) {
Identifier identifier = Identifier.parseOrDefaultNamespace(textureId, "minecraft");
PluginContainer pluginContainer;
if(identifier.getNamespace().equals("minecraft")) {
pluginContainer = null;
} else {
pluginContainer = Sponge.getPluginManager().getPlugin(identifier.getNamespace())
.orElseThrow(() -> new IllegalArgumentException("Could not access plugin with id '"
+ identifier.getNamespace() + "', is it loaded?"));
}
int lastFileNameSeparator = identifier.getValue().lastIndexOf('/');
String directory;
String fileName;
if(lastFileNameSeparator == -1) {
directory = null;
fileName = identifier.getValue();
} else {
directory = identifier.getValue().substring(0, lastFileNameSeparator);
fileName = identifier.getValue().substring(lastFileNameSeparator + 1);
}
return new TextureId(pluginContainer, directory, fileName);
}
示例7: register
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
public void register(ItemType itemType, PluginContainer pluginContainer, Iterable<String> models, String modelDirectoryName) {
models.forEach(model -> {
BiMap<Integer, Identifier> durabilityToModelId = typeToDurabilityToModelId.computeIfAbsent(itemType, k -> HashBiMap.create());
Identifier modelId = new Identifier(pluginContainer.getId(), model);
// Is the model already registered? If so, skip.
Integer registeredDurability = durabilityToModelId.inverse().get(modelId);
if(registeredDurability == null) {
registeredDurability = getAvailableDurability(itemType);
}
DurabilityIdentifier durabilityId = new DurabilityIdentifier(itemType, registeredDurability);
durabilityIdToDirectoryName.put(durabilityId, modelDirectoryName);
durabilityIdToModelId.put(durabilityId, modelId);
durabilityToModelId.put(registeredDurability, modelId);
});
}
示例8: createItem
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
@Override
public CustomTool createItem(Cause cause) {
PluginContainer plugin = getPluginContainer();
ItemStack itemStack = itemStackSnapshot.createStack();
ItemType itemType = itemStack.getItem();
int durability = DurabilityRegistry.getInstance().getDurability(itemType, plugin, getDefaultModel())
.orElseThrow(() -> new IllegalStateException("Could not get the durability for the default models."));
itemStack.offer(Keys.UNBREAKABLE, true);
itemStack.offer(Keys.ITEM_DURABILITY, durability);
itemStack.offer(Keys.HIDE_UNBREAKABLE, true);
itemStack.offer(Keys.HIDE_ATTRIBUTES, true);
itemStack.offer(createDefaultCustomFeatureData());
CustomTool tool = new CustomTool(itemStack, this);
CustomItemCreationEvent event = new CustomItemCreationEvent(tool, cause);
Sponge.getEventManager().post(event);
return tool;
}
示例9: SimpleCustomBlockDefinition
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
private SimpleCustomBlockDefinition(PluginContainer pluginContainer, String typeId,
@NonNull CorrectToolPredicate correctToolPredicate, double hardness,
@NonNull BlockState effectState, @NonNull DropProvider dropProvider,
String defaultModel, Iterable<String> additionalModels,
Iterable<String> additionalAssets, boolean rotateHorizontally,
boolean generateDamageIndicatorModels, Consumer<SimpleCustomBlock> onUpdate) {
super(pluginContainer, typeId, defaultModel, additionalModels, effectState, rotateHorizontally, generateDamageIndicatorModels, onUpdate);
this.assets = ImmutableSet.<String>builder()
.addAll(getModels().stream()
.map(SimpleCustomBlockDefinition::getModelPath)
.collect(Collectors.toSet()))
.addAll(Util.removeNull(additionalAssets)
.collect(Collectors.toSet()))
.build();
this.correctToolPredicate = correctToolPredicate;
this.hardness = hardness;
this.dropProvider = dropProvider;
}
示例10: generateResourcePackFiles
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
@Override
public void generateResourcePackFiles(Path resourcePackDirectory) {
super.generateResourcePackFiles(resourcePackDirectory);
if(isGenerateDamageIndicatorModels()) {
PluginContainer pluginContainer = getPluginContainer();
getModels().forEach(model -> {
String assetPath = SimpleCustomBlockDefinition.getModelPath(model);
String filePath = CustomFeatureRegistry.getFilePath(pluginContainer, assetPath);
Path inputFile = resourcePackDirectory.resolve(filePath);
for(int stage = 0; stage < 10; stage++) {
String outputFileName = SimpleCustomBlockRegistry.getDamageIndicatorModel(model, stage) + ".json";
Path outputFile = inputFile.resolveSibling(outputFileName);
try {
createDamageIndicatorFile(inputFile, outputFile, stage);
} catch (IOException e) {
CustomItemLibrary.getInstance().getLogger()
.error("Could not create damage indicator file '" + outputFile + "'.", e);
}
}
});
}
}
示例11: gameInit
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
@Listener
public void gameInit(GamePreInitializationEvent event){
logger = LoggerFactory.getLogger(pC.getName());
instance = this;
huskyAPI = new HuskyAPI();
forceStopIDs.clear();
for(PluginContainer pc: Sponge.getPluginManager().getPlugins()){
if(pc.getId().equalsIgnoreCase("inventorytweaks")||pc.getId().equalsIgnoreCase("inventorysorter")||pc.getId().equalsIgnoreCase("mousetweaks")){
forceStopIDs.add(pc.getName() + "(" + pc.getId() + ")");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error(pc.getName() + " is loaded! This plugin or mod is on a blacklist for HuskyCrates, and as a result, HuskyCrates is not starting. ");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
logger.error("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
forceStop = true;
}
}
if(forceStop)
return;
CommentedConfigurationNode conf = null;
try {
conf = crateConfig.load();
if(!conf.getNode("lang").isVirtual()) {
langData = new LangData(conf.getNode("lang"));
}else
logger.info("Using default lang settings.");
} catch (Exception e) {
crateUtilities.exceptionHandler(e);
}
//logger.info("Let's not init VCrates here anymore. ://)");
}
示例12: initNucleusMessageTokenService
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
private boolean initNucleusMessageTokenService(Optional<PluginContainer> pluginContainerOpt) {
Optional<ProviderRegistration<NucleusMessageTokenService>> nucleusMessageTokenServiceOpt = Sponge.getServiceManager().getRegistration(NucleusMessageTokenService.class);
if (pluginContainerOpt.isPresent() && nucleusMessageTokenServiceOpt.isPresent()) {
nucleusMessageTokenService = nucleusMessageTokenServiceOpt.get().getProvider();
try {
nucleusMessageTokenService.register(pluginContainerOpt.get(), new NucleusMessageTokenService.TokenParser() {
@Nonnull
@Override
public Optional<Text> parse(String tokenInput, CommandSource source, Map<String, Object> variables) {
if (!"clantag".equals(tokenInput)) {
return Optional.empty();
}
if (!(source instanceof Player)) {
return Optional.empty();
}
Player player = (Player) source;
ClanPlayerImpl clanPlayer = ClansImpl.getInstance().getClanPlayer(player.getUniqueId());
if (clanPlayer == null || clanPlayer.getClan() == null) {
return Optional.empty();
}
return Optional.of(clanPlayer.getClan().getTagColored());
}
});
} catch (PluginAlreadyRegisteredException e) {
MCClans.getPlugin().getLogger().error("Could not register to Nucleus message token service!", e, false);
return false;
}
return true;
} else {
return false;
}
}
示例13: IPLog
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
@Inject
public IPLog(Logger logger, @ConfigDir(sharedRoot = false) Path path, PluginContainer pluginContainer) {
plugin = this;
this.logger = logger;
this.parentPath = path;
this.pluginContainer = pluginContainer;
}
示例14: update
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
public void update(int version, PluginContainer plugin, Path defaultConfig) throws IOException {
updateconfig.plugin = plugin;
updateconfig.defaultConfig = defaultConfig;
version9();
// Not supported
/*
* if (version <= 5) { version6(loader); version7(loader); version8(loader); }
* if(version<=6){ version7(loader); version8(loader); } if(version<=7){
* version8(loader); }
*/
}
示例15: reloadConfigs
import org.spongepowered.api.plugin.PluginContainer; //导入依赖的package包/类
public void reloadConfigs(Response<Boolean> response) {
mainConfig = new MainConfig(baseDirectory.toFile());
signsConfig = new SignsConfig(baseDirectory.toFile());
signsLayoutConfig = new SignsLayoutConfig(baseDirectory.toFile());
i18n.updateLocale(mainConfig.getLang());
Sponge.getEventManager().unregisterPluginListeners(this);
for (Task task : Sponge.getScheduler().getScheduledTasks(this)) {
task.cancel();
}
setKey(mainConfig.getApiKey(), false, result -> {
if (mainConfig.isUseSigns()) {
if (signsTask == null) {
signsTask = new SignsTask(this);
}
Sponge.getScheduler().createTaskBuilder().delayTicks(20 * 10).intervalTicks(mainConfig.getCheckInterval() > 0 ? 20 * 60 * mainConfig.getCheckInterval() : 20 * 60).execute(signsTask).submit(this);
Sponge.getEventManager().registerListeners(this, new SignsListener(this));
}
if (purchasesTask == null) {
purchasesTask = new PurchasesTask(this);
}
Sponge.getScheduler().createTaskBuilder().async().delayTicks(20 * 10).intervalTicks(mainConfig.getCheckInterval() > 0 ? 20 * 60 * mainConfig.getCheckInterval() : 20 * 60).execute(purchasesTask).submit(this);
if (result && mainConfig.isStatistics()) {
Optional<PluginContainer> optional = Sponge.getPluginManager().fromInstance(this);
optional.ifPresent(pluginContainer -> new SpongeStats(marketApi, pluginContainer));
}
if (response != null) {
response.done(result);
}
});
}