LunarClientAPI is a Spigot plugin that allows developers to integrate features with LunarClient.
Unlike the original API, there is no need to add the NetHandler as it's now directly shaded!
Firstly, download the most recent release, drop it in your plugins
folder and restart. Then, simply add
the dependency to your plugin as follows, replacing [LATEST]
with latest version:
<repository>
<id>jitpack-repo</id>
<url>https://jitpack.io</url>
</repository>
<dependency>
<groupId>com.github.PestoNotPasta</groupId>
<artifactId>LunarClientAPI</artifactId>
<version>[LATEST]</version>
<scope>provided</scope>
</dependency>
repositories {
url = 'https://jitpack.io/'
}
dependencies {
compileOnly 'com.github.PestoNotPasta:LunarClientAPI:[LATEST]'
}
Don't forget to update your plugin.yml
:
depend: [LunarClientAPI]
LunarClientAPI.java
is a singleton, you can access it through LunarClientAPI#getInstance()
.
To check if someone claims to be running the client, and is therefore able to integrate with server features, use
LunarClientAPI#isRunningLunarClient(Player|UUID)
. When the API registers a Player
as running Lunar Client, a
LCPlayerRegisterEvent
is fired. When unregistered, a LCPlayerUnregisterEvent
.
You can access a view of org.bukkit.Player
s currently running the client with:
LunarClientAPI#getPlayersRunningLunarClient()
.
LCPacket.java
represents a packet that can be sent to and from players running Lunar Client.
There are protocol events for these, any time a LCPacket
is received by the server, a LCPacketReceivedEvent
is fired,
and likewise, when sent, a LCPacketSentEvent
-- both of which let you access but not modify the packet itself,
and the sender/target.
- Instantiate a
ModSetting
that sets the enabled status tofalse
. - Send a
LCPacketModSettings
withModSettings
that affect the mods you wish to disable, like so:
ModSettings.ModSetting disabled = new ModSettings.ModSetting(false, new HashMap<>());
sendPacket(event.getPlayer(), new LCPacketModSettings(
new ModSettings()
.addModSetting("Coordinates", disabled)
.addModSetting("textHotKey", disabled)
));
ServerRule.java
represents a rule your server sets for each client. You can, for example, enable a quitting
confirmation for competitive games by using LunarClientAPIServerRule.setRule(ServerRule.COMPETITIVE_GAME, true)
. You
will still need to send these server rules to users using LunarClientAPIServerRule.sendServerRule(Player)
when they join.
(This pattern work for all ServerRule)
- Q: How do I color a Waypoint or Border?
- A: Use an
int
which represents the RGB value of the color. Examples:java.awt.Color.BLUE.getRGB()
|new java.awt.Color(0, 0, 255).getRGB()
--org.bukkit.Color
s can also be used, but since they store the color inhex
, you call#asRGB()
; for example:org.bukkit.Color.BLUE.asRGB()