本文整理汇总了Java中net.citizensnpcs.api.npc.NPC类的典型用法代码示例。如果您正苦于以下问题:Java NPC类的具体用法?Java NPC怎么用?Java NPC使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NPC类属于net.citizensnpcs.api.npc包,在下文中一共展示了NPC类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: findTellers
import net.citizensnpcs.api.npc.NPC; //导入依赖的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;
}
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:17,代码来源:Bank.java
示例2: QuestsXLChatMessagesEvent
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
public QuestsXLChatMessagesEvent(NPC npc, Player player)
{
this.npc = npc;
this.player = player;
npcMessages = new File(QuestsXL.plugin.getDataFolder() + File.separator + npc.getId() + ".txt");
parentDirectory = npcMessages.getParentFile();
/*if(npcMessages.exists() && !npcMessages.isDirectory())
{
}else
{
}*/
}
开发者ID:DRE2N,项目名称:QuestsXL,代码行数:17,代码来源:QuestsXLChatMessagesEvent.java
示例3: check
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@Override
public boolean check(Event evt) {
if (evt instanceof NPCEvent) {
NPC testTarget = ((NPCEvent) evt).getNPC();
if (testTarget == null) {
return false;
}
if (name.getSingle(evt).toString().replace("\"", "").trim()
.equals(testTarget.getFullName())) {
return true;
} else {
return false;
}
} else {
return false;
}
}
开发者ID:eyesniper2,项目名称:skRayFall,代码行数:18,代码来源:CondIsNpcNamed.java
示例4: check
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@Override
public boolean check(Event evt) {
if (evt instanceof NPCEvent) {
NPC testTarget = ((NPCEvent) evt).getNPC();
if (testTarget == null) {
return false;
}
if (id.getSingle(evt).intValue() == testTarget.getId()) {
return true;
} else {
return false;
}
} else {
return false;
}
}
开发者ID:eyesniper2,项目名称:skRayFall,代码行数:17,代码来源:CondIsNpcId.java
示例5: onNpcKill
import net.citizensnpcs.api.npc.NPC; //导入依赖的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);
}
}
}
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:19,代码来源:NPCKillObjective.java
示例6: onConversationStart
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@EventHandler
public void onConversationStart(final PlayerConversationStartEvent event) {
if (event.getConversation() instanceof CitizensConversation) {
new BukkitRunnable() {
@Override
public void run() {
CitizensConversation conv = (CitizensConversation) event.getConversation();
NPC npc = conv.getNPC();
if (!npcs.containsKey(npc)) {
Navigator nav = npc.getNavigator();
npcs.put(npc, new Integer(1));
locs.put(npc, nav.getTargetAsLocation());
nav.setPaused(true);
nav.cancelNavigation();
nav.setTarget(conv.getNPC().getEntity().getLocation());
nav.setPaused(true);
nav.cancelNavigation();
} else {
npcs.put(npc, npcs.get(npc) + 1);
}
}
}.runTask(BetonQuest.getInstance());
}
}
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:26,代码来源:CitizensWalkingListener.java
示例7: onConversationEnd
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@EventHandler
public void onConversationEnd(final PlayerConversationEndEvent event) {
if (event.getConversation() instanceof CitizensConversation) {
new BukkitRunnable() {
@Override
public void run() {
CitizensConversation conv = (CitizensConversation) event.getConversation();
NPC npc = conv.getNPC();
Integer i = npcs.get(npc);
i--;
if (i == 0) {
npcs.remove(npc);
if (npc.isSpawned()) {
Navigator nav = npc.getNavigator();
nav.setPaused(false);
nav.setTarget(locs.remove(npc));
}
} else {
npcs.put(npc, i);
}
}
}.runTask(BetonQuest.getInstance());
}
}
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:26,代码来源:CitizensWalkingListener.java
示例8: run
import net.citizensnpcs.api.npc.NPC; //导入依赖的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);
}
}
}
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:27,代码来源:NPCMoveEvent.java
示例9: applyVisibility
import net.citizensnpcs.api.npc.NPC; //导入依赖的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());
}
}
}
开发者ID:Co0sh,项目名称:BetonQuest,代码行数:31,代码来源:NPCHider.java
示例10: generateTellerBlocks
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
/**
* Gets a perimeter around the NPC teller which will be used to figure transaction interactions.
*
* @param teller the employee to generate the blocks for.
* @return The list of blocks which are around the employee, in a cube form.
*/
public List<Block> generateTellerBlocks(NPC teller) {
//This location is the CENTER of the teller blocks. we expand outwards the specified amount (set in config.yml)
Location telLoc = teller.getBukkitEntity().getLocation();
List<Block> tellerBlocks = new ArrayList<>();
for(int x = telLoc.getBlockX() - tellerDiameter; x <= telLoc.getBlockX() + tellerDiameter; x++) {
for(int y = telLoc.getBlockY(); y <= telLoc.getBlockY() + tellerDiameter; y++) {
for(int z = telLoc.getBlockZ() + tellerDiameter; z >= telLoc.getBlockZ() - tellerDiameter; z--) {
tellerBlocks.add(world.getBlockAt(x, y, z));
}
}
}
//Testing mapping of convos.
// for(Block b : tellerBlocks) {
// b.setType(Material.GOLD_BLOCK);
// }
return tellerBlocks;
}
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:26,代码来源:Bank.java
示例11: dialogMonitor
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
/**
* In charge of monitoring where the player is during conversations.
* <p>
* Determines whether or not a conversation should start, continue, or stop.
*
* @param pme The event of Player Movement.
*/
@EventHandler
public void dialogMonitor(PlayerMoveEvent pme) {
Block from = pme.getFrom().getBlock(), to = pme.getTo().getBlock();
Player p = pme.getPlayer();
if(helpedBy.containsKey(p.getName())) {
//Leaving Conversation
if(!tellerAreas.containsKey(to) && tellerAreas.containsKey(from)) {
if(tellerAreas.get(from).equals(helpedBy.get(p.getName()))) {
Conversation c = conversations.get(p.getName());
if(c.getState().equals(Conversation.ConversationState.STARTED)) c.abandon();
conversations.remove(p.getName());
helpedBy.remove(p.getName());
}
}
}
//Entering Conversation
if(tellerAreas.containsKey(to) && !tellerAreas.containsKey(from)) {
if(helpedBy.get(p.getName()) == null) {
NPC employee = tellerAreas.get(to);
helpedBy.put(p.getName(), employee);
conversations.put(p.getName(), startTransaction(p, employee));
}
}
}
开发者ID:GoldRushMC,项目名称:GoldRushPlugin,代码行数:33,代码来源:Bank.java
示例12: isMissingShopkeeper
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
private boolean isMissingShopkeeper() {
NPC npc = this.getNPC();
if (npc == null || !npc.hasTrait(CitizensShopkeeperTrait.class)) {
// citizens not running or trait got already removed again?
return false;
}
if (ShopkeepersPlugin.getInstance() == null) {
// shopkeepers not running:
return false;
}
if (ShopkeepersPlugin.getInstance().getActiveShopkeeper(CitizensShop.getId(npc.getId())) != null) {
// there is already a shopkeeper for this npc:
// the trait was probably re-attached after a reload of citizens:
return false;
}
return true;
}
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:20,代码来源:CitizensShopkeeperTrait.java
示例13: setName
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@Override
public void setName(String name) {
NPC npc = this.getNPC();
if (npc == null) return;
if (Settings.showNameplates && name != null && !name.isEmpty()) {
if (Settings.nameplatePrefix != null && !Settings.nameplatePrefix.isEmpty()) {
name = Settings.nameplatePrefix + name;
}
name = this.trimToNameLength(name);
// set entity name plate:
npc.setName(name);
// this.entity.setCustomNameVisible(Settings.alwaysShowNameplates);
} else {
// remove name plate:
npc.setName("");
// this.entity.setCustomNameVisible(false);
}
}
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:20,代码来源:CitizensShop.java
示例14: check
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@Override
public boolean check() {
NPC npc = this.getNPC();
if (npc != null) {
String worldName = shopkeeper.getWorldName();
World world = Bukkit.getWorld(worldName);
int x = shopkeeper.getX();
int y = shopkeeper.getY();
int z = shopkeeper.getZ();
Location currentLocation = npc.getStoredLocation();
Location expectedLocation = new Location(world, x + 0.5D, y + 0.5D, z + 0.5D);
if (currentLocation == null) {
npc.teleport(expectedLocation, PlayerTeleportEvent.TeleportCause.PLUGIN);
Log.debug("Shopkeeper NPC (" + worldName + "," + x + "," + y + "," + z + ") had no location, teleported");
} else if (!currentLocation.getWorld().equals(expectedLocation.getWorld()) || currentLocation.distanceSquared(expectedLocation) > 1.0D) {
shopkeeper.setLocation(currentLocation);
Log.debug("Shopkeeper NPC (" + worldName + "," + x + "," + y + "," + z + ") out of place, re-indexing");
}
} else {
// Not going to force Citizens creation, this seems like it could go really wrong.
}
return false;
}
开发者ID:nisovin,项目名称:Shopkeepers,代码行数:26,代码来源:CitizensShop.java
示例15: onNPCRightClick
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@EventHandler
public void onNPCRightClick(NPCRightClickEvent e) throws FileNotFoundException, IOException
{
player = e.getClicker();
npc = e.getNPC();
if(e.getNPC() instanceof NPC)
{
int npcID = npc.getId();
npcText = new File("plugins/QuestsXL/" + npcID + ".txt");
if((npcText.exists()) == false)
{
player.sendMessage(ChatColor.DARK_GRAY + "This NPC has nothing to tell.");
}else
{
try(BufferedReader br = new BufferedReader(new FileReader(npcText)))
{
String line;
while((line = br.readLine()) != null)
{
player.sendMessage(ChatColor.DARK_PURPLE + "[NPC] " + npc.getName() + ": " + ChatColor.WHITE + line);
}
}
}
}
}
开发者ID:DRE2N,项目名称:QuestsXL,代码行数:29,代码来源:QuestsXLNPCClickEvent.java
示例16: init
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
marker = parser.mark;
npc = (Expression<NPC>) e[0];
location = (Expression<Location>) e[1];
teleportcause = (Expression<TeleportCause>) e[2];
teleportcausestring = (Expression<String>) e[3];
return true;
}
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:11,代码来源:EffNpcTeleport.java
示例17: init
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int arg1, Kleenean arg2, ParseResult arg3) {
npc = (Expression<NPC>) e[0];
despawn = (Expression<DespawnReason>) e[1];
return true;
}
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:EffNpcDespawn.java
示例18: init
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int matchedPattern, Kleenean isDelayed, ParseResult parser) {
npc = (Expression<NPC>) e[0];
entity = (Expression<Entity>) e[1];
aggressive = (Expression<Boolean>) e[2];
return true;
}
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:9,代码来源:EffNpcAttack.java
示例19: init
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public boolean init(Expression<?>[] e, int arg1, Kleenean arg2, ParseResult arg3) {
npc = (Expression<NPC>) e[0];
location = (Expression<Location>) e[1];
return true;
}
开发者ID:TheLimeGlass,项目名称:Skellett,代码行数:8,代码来源:EffNpcFaceLocation.java
示例20: rawset
import net.citizensnpcs.api.npc.NPC; //导入依赖的package包/类
@Override
public void rawset(LuaValue key, LuaValue value) {
if (key.isstring()) {
switch (key.checkjstring()) {
case "health":
if (entity.getEntity() instanceof Damageable) {
((Damageable) entity.getEntity()).setHealth(value.checkdouble());
}
break;
case "maxHealth":
if (entity.getEntity() instanceof Damageable) {
((Damageable) entity.getEntity()).setMaxHealth(value.checkdouble());
}
break;
case "name":
entity.setName(ChatColor.translateAlternateColorCodes('&', value.checkjstring()));
break;
case "secondName":
entity.setSecondName(ChatColor.translateAlternateColorCodes('&', value.checkjstring()));
break;
case "invulnerable":
entity.setTakingDamage(!value.checkboolean());
break;
case "nameVisible":
entity.setNameVisible(value.checkboolean());
break;
case "target":
getEntity().getNpc().getNavigator().getLocalParameters().stuckAction(new StuckAction() {
@Override
public boolean run(NPC npc, Navigator nav) {
return true;
}
});
entity.setTarget(value == LuaValue.NIL ? null : ScriptUtil.getPlayer(value));
break;
}
}
super.rawset(key, value);
}
开发者ID:leMaik,项目名称:RpgPlus,代码行数:41,代码来源:EntityWrapper.java
注:本文中的net.citizensnpcs.api.npc.NPC类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论