本文整理汇总了Java中net.canarymod.plugin.Plugin类的典型用法代码示例。如果您正苦于以下问题:Java Plugin类的具体用法?Java Plugin怎么用?Java Plugin使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Plugin类属于net.canarymod.plugin包,在下文中一共展示了Plugin类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: Metrics
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
public Metrics(final Plugin plugin) throws IOException {
if (plugin == null) {
throw new IllegalArgumentException("Plugin cannot be null");
}
this.plugin = plugin;
// load the config
configuration = plugin.getModuleConfig("PluginMetrics");
// Do we need to create the file?
if (!configuration.containsKey("guid")) {
// add some defaults
configuration.addHeaderLines("http://mcstats.org");
configuration.getBoolean("opt-out", false);
configuration.getString("guid", UUID.randomUUID().toString());
configuration.getBoolean("debug", false);
configuration.save();
}
// Load the guid then
guid = configuration.getString("guid");
debug = configuration.getBoolean("debug", false);
}
示例2: onPopulateEnvironment
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
@Inject(method = "populateEnvironment", at = @At("RETURN"))
private void onPopulateEnvironment(CallbackInfo ci) {
if (Canary.pluginManager() != null) {
this.theReportCategory.addCrashSectionCallable("Canary Plugins", () -> {
final StringBuilder result = new StringBuilder(64);
for (final Plugin plugin : Canary.pluginManager().getPlugins()) {
result.append("\n\t\t")
.append(plugin.getName())
.append(" v ")
.append(plugin.getVersion())
.append(" (")
.append(plugin.getPath())
.append(")");
}
return result.toString();
});
}
}
示例3: enable
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
@Override
public boolean enable() {
if (Bukkit.getServer() == null) {
server = new CanaryServer(Canary.getServer(), getLogman());
}
// Enable Listener
Canary.hooks().registerListener(new CanaryPlayerListener(server), this);
Canary.hooks().registerListener(new CanaryBlockListener(server), this);
Canary.hooks().registerListener(new CanaryWorldListener(server), this);
Canary.hooks().registerListener(new CanaryServerListener(server), this);
// Create all the directories.
Constants.createDirectories();
// Start server
server.start();
// Metrics (statistics)
try {
Metrics metrics = new Metrics(this);
Metrics.Graph plugins = metrics.createGraph("Plugins");
for (org.bukkit.plugin.Plugin plugin : server.getPluginManager().getPlugins()) {
plugins.addPlotter(new Metrics.Plotter(plugin.getName()) {
@Override
public int getValue() {
return 1;
}
});
}
metrics.start();
} catch (IOException e) {
getLogman().warn("Failed to send statistics to Metrics", e);
}
return true;
}
示例4: exportResource
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
static public boolean exportResource(final Plugin plugin, final String resourceName,
final File targetDir) throws IOException {
boolean success = false;
final File targetFile = new File(targetDir, resourceName);
if (!targetFile.exists()) {
final InputStream in = plugin.getClass().getResourceAsStream("/" + resourceName);
OutputStream out = null;
if (in != null) {
try {
if (targetDir.mkdirs()) {
if (targetFile.createNewFile()) {
int readBytes;
final byte[] buffer = new byte[1024];
out = new FileOutputStream(targetFile);
while ((readBytes = in.read(buffer)) > 0) {
out.write(buffer, 0, readBytes);
}
plugin.getLogman().info("Wrote default " + resourceName);
success = true;
}
}
} finally {
in.close();
if (out != null) {
out.close();
}
}
}
}
return success;
}
示例5: createCrashSectionMessage
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
public static String createCrashSectionMessage() {
StringBuilder result = new StringBuilder(64);
for (Plugin plugin : Canary.pluginManager().getPlugins()) {
result.append("\n\t\t").append(plugin.getName());
}
return result.toString();
}
示例6: LatchConfig
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
/**
* Constructor.
*/
public LatchConfig(Plugin plugin) {
config = Configuration.getPluginConfig(plugin);
}
示例7: CanaryServer
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
public CanaryServer(Server server, Plugin plugin) {
this.server = server;
this.plugin = plugin;
}
示例8: CanaryConfigurationStorage
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
public CanaryConfigurationStorage(Plugin plugin) {
this.plugin = plugin;
}
示例9: getInstance
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
/**
*
* @return {@link Main#plugin}
*/
public static Plugin getInstance() {
return Main.plugin;
}
示例10: CanaryCommandHandler
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
/**
* The Constructor for base-commands.
*
* @param plugin The backend that uses this library.
*/
public CanaryCommandHandler(Plugin plugin) {
super(new CanaryPluginBackend(plugin));
}
示例11: CanaryPluginBackend
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
/**
* Creates a new handle.
*
* @param handle The handle in the backend.
*/
protected CanaryPluginBackend(Plugin handle) {
super(handle);
this.scheduler = new FallbackSchedulerBackend();
}
示例12: CanaryConfigurationLoader
import net.canarymod.plugin.Plugin; //导入依赖的package包/类
/**
* Uses the default parameters for the configuration loader.
*
* @param plugin The plugin that the logger should use.
*/
public CanaryConfigurationLoader(Plugin plugin) {
super(new CanaryConfigurationStorage(plugin));
this.setLoggingInterface(new Log4jBinding(plugin.getLogman()));
}