- 欢迎来到Minecraft插件百科!
- 对百科编辑一脸懵逼?帮助:快速入门带您快速熟悉百科编辑!
- 因近日遭受攻击,百科现已限制编辑,有意编辑请加入插件百科企鹅群:223812289
SpaciousLib:修订间差异
跳转到导航
跳转到搜索
Qsefthuopq(留言 | 贡献) (创建页面,内容为“{{Bukkit Plugin Infobox |插件名=SpaciousLib |图标= |版本= |前置插件= |兼容服务端版本=1.8-1.13 |作者= AnhCraft |網址= [https://www.spigotmc.or...”) |
Qsefthuopq(留言 | 贡献) 无编辑摘要 |
||
第14行: | 第14行: | ||
SpaciousLib提供一些可以节约你抠代码的时间的功能。并且这些功能兼容多版本 | SpaciousLib提供一些可以节约你抠代码的时间的功能。并且这些功能兼容多版本 | ||
={{mCColor|&1|特点}}= | ={{mCColor|&1|特点}}= | ||
==Annotations== | |||
- Packet handler: | * - Packet handler: 简单易懂地修改packets | ||
@PacketHandler | @PacketHandler | ||
public void | public void packetHandler(PacketListener.Handler handler){ | ||
if(handler.getBound() == PacketListener.BoundType.CLIENT_BOUND | |||
&& handler.getPacket().getClass().getSimpleName().equals("PacketPlayOutChat")){ | |||
handler.setCancelled(true); | |||
} | |||
} | |||
} | * - PlayerCleaner: 自动移除地图外的离线玩家 => 节约内存! | ||
- PlayerCleaner: | @PlayerCleaner | ||
private static List<UUID> players = new ArrayList<>(); | |||
@PlayerCleaner | |||
private static List<UUID> players = new | ---- | ||
={{ | |||
={{ | ==BungeeAPI== | ||
={{ | 在bc服务器上使用更高效 | ||
BungeeAPI.getPlayerList("hub", new BungeePlayerListResponse() { | |||
@Override | |||
public void result(String server, List<String> players) { | |||
System.out.println("Hub: "+String.join(", ", players)); | |||
} | |||
}); | |||
==Command builder|指令构建器== | |||
对传统的指令构建系统感到疑惑?难以检测执行指令? 那么你可以使用这个构建器.特点:支持自动完成. | |||
new CommandBuilder("this", new CommandRunnable() { | |||
@Override | |||
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) { | |||
} | |||
}).addSubCommand(new SubCommandBuilder("is a long command", "", new CommandRunnable() { | |||
@Override | |||
public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) { | |||
} | |||
})).buildExecutor(this); | |||
==effect|粒子效果== | |||
包括很多效果类型,完全可自定义 | |||
ImageEffect effect = new ImageEffect(player.getLocation(), getClass().getResourceAsStream("/test.png")); | |||
effect.setAngleX(90); | |||
effect.addNearbyViewers(10); | |||
effect.setImageSize(0.5); | |||
effect.setParticleAmount(effect.getParticleAmount() * 20); | |||
effect.spawn(); | |||
==Entity|实体== | |||
* Hologram|全息显示 | |||
Hologram hologram = new Hologram(location); | |||
hologram.addLine("first line"); | |||
hologram.addLine("second line"); | |||
hologram.addLine("third line"); | |||
hologram.buildPackets(); | |||
hologram.addViewer(player.getUniqueId()); | |||
* NPC | |||
生成一个NPC,并且可以设置皮肤和处理交互的玩家 | |||
try { | |||
Skin skin = SkinAPI.getSkin(UUID.fromString("2c8d5050-eae7-438d-88c4-c29fbcebede9")).getSkin(); | |||
GameProfile profile = new GameProfileManager("test").setSkin(skin).getGameProfile(); | |||
npc = new NPC(profile, location); | |||
npc.buildPackets(); | |||
npc.addViewer(player.getUniqueId()); | |||
} catch(Exception e) { | |||
e.printStackTrace(); | |||
} | |||
* Bossbar|血条 | |||
BossBar bossbar = new BossBar("This is a boss bar", BossBar.Color.BLUE, BossBar.Style.NOTCHED_12, 1, BossBar.Flag.DARKEN_SKY); | |||
bossbar.addViewer(player.getUniqueId()); | |||
* ArmorStand|盔甲架 | |||
ArmorStand armorStand = new ArmorStand(player.getLocation()).setArms(true).setGravity(true).setCustomName("aaa").setMarker(true).setVisible(true).setHelmet(new ItemManager("&aaaa", Material.BEACON, 1).setUnbreakable(true).getItem()); | |||
armorstand.buildPackets(); | |||
armorstand.addViewer(player.getUniqueId()); | |||
==Events|事件== | |||
* ArmorEquipEvent | |||
由玩家穿戴或卸下装备触发 | |||
@EventHandler | |||
public void equip(ArmorEquipEvent event){ | |||
if(!InventoryUtils.isNull(event.getNewArmor())){ | |||
if(event.getNewArmor().getType().equals(Material.DIAMOND_HELMET)) { | |||
event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 9999999, 1)); | |||
} | |||
return; | |||
} | |||
if(!InventoryUtils.isNull(event.getOldArmor())) { | |||
if(event.getOldArmor().getType().equals(Material.DIAMOND_HELMET)) { | |||
event.getPlayer().removePotionEffect(PotionEffectType.LEVITATION); | |||
} | |||
} | |||
} | |||
* BowArrowHitEvent | |||
@EventHandler | |||
public void bow(BowArrowHitEvent event){ | |||
event.getShooter().teleport(event.getArrow().getLocation()); | |||
} | |||
* BungeeForwardEvent | |||
由bc服务器发送的数据触发 | |||
* NPCInteractEvent: 由玩家交互NPC触发 | |||
* PlayerJumpEvent: 由玩家跳跃触发 | |||
* ServerReloadEvent: 由服务器重载触发 | |||
* ServerStopEvent: 由关服触发 | |||
==Inventory|背包== | |||
* - BookManager: 更容易地创建一本书, 修改页面, 设置书的作者等 | |||
* - ItemManager: 更容易地创建带有颜色的物品,设置无限耐久或修改其他属性 | |||
* - InventoryManager: 更快地创建背包! 用如 #addUniqueItem 一样的特殊方法,或添加可点击的物品 | |||
* - RecipeManager: 可以注册/注销配方或进行比较 | |||
* - SkullManager: 更容易地创建皮肤头! | |||
==Mojang== | |||
* - GameProfileManager: 更简单地修改游戏数据, 你可以用来修改一位玩家的皮肤 | |||
* - SkinAPI:更安全的API来获取皮肤 (它们将会被缓存) | |||
// 注意: 此代码仅在没有代理的情况下运行 | |||
new PlayerManager((Player) sender).changeSkin(SkinAPI.getSkin(MojangAPI.getUUID(value).getB()).getSkin()); | |||
==NBT== | |||
可以加载多种 NBT 标签 (配置选择, JSON, 实体, 物品), 然后修改它们并保存为另一个类型 | |||
NBTCompound nbt = NBTLoader.fromEntity(player); | |||
try { | |||
new FileManager("entity.json").delete() | |||
.initFile(nbt.toJSON().getBytes(StandardCharsets.UTF_8)); | |||
} catch(IOException e) { | |||
e.printStackTrace(); | |||
} | |||
---- | |||
* Placeholders: 有三种类型: Placeholder (经常是最新的), CachedPlaceholder (推荐方式, placeholders会被缓存并自动被更新), FixedPlaceholder (不会更新) | |||
* Protocol: 包含很多如Title标题, Action Bar, Particle粒子效果, Camera, Player List玩家列表 的 packets | |||
---- | |||
* Socket: 帮助你创建一个 socket 服务器/客户端, 能够通过字节数组发送和接收数据. | |||
ServerSocketManager server = new ServerSocketManager(16850, new ServerSocketHandler() { | |||
@Override | |||
public void request(ServerSocketClientManager client, byte[] data) { | |||
} | |||
@Override | |||
public void connect(ServerSocketClientManager client) { | |||
try { | |||
client.send("欢迎来到服务器!"); | |||
} catch(IOException e) { | |||
e.printStackTrace(); | |||
} | |||
} | |||
}); | |||
==Utils|效用== | |||
包含很多东西 你自己看吧 | |||
={{mCColor|&9|链接}}= | ={{mCColor|&9|链接}}= | ||
*Javadoc: https://anhcraft.github.io/SpaciousLib/javadoc/ | *Javadoc: https://anhcraft.github.io/SpaciousLib/javadoc/ |
2018年9月16日 (日) 06:25的最新版本
SpaciousLib
外文名 | SpaciousLib |
作者 | AnhCraft |
插件类型 | Spigot / CraftBukkit |
兼容服务端 | 1.8-1.13 |
源地址 | http://dev.bukkit.org/bukkit-plugins/SpaciousLib |
介绍
SpaciousLib提供一些可以节约你抠代码的时间的功能。并且这些功能兼容多版本
特点
Annotations
- - Packet handler: 简单易懂地修改packets
@PacketHandler public void packetHandler(PacketListener.Handler handler){ if(handler.getBound() == PacketListener.BoundType.CLIENT_BOUND && handler.getPacket().getClass().getSimpleName().equals("PacketPlayOutChat")){ handler.setCancelled(true); } }
- - PlayerCleaner: 自动移除地图外的离线玩家 => 节约内存!
@PlayerCleaner private static List<UUID> players = new ArrayList<>();
BungeeAPI
在bc服务器上使用更高效
BungeeAPI.getPlayerList("hub", new BungeePlayerListResponse() { @Override public void result(String server, List<String> players) { System.out.println("Hub: "+String.join(", ", players)); } });
Command builder|指令构建器
对传统的指令构建系统感到疑惑?难以检测执行指令? 那么你可以使用这个构建器.特点:支持自动完成. new CommandBuilder("this", new CommandRunnable() { @Override public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) { } }).addSubCommand(new SubCommandBuilder("is a long command", "", new CommandRunnable() { @Override public void run(CommandBuilder cmd, SubCommandBuilder subcmd, CommandSender sender, String[] args, String value) { } })).buildExecutor(this);
effect|粒子效果
包括很多效果类型,完全可自定义
ImageEffect effect = new ImageEffect(player.getLocation(), getClass().getResourceAsStream("/test.png")); effect.setAngleX(90); effect.addNearbyViewers(10); effect.setImageSize(0.5); effect.setParticleAmount(effect.getParticleAmount() * 20); effect.spawn();
Entity|实体
- Hologram|全息显示
Hologram hologram = new Hologram(location); hologram.addLine("first line"); hologram.addLine("second line"); hologram.addLine("third line"); hologram.buildPackets(); hologram.addViewer(player.getUniqueId());
- NPC
生成一个NPC,并且可以设置皮肤和处理交互的玩家
try { Skin skin = SkinAPI.getSkin(UUID.fromString("2c8d5050-eae7-438d-88c4-c29fbcebede9")).getSkin(); GameProfile profile = new GameProfileManager("test").setSkin(skin).getGameProfile(); npc = new NPC(profile, location); npc.buildPackets(); npc.addViewer(player.getUniqueId()); } catch(Exception e) { e.printStackTrace(); }
- Bossbar|血条
BossBar bossbar = new BossBar("This is a boss bar", BossBar.Color.BLUE, BossBar.Style.NOTCHED_12, 1, BossBar.Flag.DARKEN_SKY); bossbar.addViewer(player.getUniqueId());
- ArmorStand|盔甲架
ArmorStand armorStand = new ArmorStand(player.getLocation()).setArms(true).setGravity(true).setCustomName("aaa").setMarker(true).setVisible(true).setHelmet(new ItemManager("&aaaa", Material.BEACON, 1).setUnbreakable(true).getItem()); armorstand.buildPackets(); armorstand.addViewer(player.getUniqueId());
Events|事件
- ArmorEquipEvent
由玩家穿戴或卸下装备触发
@EventHandler public void equip(ArmorEquipEvent event){ if(!InventoryUtils.isNull(event.getNewArmor())){ if(event.getNewArmor().getType().equals(Material.DIAMOND_HELMET)) { event.getPlayer().addPotionEffect(new PotionEffect(PotionEffectType.LEVITATION, 9999999, 1)); } return; } if(!InventoryUtils.isNull(event.getOldArmor())) { if(event.getOldArmor().getType().equals(Material.DIAMOND_HELMET)) { event.getPlayer().removePotionEffect(PotionEffectType.LEVITATION); } } }
- BowArrowHitEvent
@EventHandler public void bow(BowArrowHitEvent event){ event.getShooter().teleport(event.getArrow().getLocation()); }
- BungeeForwardEvent
由bc服务器发送的数据触发
- NPCInteractEvent: 由玩家交互NPC触发
- PlayerJumpEvent: 由玩家跳跃触发
- ServerReloadEvent: 由服务器重载触发
- ServerStopEvent: 由关服触发
Inventory|背包
- - BookManager: 更容易地创建一本书, 修改页面, 设置书的作者等
- - ItemManager: 更容易地创建带有颜色的物品,设置无限耐久或修改其他属性
- - InventoryManager: 更快地创建背包! 用如 #addUniqueItem 一样的特殊方法,或添加可点击的物品
- - RecipeManager: 可以注册/注销配方或进行比较
- - SkullManager: 更容易地创建皮肤头!
Mojang
- - GameProfileManager: 更简单地修改游戏数据, 你可以用来修改一位玩家的皮肤
- - SkinAPI:更安全的API来获取皮肤 (它们将会被缓存)
// 注意: 此代码仅在没有代理的情况下运行 new PlayerManager((Player) sender).changeSkin(SkinAPI.getSkin(MojangAPI.getUUID(value).getB()).getSkin());
NBT
可以加载多种 NBT 标签 (配置选择, JSON, 实体, 物品), 然后修改它们并保存为另一个类型
NBTCompound nbt = NBTLoader.fromEntity(player); try { new FileManager("entity.json").delete() .initFile(nbt.toJSON().getBytes(StandardCharsets.UTF_8)); } catch(IOException e) { e.printStackTrace(); }
- Placeholders: 有三种类型: Placeholder (经常是最新的), CachedPlaceholder (推荐方式, placeholders会被缓存并自动被更新), FixedPlaceholder (不会更新)
- Protocol: 包含很多如Title标题, Action Bar, Particle粒子效果, Camera, Player List玩家列表 的 packets
- Socket: 帮助你创建一个 socket 服务器/客户端, 能够通过字节数组发送和接收数据.
ServerSocketManager server = new ServerSocketManager(16850, new ServerSocketHandler() { @Override public void request(ServerSocketClientManager client, byte[] data) { } @Override public void connect(ServerSocketClientManager client) { try { client.send("欢迎来到服务器!"); } catch(IOException e) { e.printStackTrace(); } } });
Utils|效用
包含很多东西 你自己看吧
链接
- Javadoc: https://anhcraft.github.io/SpaciousLib/javadoc/
- • Wiki: https://github.com/anhcraft/SpaciousLib/wiki
- • Placeholders: https://cdn.rawgit.com/anhcraft/SpaciousLib/master/.placeholders