本文整理汇总了Java中org.bukkit.plugin.PluginLoader类的典型用法代码示例。如果您正苦于以下问题:Java PluginLoader类的具体用法?Java PluginLoader怎么用?Java PluginLoader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
PluginLoader类属于org.bukkit.plugin包,在下文中一共展示了PluginLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initialize
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
/**
* Initializes this plugin with the given variables.
*
* This method should never be called manually.
*
* @param loader PluginLoader that is responsible for this plugin
* @param server Server instance that is running this plugin
* @param description PluginDescriptionFile containing metadata on this plugin
* @param dataFolder Folder containing the plugin's data
* @param file File containing this plugin
* @param classLoader ClassLoader which holds this plugin
*/
protected final void initialize(PluginLoader loader, Server server,
PluginDescriptionFile description, File dataFolder, File file ) { //,
//ClassLoader classLoader) {
if (!initialized) {
this.initialized = true;
this.loader = loader;
this.server = server;
this.file = file;
this.description = description;
this.dataFolder = dataFolder;
//this.classLoader = classLoader;
this.config = YamlConfiguration.loadConfiguration(new File(dataFolder, "config.yml"));
}
}
示例2: test_default_modules
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Test
public void test_default_modules() throws Exception
{
PluginLoader loader = mock(PluginLoader.class);
Server server = mock(Server.class);
PluginDescriptionFile pdf = mock(PluginDescriptionFile.class);
File file1 = new File("target" + File.separator + "testdatafolder");
PluginLogger logger = mock(PluginLogger.class);
when(server.getLogger()).thenReturn(logger);
TestPluginDefaultModules plugin = new TestPluginDefaultModules(loader, server, pdf, file1, file1);
assertThat(plugin.injectedPlugin).isNull();
plugin.onLoad();
assertThat(plugin.injectedPlugin).isNull();
plugin.onEnable();
assertThat(plugin.injectedPlugin).isSameAs(plugin);
}
示例3: test_extra_modules
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Test
public void test_extra_modules() throws Exception
{
PluginLoader loader = mock(PluginLoader.class);
Server server = mock(Server.class);
PluginDescriptionFile pdf = mock(PluginDescriptionFile.class);
File file1 = new File("target" + File.separator + "testdatafolder");
PluginLogger logger = mock(PluginLogger.class);
when(server.getLogger()).thenReturn(logger);
TestPluginExtraModules plugin = new TestPluginExtraModules(loader, server, pdf, file1, file1);
assertThat(plugin.i).isNull();
plugin.onLoad();
assertThat(plugin.i).isNull();
plugin.onEnable();
assertThat(plugin.i).isInstanceOf(TestPluginExtraModules.TestConcrete.class);
}
示例4: test_override_modules
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Test
public void test_override_modules() throws Exception
{
PluginLoader loader = mock(PluginLoader.class);
Server server = mock(Server.class);
PluginDescriptionFile pdf = mock(PluginDescriptionFile.class);
File file1 = new File("target" + File.separator + "testdatafolder");
PluginLogger logger = mock(PluginLogger.class);
when(server.getLogger()).thenReturn(logger);
TestPluginReplaceModules plugin = new TestPluginReplaceModules(loader, server, pdf, file1, file1);
assertThat(plugin.logger).isNull();
plugin.onLoad();
assertThat(plugin.logger).isNull();
plugin.onEnable();
assertThat(plugin.logger).isInstanceOf(TestPluginReplaceModules.TestPluginLogger.class);
}
示例5: JavaPlugin
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
/**
* @deprecated This method is intended for unit testing purposes when the
* other {@linkplain #JavaPlugin(JavaPluginLoader,
* PluginDescriptionFile, File, File) constructor} cannot be used.
* <p>
* Its existence may be temporary.
*/
@Deprecated
protected JavaPlugin(final PluginLoader loader, final Server server, final PluginDescriptionFile description, final File dataFolder, final File file) {
final ClassLoader classLoader = this.getClass().getClassLoader();
if (classLoader instanceof PluginClassLoader) {
throw new IllegalStateException("Cannot use initialization constructor at runtime");
}
init(loader, server, description, dataFolder, file, classLoader);
}
示例6: initialize
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
/**
* @deprecated This method is legacy and will be removed - it must be
* replaced by the specially provided constructor(s).
*/
@Deprecated
protected final void initialize(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
if (server.getWarningState() == WarningState.OFF) {
return;
}
getLogger().log(Level.WARNING, getClass().getName() + " is already initialized", server.getWarningState() == WarningState.DEFAULT ? null : new AuthorNagException("Explicit initialization"));
}
示例7: init
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
this.loader = loader;
this.server = server;
this.file = file;
this.description = description;
this.dataFolder = dataFolder;
this.classLoader = classLoader;
this.configFile = new File(dataFolder, "config.yml");
this.logger = new PluginLogger(this);
if (description.isDatabaseEnabled()) {
ServerConfig db = new ServerConfig();
db.setDefaultServer(false);
db.setRegister(false);
db.setClasses(getDatabaseClasses());
db.setName(description.getName());
server.configureDbConfig(db);
DataSourceConfig ds = db.getDataSourceConfig();
ds.setUrl(replaceDatabaseString(ds.getUrl()));
dataFolder.mkdirs();
ClassLoader previous = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
ebean = EbeanServerFactory.create(db);
Thread.currentThread().setContextClassLoader(previous);
}
}
示例8: test_no_modules
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Test
public void test_no_modules() throws Exception
{
PluginLoader loader = mock(PluginLoader.class);
Server server = mock(Server.class);
PluginDescriptionFile pdf = mock(PluginDescriptionFile.class);
File file1 = new File("target" + File.separator + "testdatafolder");
PluginLogger logger = mock(PluginLogger.class);
when(server.getLogger()).thenReturn(logger);
TestPluginNoModules plugin = new TestPluginNoModules(loader, server, pdf, file1, file1);
plugin.onLoad();
plugin.onEnable();
}
示例9: initialize
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
/**
* Initializes this plugin with the given variables.
* <p>
* This method should never be called manually.
*
* @param loader PluginLoader that is responsible for this plugin
* @param server Server instance that is running this plugin
* @param description PluginDescriptionFile containing metadata on this plugin
* @param dataFolder Folder containing the plugin's data
* @param file File containing this plugin
* @param classLoader ClassLoader which holds this plugin
*/
protected final void initialize(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
if (!initialized) {
this.initialized = true;
this.loader = loader;
this.server = server;
this.file = file;
this.description = description;
this.dataFolder = dataFolder;
this.classLoader = classLoader;
this.configFile = new File(dataFolder, "config.yml");
this.logger = new PluginLogger(this);
if (description.isDatabaseEnabled()) {
ServerConfig db = new ServerConfig();
db.setDefaultServer(false);
db.setRegister(false);
db.setClasses(getDatabaseClasses());
db.setName(description.getName());
server.configureDbConfig(db);
DataSourceConfig ds = db.getDataSourceConfig();
ds.setUrl(replaceDatabaseString(ds.getUrl()));
dataFolder.mkdirs();
ClassLoader previous = Thread.currentThread().getContextClassLoader();
Thread.currentThread().setContextClassLoader(classLoader);
ebean = EbeanServerFactory.create(db);
Thread.currentThread().setContextClassLoader(previous);
}
}
}
示例10: registerInterface
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Override
public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException
{
// TODO Auto-generated method stub
throw new UnimplementedOperationException();
}
示例11: registerInterface
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Override
public void registerInterface(Class<? extends PluginLoader> loader)
throws IllegalArgumentException {
delegate.registerInterface(loader);
}
示例12: before
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@SuppressWarnings({"resource", "deprecation"})
@Before
public void before() throws Exception {
final File dataDir = new File("target/classes/");
final File jar = new File("target/", "skript.jar");
assumeTrue(jar.exists());
final Logger l = Logger.getLogger(getClass().getCanonicalName());
l.setParent(SkriptLogger.LOGGER);
l.setLevel(Level.WARNING);
final Server s = createMock(Server.class);
s.getLogger();
expectLastCall().andReturn(l).anyTimes();
s.isPrimaryThread();
expectLastCall().andReturn(true).anyTimes();
s.getName();
expectLastCall().andReturn("Whatever").anyTimes();
s.getVersion();
expectLastCall().andReturn("2.0").anyTimes();
s.getBukkitVersion();
expectLastCall().andReturn("2.0").anyTimes();
replay(s);
Bukkit.setServer(s);
final Skript skript = (Skript) ObjenesisHelper.newInstance(Skript.class); // bypass the class loader check
final Field instance = Skript.class.getDeclaredField("instance");
instance.setAccessible(true);
instance.set(null, skript);
final PluginDescriptionFile pdf = new PluginDescriptionFile(new FileInputStream(new File(dataDir, "plugin.yml")));
// final void init(PluginLoader loader, Server server, PluginDescriptionFile description, File dataFolder, File file, ClassLoader classLoader) {
final Method init = JavaPlugin.class.getDeclaredMethod("init", PluginLoader.class, Server.class, PluginDescriptionFile.class, File.class, File.class, ClassLoader.class);
init.setAccessible(true);
init.invoke(skript, new JavaPluginLoader(s), s, pdf, dataDir, jar, getClass().getClassLoader());
Skript.getAddonInstance().loadClasses("ch.njol.skript", "entity");
new JavaClasses();
new BukkitClasses();
new BukkitEventValues();
new SkriptClasses();
final Field r = Skript.class.getDeclaredField("acceptRegistrations");
r.setAccessible(true);
r.set(null, false);
Classes.onRegistrationsStop();
}
示例13: registerInterface
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Override
public void registerInterface(Class<? extends PluginLoader> loader) throws IllegalArgumentException {
pm.registerInterface(loader);
}
示例14: setLoader
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
void setLoader(PluginLoader loader) {
this.loader = loader;
}
示例15: getPluginLoader
import org.bukkit.plugin.PluginLoader; //导入依赖的package包/类
@Override
public PluginLoader getPluginLoader() {
return loader;
}