-
-
Notifications
You must be signed in to change notification settings - Fork 4
Developer API
YouHaveTrouble edited this page Nov 20, 2023
·
5 revisions
Replace VERSION
with latest version visible here:
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependency>
<groupId>com.github.YouHaveTrouble</groupId>
<artifactId>PreventStabby</artifactId>
<version>VERSION</version>
</dependency>
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
dependencies {
implementation 'com.github.YouHaveTrouble:PreventStabby:VERSION'
}
For all API methods here you can provide a Player object or player UUID object.
API will be improved in the future, consistency not guaranteed between major versions!
PreventStabbyAPI.setPvpEnabled(player, true);
boolean state = PreventStabbyAPI.getPvpEnabled(player);
The boolean at the end decides if the deny message should be sent to attacker in case they can't damage the victim.
boolean canDamage = PreventStabbyAPI.canDamage(playerAttacker, playerVictim, false);
This check is included in PreventStabbyAPI#canDamage(), but in case you need to check for that specifically here's the method for that
boolean hasloginProtection = PreventStabbyAPI.hasLoginProtection(player);
boolean isInCombat = PreventStabbyAPI.isInCombat(player);
Pvpstate pvpState = PreventStabbyAPI.getForcedPvpState();
PreventStabbyAPI.setForcedPvpState(PvpState newForcedPvpState);
Called when player enters pvp combat. If cancelled, player will not be put in combat. Example use:
@EventHandler(ignoreCancelled = true)
public void onPlayerJoin(PlayerEnterCombatEvent event) {
// do stuff
}
Called when player leaves pvp combat. If cancelled, combat time will be refreshed for the combat time set in plugin config. Example use:
@EventHandler(ignoreCancelled = true)
public void onPlayerJoin(PlayerLeaveCombatEvent event) {
// do stuff
}