For v1.1.4.

Fixed the usage of NPCLib as a plugin dependency without shading it.
master
JitseB 6 years ago
parent d3af2fa9ae
commit 15335c24f1
  1. 3
      README.md
  2. 2
      api/pom.xml
  3. 2
      commons/pom.xml
  4. 2
      nms/pom.xml
  5. 2
      nms/v1_10_R1/pom.xml
  6. 2
      nms/v1_11_R1/pom.xml
  7. 2
      nms/v1_12_R1/pom.xml
  8. 2
      nms/v1_8_R1/pom.xml
  9. 2
      nms/v1_8_R2/pom.xml
  10. 2
      nms/v1_8_R3/pom.xml
  11. 2
      nms/v1_9_R1/pom.xml
  12. 2
      nms/v1_9_R2/pom.xml
  13. 2
      plugin/pom.xml
  14. 68
      plugin/src/main/java/net/jitse/npclib/plugin/NPCLibPlugin.java
  15. 43
      plugin/src/main/java/net/jitse/npclib/plugin/listeners/NPCListener.java
  16. 2
      pom.xml

@ -20,6 +20,7 @@ Alternatively, you can help the project by starring the repository or telling ot
## Usage
It is recommended to shade `NPCLib-API-v*.jar` into your plugin.
Alternatively, you may put `NPCLib-Plugin-v*.jar` under your `plugins` folder. By using this option, you do not need to shade the API JAR anymore. Though, do not forget to add `NPCLib` as a dependency in your `plugin.yml`!
You can download the latest release [here](https://github.com/JitseB/NPCLib/releases/latest).
@ -41,7 +42,7 @@ You can download the latest release [here](https://github.com/JitseB/NPCLib/rele
npc.show(player);
npc.hide(player);
// If you don't use the NPC anymore, destroy the NPC accordingly.
// If you do not use the NPC anymore, destroy the NPC accordingly.
npc.destroy();
```

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-api</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-commons</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_10_R1</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_11_R1</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_12_R1</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_8_R1</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_8_R2</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_8_R3</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_9_R1</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib-nms</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-nms-v1_9_R2</artifactId>

@ -7,7 +7,7 @@
<parent>
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
</parent>
<artifactId>npclib-plugin</artifactId>

@ -4,82 +4,20 @@
package net.jitse.npclib.plugin;
import net.jitse.npclib.NPCLib;
import net.jitse.npclib.api.NPC;
import net.jitse.npclib.plugin.listeners.NPCListener;
import net.jitse.npclib.skin.MineSkinFetcher;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.Arrays;
/**
* @author Jitse Boonstra
*/
public class NPCLibPlugin extends JavaPlugin implements Listener {
private NPCLib npcLib;
private NPC npc;
public class NPCLibPlugin extends JavaPlugin {
@Override
public void onEnable() {
this.npcLib = new NPCLib(this);
getServer().getConsoleSender().sendMessage(ChatColor.BLUE + "[NPCLib] " + ChatColor.WHITE + "plugin enabled.");
getServer().getConsoleSender().sendMessage(ChatColor.BLUE + "[NPCLib] " +
ChatColor.GRAY + "This is a test plugin usually used for development reasons. " +
"You can spawn NPCs by pressing [shift] in game.");
getServer().getPluginManager().registerEvents(this, this);
getServer().getPluginManager().registerEvents(new NPCListener(), this);
getLogger().info("NPC library loaded.");
}
@Override
public void onDisable() {
if (npc != null) {
npc.destroy(false);
}
getServer().getConsoleSender().sendMessage(ChatColor.BLUE + "[NPCLib] " + ChatColor.WHITE + "plugin disabled.");
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
if (npc != null) {
npc.show(event.getPlayer());
}
}
@EventHandler
public void onPlayerShift(PlayerToggleSneakEvent event) {
if (event.isSneaking()) {
return;
}
if (npc != null) {
if (npc.isActuallyShown(event.getPlayer())) {
npc.hide(event.getPlayer());
} else {
npc.show(event.getPlayer());
}
} else {
MineSkinFetcher.fetchSkinFromIdAsync(168841, skin -> {
npc = npcLib.createNPC(skin, Arrays.asList(
ChatColor.BOLD + "NPC Library", "",
"Create your own", "non-player characters",
"with the simplistic", "API of NPCLib!"
));
npc.create(event.getPlayer().getLocation());
for (Player player : getServer().getOnlinePlayers()) {
npc.show(player);
}
});
}
getLogger().info("NPC library unloaded.");
}
}

@ -1,43 +0,0 @@
/*
* Copyright (c) 2018 Jitse Boonstra
*/
package net.jitse.npclib.plugin.listeners;
import net.jitse.npclib.events.NPCDestroyEvent;
import net.jitse.npclib.events.NPCInteractEvent;
import net.jitse.npclib.events.NPCSpawnEvent;
import net.jitse.npclib.events.trigger.TriggerType;
import org.bukkit.ChatColor;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
/**
* @author Jitse Boonstra
*/
public class NPCListener implements Listener {
@EventHandler
public void onNPCSpawn(NPCSpawnEvent event) {
if (event.getTrigger() == TriggerType.AUTOMATIC) {
return;
}
event.getPlayer().sendMessage(ChatColor.GREEN + "Spawned NPC " + event.getNPC().getEntityId());
}
@EventHandler
public void onNPCDestroy(NPCDestroyEvent event) {
if (event.getTrigger() == TriggerType.AUTOMATIC) {
return;
}
event.getPlayer().sendMessage(ChatColor.RED + "Destroyed NPC " + event.getNPC().getEntityId());
}
@EventHandler
public void onNPCInteract(NPCInteractEvent event) {
event.getWhoClicked().sendMessage(ChatColor.BLUE + "Interacted with NPC "
+ event.getNPC().getEntityId() + " type " + event.getClickType());
}
}

@ -8,7 +8,7 @@
<groupId>net.jitse</groupId>
<artifactId>npclib</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
<name>NPCLib</name>
<url>https://github.com/JitseB/npclib</url>

Loading…
Cancel
Save