本文整理汇总了Java中net.citizensnpcs.api.CitizensAPI类的典型用法代码示例。如果您正苦于以下问题:Java CitizensAPI类的具体用法?Java CitizensAPI怎么用?Java CitizensAPI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CitizensAPI类属于net.citizensnpcs.api包,在下文中一共展示了CitizensAPI类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findTellers
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
public List<NPC> findTellers() {
List<NPC> tellers = new ArrayList<>();
for(Chunk c : chunks) {
Entity[] entities = c.getEntities();
for(Entity e : entities) {
//We don't care about entities that are not within the bank area, and that aren't human.
if(!bankArea.contains(e.getLocation().getBlock()) || !(e instanceof HumanEntity)) continue;
if(CitizensAPI.getNPCRegistry().isNPC(e)) {
NPC n = CitizensAPI.getNPCRegistry().getNPC(e);
if(n != null) tellers.add(n);
}
}
}
return tellers;
}
示例2: reset
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
private void reset() {
scriptingManager.reset();
scriptEventManager.reset();
entityEventManager.reset();
inventoryEventManager.reset();
CitizensAPI.getNPCRegistry().forEach((npc) -> npc.despawn(DespawnReason.PLUGIN));
commandManager.removeAll();
timerManager.removeAll();
dialogs.reset();
trackingShots.reset();
abilities.reset();
weakPlayerMaps.reset();
try {
storage.getStorage().reload();
} catch (StorageException e) {
getLogger().log(Level.SEVERE, "Reloading the storage failed", e);
}
}
示例3: onNpcKill
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@EventHandler
public void onNpcKill(MobKilledEvent event) {
NPC npc = CitizensAPI.getNPCRegistry().getNPC(event.getEntity());
if (npc == null) {
return;
}
if (npc.getId() != ID) {
return;
}
String playerID = PlayerConverter.getID(event.getPlayer());
NPCData playerData = (NPCData) dataMap.get(playerID);
if (containsPlayer(playerID) && checkConditions(playerID)) {
playerData.kill();
if (playerData.killed()) {
completeObjective(playerID);
}
}
}
示例4: run
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
public void run(String playerID) throws QuestRuntimeException {
// this event should not run if the player is offline
if (PlayerConverter.getPlayer(playerID) == null) {
currentPlayer = null;
return;
}
NPC npc = CitizensAPI.getNPCRegistry().getById(id);
if (npc == null) {
BetonQuest.getInstance().getLogger().warning("NPC with ID " + id + " does not exist");
return;
}
if (!npc.isSpawned()) {
return;
}
if (currentPlayer == null) {
npc.getNavigator().setTarget(loc.getLocation(playerID));
currentPlayer = playerID;
movingNPCs.add(npc);
Bukkit.getPluginManager().registerEvents(ths, BetonQuest.getInstance());
} else {
for (EventID event : failEvents) {
BetonQuest.event(playerID, event);
}
}
}
示例5: applyVisibility
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
/**
* Updates the visibility of the specified NPC for this player.
*
* @param player the player
* @param npcID ID of the NPC
*/
public void applyVisibility(Player player, Integer npcID) {
boolean hidden = true;
Set<ConditionID> conditions = npcs.get(npcID);
if (conditions == null || conditions.isEmpty()) {
hidden = false;
} else {
for (ConditionID condition : conditions) {
if (!BetonQuest.condition(PlayerConverter.getID(player), condition)) {
hidden = false;
break;
}
}
}
NPC npc = CitizensAPI.getNPCRegistry().getById(npcID);
if (npc.isSpawned()) {
if (hidden) {
hider.hideEntity(player, npc.getEntity());
} else {
hider.showEntity(player, npc.getEntity());
}
}
}
示例6: createWorkers
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
protected void createWorkers() {
for (Chunk c : this.chunks) {
Entity[] entities = c.getEntities();
for (Entity e : entities) {
if (this.trainArea.contains(e.getLocation().getBlock())) {
//See if the Entity is convertable to an NPC.
if (CitizensAPI.getNPCRegistry().isNPC(e)) {
//We only want NPC Humans to be converted and used... We don't want cows and chickens...
if (e instanceof HumanEntity) {
//Convert it!!!
this.workers.add(CitizensAPI.getNPCRegistry().getNPC(e));
}
}
}
}
}
}
示例7: createMount
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
/**
* Create a mount for the jockey
* @param mountName
* @param spawn
*/
private void createMount(String mountName, Location spawn, boolean enabled) {
if (this.mountType.hasBukkitMapping()) {
// Make their mounts
this.mount = CitizensAPI.getNPCRegistry().createNPC(this.mountType.getBukkitMapping(), mountName == null ? "Error" : mountName);
this.mount.setProtected(true);
this.mount.addTrait(NmsHandler.getNmsHandler().newMount(true));
this.mount.spawn(spawn);
this.race.getCourse().getMountData().applyMountData(this.mount.getEntity());
// Set the owner of the mount to the jockey
Owner owner = this.mount.getTrait(Owner.class);
owner.setOwner(this.player.getName());
// Make the NPC controllable and mount the player
Mount trait = this.mount.getTrait(NmsHandler.getNmsHandler().getMountClass());
trait.mount(this.player);
trait.setEnabled(enabled); // disable it until the race has started
}
}
示例8: onPlayerInteractEntity
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@EventHandler
public void onPlayerInteractEntity(PlayerInteractEntityEvent event){
Entity entity = event.getRightClicked();
Player player = event.getPlayer();
if(createNewQuestEntity != null && createNewQuestEntity == player){
if(CitizensAPI.getNPCRegistry().isNPC(entity)){
QuestEntity qEntity = new QuestEntity(entity);
qEntity.SetBasics(createNewQuestEntityQuest);
player.sendMessage(ChatColor.GREEN + QuestEntityHandler.getEntityName(entity) + " is now a quest giver.");
}else{
player.sendMessage(ChatColor.RED + "That isn't a citizens NPC. Try again.");
}
createNewQuestEntity = null;
return;
}
EpicPlayer epicPlayer = EpicSystem.getEpicPlayer(player.getUniqueId());
if(QuestEntityHandler.entityList.containsKey(entity)){
QuestEntityHandler.GetQuestEntity(entity).NextInteraction(epicPlayer);
event.setCancelled(true);
}
}
示例9: check
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
public boolean check(Event e) {
NPCRegistry registry = CitizensAPI.getNPCRegistry();
if (registry.isNPC(entity.getSingle(e))) {
return isNegated();
} else {
return !isNegated();
}
}
示例10: RpgPlusEntity
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
public RpgPlusEntity(Location location, EntityType type) {
this.location = location;
this.type = type;
npc = CitizensAPI.getNPCRegistry().createNPC(type, "");
npc.addTrait(new NameTagTrait(type));
if (type == EntityType.PLAYER) {
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, true);
} else {
npc.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
}
}
示例11: check
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
public boolean check(Event evt) {
if (test.getSingle(evt) != null && id.getSingle(evt) != null
&& test.getSingle(evt).hasMetadata("NPC")) {
NPCRegistry registry = CitizensAPI.getNPCRegistry();
if (registry.getNPC(test.getSingle(evt)).getId() == id.getSingle(evt).intValue()) {
return true;
}
return false;
} else {
return false;
}
}
示例12: get
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
@Nullable
protected Location[] get(Event evt) {
NPCRegistry registry = CitizensAPI.getNPCRegistry();
NPC npc = registry.getById(id.getSingle(evt).intValue());
BuilderTrait bt = npc.getTrait(BuilderTrait.class);
if (bt.schematic != null) {
Location topLeft = loc.getSingle(evt).add((Math.round(bt.schematic.width() / 2)),
bt.schematic.height() - 1, (Math.round(bt.schematic.length() / 2)));
return new Location[] {topLeft};
} else {
Skript.error("A schematic has yet to be loaded for this Builder");
return new Location[] {loc.getSingle(evt)};
}
}
示例13: get
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
@org.eclipse.jdt.annotation.Nullable
protected Entity[] get(org.bukkit.event.Event evt) {
NPCRegistry registry = CitizensAPI.getNPCRegistry();
try {
NPC npc = registry.getById(this.id.getSingle(evt).intValue());
return new Entity[] {npc.getEntity()};
} catch (NullPointerException exception) {
return null;
}
}
示例14: get
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
@Nullable
protected Number[] get(Event evt) {
if (entity.getSingle(evt) != null && entity.getSingle(evt).hasMetadata("NPC")) {
NPCRegistry registry = CitizensAPI.getNPCRegistry();
return new Number[] {registry.getNPC(entity.getSingle(evt)).getId()};
}
return null;
}
示例15: get
import net.citizensnpcs.api.CitizensAPI; //导入依赖的package包/类
@Override
@Nullable
protected String[] get(Event evt) {
NPCRegistry registry = CitizensAPI.getNPCRegistry();
NPC npcName = registry.getById(id.getSingle(evt).intValue());
return new String[] {npcName.getName()};
}