The nPunish API allows you to integrate the nPunish plugin functionalities into your own plugins. With this API, you can programmatically perform actions such as banning and kicking players from your server.
To use the nPunish API in your plugin, follow the steps below:
-
Download the latest version of the nPunish plugin from the SpigotMC website.
-
Install and enable the nPunish plugin on your Spigot/Paper server.
-
Add the nPunish plugin as a dependency in your plugin's
plugin.yml
file:depend: [nPunish] Add the nPunish API class (nPunishAPI.java) to your plugin's source code. You can find the API class in this repository.
To ban a player using the nPunish API, follow these steps:
Create an instance of the nPunishAPI class in your plugin:
First import the api:
import com.nate.npunish.api.nPunishAPI;
Then initialize it in your on enable method:
private nPunishAPI npunishAPI;
@Override
public void onEnable() {
npunishAPI = new nPunishAPI(this);
}
}
Use the kickPlayer method of the nPunishAPI class to ban a player:
import org.bukkit.entity.Player;
// Inside your plugin code...
Player player = getPlayerSomehow(); // Get the player you want to ban
String reason = "Breaking server rules"; // Specify the reason for the ban
// Ban the player using the nPunishAPI
npunishAPI.banPlayer(player, reason);
To kick a player using the nPunish API, follow these steps:
Create an instance of the nPunishAPI class in your plugin (if you haven;t already done so):
@Override
import org.bukkit.plugin.java.JavaPlugin;
import com.nate.npunish.api.nPunishAPI;
public class YourPlugin extends JavaPlugin {
private nPunishAPI npunishAPI;
public void onEnable() {
// Initialize the nPunishAPI with your plugin instance
npunishAPI = new nPunishAPI(this);
// Your plugin initialization code...
}
// Other methods and plugin code...
}
Use the kickPlayer method of the nPunishAPI class to kick a player:
import org.bukkit.entity.Player;
// Inside your plugin code...
Player player = getPlayerSomehow(); // Get the player you want to kick
String reason = "Breaking server rules"; // Specify the reason for the kick
// Kick the player using the nPunishAPI
npunishAPI.kickPlayer(player, reason);
The nPunish API requires the nPunish plugin to be installed and enabled on your Spigot/Paper server. Make sure to include the nPunish plugin as a dependency in your plugin's plugin.yml file.
If you encounter any issues or have suggestions for improvements, please open an issue on the GitHub repository.
This API is released under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
You are free to use and modify the API as per your needs. However, you are not allowed to claim it as your own or use it in any commercial project without proper permission. Additionally, you are not permitted to incorporate this API into any plugin or software that replicates or duplicates the functionality of the nPunish plugin.