Developer API

EzWarnings has an awesome API for you to hook into! Let me explain it below.

// Warn a player. It will automatically check the config to see 
// if the player needs to be punished, and if he/she does, 
// it will automatically punish them.
WarningManager.warn(Player p);

// Get the amount of warnings the player has.
// Returns an Integer
WarningManager.getWarnings(Player p);

// Get the warning types defined in the config
// Returns a list of strings
WarningManager.getWarningTypes();

// Get the warning types in the format for the /warn command
// Returns a string
// Example of something it would return:
// <abuse/caps/racist>
WarningManager.getWarningTypesForCommand();

// Reset warnings for a player
WarningManager.resetWarnings(Player p);

// Punish a player. It will automaticially check the config to see
// if it needs to run the final command, and if it does need to,
// it will.
WarningManager.punish(Player p);

// Get the times a player has been punished
// Returns an integer
WarningManager.getTimesPunished(Player p);

// Reset the punishments for a player
WarningManager.resetPunishments(Player p);

// You can also use the Message and Config part of the EzWarnings API

// Save a default message from the EzWarnings local
EzWarnings.messages.setDefault("EzAddon.message", "&6Some cool &aColor Coded &6message");
EzWarnings.messages.save();

// Send a message from the EzWarnings local
EzWarnings.messages.sendTranslation(CommandSender sender, String key, boolean addPrefix, Variable... variables);
// Example:
EzWarnings.messages.sendTranslation(p, "EzAddon.message", true, new Variable[] { new Variable("<player>", args[0]), new Variable("{reasons}", WarningManager.getWarningTypesForCommand()) });

See more information about Variables here.


Comments

Posts Quoted:
Reply
Clear All Quotes