本文整理汇总了Java中cn.nukkit.plugin.PluginBase类的典型用法代码示例。如果您正苦于以下问题:Java PluginBase类的具体用法?Java PluginBase怎么用?Java PluginBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PluginBase类属于cn.nukkit.plugin包,在下文中一共展示了PluginBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SignsConfig
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public SignsConfig(PluginBase plugin) {
super(plugin, "signs");
for (String key : config.getKeys(false)) {
if (Utils.isInt(key)) {
Set<DonorSign> signs = new HashSet<>();
for (Location loc : stringsToLocArray(config.getStringList(key))) {
if (loc != null) {
BlockEntity block = loc.getLevel().getBlockEntity(loc);
if (block != null && block instanceof BlockEntitySign) {
signs.add(new DonorSign(Utils.getInt(key), block.getBlock()));
}
}
}
donorSigns.put(Utils.getInt(key), signs);
}
}
}
示例2: ConfigFile
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public ConfigFile(PluginBase plugin, String name) {
super(plugin.getDataFolder(), name + ".yml");
if (!plugin.getDataFolder().exists()) {
plugin.getDataFolder().mkdirs();
}
if (!exists()) {
try {
if (plugin.getResource(name + ".yml") != null) {
plugin.saveResource(name + ".yml", true);
} else {
createNewFile();
}
} catch (IOException e) {
e.printStackTrace();
}
}
config = new Config(this, Config.YAML);
}
示例3: onLoad
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public void onLoad(PluginBase plugin) {
File pluginFolder = new File(plugin.getDataFolder(), "bukkitPlugins");
if (!pluginFolder.exists()) {
pluginFolder.mkdirs();
}
Logger logger = new PokkitLogger(plugin.getLogger());
LogManager.getLogManager().addLogger(logger);
loadVersionNumbers(logger);
CraftServer server = new CraftServer(plugin.getServer(), logger, pluginFolder);
Bukkit.setServer(server);
// Load the services
services.forEach(service -> service.onLoad(plugin));
}
示例4: MainConfig
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public MainConfig(PluginBase plugin) {
super(plugin, "nukkitConfig");
apiKey = config.getString("APIKey", "");
checkInterval = config.getInt("CheckInterval", 1);
useSigns = config.getBoolean("UseSigns", true);
dateFormat = config.getString("DateFormat", "yyyy-MM-dd");
statistics = config.getBoolean("Statistics", true);
lang = config.getString("Lang", "en");
debug = config.getBoolean("Debug", false);
}
示例5: SkyBlockAPI
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public SkyBlockAPI(PluginBase plugin) {
this.executor = plugin;
SkyBlockAPI.list.add(plugin);
if (plugin instanceof ASkyBlock) {
hasPermissionToAccessAll = true;
}
}
示例6: init
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public static void init(PluginBase plg) {
plugin = plg;
//Perm command
addNewCommand(PermHelp.class);
addNewCommand(PermReload.class);
addNewCommand(PermRefresh.class);
addNewCommand(PermCheck.class);
addNewCommand(PermExport.class);
addNewCommand(PermImport.class);
// Group command
addNewCommand(GroupInfo.class);
addNewCommand(GroupCreate.class);
addNewCommand(GroupRemove.class);
addNewCommand(GroupRemovePerm.class);
addNewCommand(GroupSetPerm.class);
addNewCommand(GroupSetGroup.class);
addNewCommand(GroupAddGroup.class);
addNewCommand(GroupRemoveGroup.class);
addNewCommand(GroupSetPrefix.class);
addNewCommand(GroupSetSuffix.class);
//User command
addNewCommand(UserInfo.class);
addNewCommand(UserRemove.class);
addNewCommand(UserAddGroup.class);
addNewCommand(UserRemoveGroup.class);
addNewCommand(UserRemovePerm.class);
addNewCommand(UserSetGroup.class);
addNewCommand(UserSetPerm.class);
addNewCommand(UserSetPrefix.class);
addNewCommand(UserSetSuffix.class);
}
示例7: DefaultManager
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public DefaultManager(PluginBase plugin){
this.plugin = plugin;
attachments = new HashMap<>();
this.provider = new YamlProvider(plugin);
//this.plugin.getServer().getScheduler().scheduleDelayedRepeatingTask(task = new SendTipTask(plugin), 10, 10);
}
示例8: onDisable
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
@Override
public void onDisable() {
try {
pokkit.getClass().getMethod("onDisable", PluginBase.class).invoke(pokkit, this);
} catch (Throwable t) {
this.getLogger().error("Error disabling plugin", t);
}
}
示例9: onEnable
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
@Override
public void onEnable() {
try {
pokkit.getClass().getMethod("onEnable", PluginBase.class).invoke(pokkit, this);
} catch (Throwable t) {
this.getLogger().error("Error disabling plugin", t);
}
}
示例10: onLoad
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
@Override
public void onLoad() {
try {
PluginClassLoader nukkitLoader = (PluginClassLoader) getClass().getClassLoader();
@SuppressWarnings("resource")
UrlFirstClassLoader classLoader = new UrlFirstClassLoader(nukkitLoader.getURLs(), nukkitLoader);
pokkit = classLoader.loadClass("nl.rutgerkok.pokkit.Pokkit").newInstance();
pokkit.getClass().getMethod("onLoad", PluginBase.class).invoke(pokkit, this);
} catch (Throwable t) {
this.getLogger().error("Error loading plugin", t);
}
}
示例11: onDisable
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
@Override
public void onDisable(PluginBase pokkit) {
YamlConfiguration scoreboardConfig = new YamlConfiguration();
persister.saveScoreboard(scoreboardConfig, Bukkit.getScoreboardManager().getMainScoreboard());
scoreboardConfig.options().header("This is the scoreboard data of the main scoreboard.");
try {
scoreboardConfig.save(getScoreboardFile(pokkit));
} catch (IOException e) {
Bukkit.getLogger().log(Level.SEVERE, "Error saving " + getScoreboardFile(pokkit).getName(), e);
}
}
示例12: SignsLayoutConfig
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public SignsLayoutConfig(PluginBase plugin) {
super(plugin, "signsLayout");
activeLayout = Colors.colorList(config.getStringList("Active"));
waitingLayout = Colors.colorList(config.getStringList("Waiting"));
}
示例13: PluginCertificateTask
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public PluginCertificateTask(PluginBase plugin) {
this.plugin = plugin;
}
示例14: list
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public List<String> list() throws IOException {
List<String> result = new ArrayList<>();
// Check if the locale folder exists
File localeDir = new File(plugin.getDataFolder(), FOLDERPATH);
if (localeDir.exists()) {
FilenameFilter ymlFilter = (File dir, String name) -> {
String lowercaseName = name.toLowerCase();
return lowercaseName.endsWith(".yml");
};
for (String fileName : localeDir.list(ymlFilter)) {
result.add(fileName.replace(".yml", ""));
}
if (!result.isEmpty()) {
return result;
}
}
// Else look in the JAR
File jarfile = null;
/**
* Get the jar file from the plugin.
*/
try {
Method method = PluginBase.class.getDeclaredMethod("getFile");
method.setAccessible(true);
jarfile = (File) method.invoke(this.plugin);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
throw new IOException(e);
}
/**
* Loop through all the entries.
*/
try (JarFile jar = new JarFile(jarfile)) {
/**
* Loop through all the entries.
*/
Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement();
String path = entry.getName();
/**
* Not in the folder.
*/
if (!path.startsWith(FOLDERPATH)) {
continue;
}
if (entry.getName().endsWith(".yml")) {
result.add((entry.getName().replace(".yml", "")).replace("locale/", ""));
}
}
}
return result;
}
示例15: getPlugin
import cn.nukkit.plugin.PluginBase; //导入依赖的package包/类
public static PluginBase getPlugin() {
return plugin;
}