Omels API (Omels API)
Omels API 是一款功能强大的工具,适用于每个开发者。它包含了大量简化的酷炫功能。
Stats!!!
关于该API的统计信息可以在这里查看:
public MyEvent(Plugin pl) {
super(pl);
\/\/ TODO 自动生成的构造函数存根
}
@Override
@EventHandler \/\/ 必须手动添加
public void callEvent(NameOfEvent e) {
\/\/ TODO 自动生成的方法存根
}
然后在你的onEnable代码中注册它:
public void onEnable() {
new MyEvent(this);
}
Method 2
方法2:
public void onEnable() {
new QuickEvent(this) {
@Override
@EventHandler \/\/ 必须手动添加
public void callEvent(NameOfEvent e) {
}
};
}
Entity stuff
实体相关:
CustomEntity ce = new CustomEntity(EntityType.COW, Location);
ce.setAge(EntityAge.ADULT);
ce.setName("Cool cow");
File Builder
文件构建器:
FileBuilder f = new FileBuilder("plugins\/\/Your_Folder\/\/", "Your_File_Name.yml");
f.setValue("ValuePath", 100);
f.save();
Fun stuff
有趣的功能:
Pets
宠物:
Pet pet = new Pet(EntityType.COW, PLAYER);
pet.setBaby();
pet.setAgeLock(true);
pet.setName("Cool cow");
Airdrops
空投:
Airdrop drop = new Airdrop(WORLD, this);
drop.setLocation(MAX_RADIUS, MIN_RADIUS);
drop.setContents(new ItemStack[]{new ItemStack(Material.APPLE)});
drop.spawn();
Bukkit.broadcastMessage("A new Airdrop appeared!");
Bukkit.broadcastMessage("Location: X" + drop.getX() + " Y: " + drop.getY()+ " Z: " + drop.getZ());
Autobroadcaster
自动广播:
new AutoBroacaster() {
@Override
public int period() {
\/\/ 每几秒
return 60 * 5;
}
@Override
public List messages() {
\/\/ TODO 自动生成的方法存根
return Arrays.asList("This is message number 1", "This is message number 2");
}
}.run();
Warps
传送点:
Warp warp = new Warp("WARP_NAME");
warp.setLocation(LOCATION);
Holograms
全息:
Hologram holo = new Hologram("HOLOGRAM_NAME");
holo.setLocation(LOCATION);
holo.addLine("This is a HOLOGRAM!");
holo.addLine("§aCool this is green!");
holo.update();
Inventorys
库存:
Inv inv = new Inv(InventoryType.HOPPER); inv.addItem(new ItemStack(Material.BREAD)); inv.setCancelOnClick(true); \/\/ 无法从库存中偷取物品! PLAYER.openInventory(inv.getInventory()); \/\/ 获取当前观看该库存的玩家列表
Item Builder
物品构建器:
ItemBuilder item = new ItemBuilder(Material.BREAD, 1);
item.setDisplayname("CoOL BREAD");
item.setLore(Arrays.asList("Line 1", "Line 2", "Line 3"));
item.addEnchantment(Enchantment.DAMAGE_ALL, 10, false); \/\/ false = 允许不安全附魔
ItemStack i = item.build(); \/\/ 或者你可以这样使用
ItemStack it = new ItemBuilder(Material.BREAD, 1).setDisplayname("CoOL BREAD").setLore(Arrays.asList("Line 1", "Line 2", "Line 3")).addEnchantment(Enchantment.DAMAGE_ALL, 10, false).build(); \/\/ 现在更简洁了
MySQL
MySQL:
首先,在你的主类中你需要一个静态的数据库:
static Database database;
现在初始化数据库:
public void onEnable() {
database = new MySQL(hostname, port, database, username, password);
}
现在你可以轻松地访问你的MySQL数据库:
try {
database.updateSQL("MySQL COMMAND");
} catch (ClassNotFoundException e) {
\/\/ TODO 自动生成的 catch 块
e.printStackTrace();
} catch (SQLException e) {
\/\/ TODO 自动生成的 catch 块
e.printStackTrace();
}
或者如果你需要一个ResultSet,可以这样简单地使用:
ResultSet query =database.querySQL("MySQL COMMAND");
Packets
不再支持
Particles
粒子:
这是一个小的粒子API
Single Effect
单一效果:
SingleEffect effect = new SingleEffect(PLUGIN); effect.setTicks(10); \/\/ 在几个游戏刻内 effect.setDelay(20); \/\/ 等待显示粒子之前的延迟 effect.setEffect(Effect.FLAME); effect.setPeriod(10); \/\/ 这意味着粒子将显示10次!默认值为-1 effect.attachToEntity(ENTITY); \/\/ 这将将效果附加到实体上 effect.setLocation(LOCATION); \/\/ 这设置了效果的位置 effect.start(); \/\/ 这启动了效果 effect.cancel(); \/\/ 这取消了效果
Line Effect
线性效果:
LineEffect effect = new LineEffect(PLUGIN); effect.setEffect(Effect.FLAME); effect.setStartLocation(LOCATION); \/\/ 设置线的起始位置 effect.setEndLocation(LOCATION); \/\/ 设置线的结束位置 effect.setDisplayRadius(30); \/\/ 将显示多少个方块 effect.start();
Scheduler
调度器:
new Scheduler() {
@Override
public void runTask() {
\/\/ 执行任务
}
}.start(initialDelay, period, TIMEUNIT);
收录



