use of net.citizensnpcs.api.npc.NPC in project Denizen-For-Bukkit by DenizenScript.
the class VulnerableCommand method execute.
@Override
public void execute(ScriptEntry scriptEntry) throws CommandExecutionException {
// Fetch objects
Element action = scriptEntry.getElement("action");
BukkitScriptEntryData entryData = (BukkitScriptEntryData) scriptEntry.entryData;
// Report to dB
dB.report(scriptEntry, getName(), entryData.getNPC().debug() + action.debug());
NPC npc = entryData.getNPC().getCitizen();
Toggle toggle = Toggle.valueOf(action.asString().toUpperCase());
npc.setProtected(!(toggle == Toggle.TOGGLE ? npc.isProtected() : action.asBoolean()));
}
use of net.citizensnpcs.api.npc.NPC in project Denizen-For-Bukkit by DenizenScript.
the class dNPC method matches.
public static boolean matches(String string) {
// If using object notation, assume it's valid
if (CoreUtilities.toLowerCase(string).startsWith("n@")) {
return true;
}
// Otherwise, let's do checks
string = string.toUpperCase().replace("N@", "");
NPC npc;
if (aH.matchesInteger(string)) {
npc = CitizensAPI.getNPCRegistry().getById(aH.getIntegerFrom(string));
if (npc != null) {
return true;
}
} else {
for (NPC test : CitizensAPI.getNPCRegistry()) {
if (test.getName().equalsIgnoreCase(string)) {
return true;
}
}
}
return false;
}
use of net.citizensnpcs.api.npc.NPC in project Denizen-For-Bukkit by DenizenScript.
the class dNPCRegistry method onRemove.
// <--[action]
// @Actions
// remove
// @Triggers when the NPC is removed.
//
// @Context
// None
// -->
/**
* Removes an NPC from the Registry when removed from Citizens.
*
* @param event NPCRemoveEvent
*/
@EventHandler
public void onRemove(NPCRemoveEvent event) {
NPC npc = event.getNPC();
getDenizen(npc).action("remove", null);
if (_isRegistered(npc)) {
denizenNPCs.remove(npc.getId());
npcInventories.remove(npc.getId());
}
FlagManager.clearNPCFlags(npc.getId());
}
Aggregations