For v1.1.4.
Fixed the usage of NPCLib as a plugin dependency without shading it.
This commit is contained in:
parent
d3af2fa9ae
commit
15335c24f1
|
@ -20,6 +20,7 @@ Alternatively, you can help the project by starring the repository or telling ot
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
It is recommended to shade `NPCLib-API-v*.jar` into your plugin.
|
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).
|
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.show(player);
|
||||||
npc.hide(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();
|
npc.destroy();
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib</artifactId>
|
<artifactId>npclib</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-api</artifactId>
|
<artifactId>npclib-api</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib</artifactId>
|
<artifactId>npclib</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-commons</artifactId>
|
<artifactId>npclib-commons</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib</artifactId>
|
<artifactId>npclib</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_10_R1</artifactId>
|
<artifactId>npclib-nms-v1_10_R1</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_11_R1</artifactId>
|
<artifactId>npclib-nms-v1_11_R1</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_12_R1</artifactId>
|
<artifactId>npclib-nms-v1_12_R1</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_8_R1</artifactId>
|
<artifactId>npclib-nms-v1_8_R1</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_8_R2</artifactId>
|
<artifactId>npclib-nms-v1_8_R2</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_8_R3</artifactId>
|
<artifactId>npclib-nms-v1_8_R3</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_9_R1</artifactId>
|
<artifactId>npclib-nms-v1_9_R1</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib-nms</artifactId>
|
<artifactId>npclib-nms</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-nms-v1_9_R2</artifactId>
|
<artifactId>npclib-nms-v1_9_R2</artifactId>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib</artifactId>
|
<artifactId>npclib</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>npclib-plugin</artifactId>
|
<artifactId>npclib-plugin</artifactId>
|
||||||
|
|
|
@ -4,82 +4,20 @@
|
||||||
|
|
||||||
package net.jitse.npclib.plugin;
|
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 org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Jitse Boonstra
|
* @author Jitse Boonstra
|
||||||
*/
|
*/
|
||||||
public class NPCLibPlugin extends JavaPlugin implements Listener {
|
public class NPCLibPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private NPCLib npcLib;
|
|
||||||
private NPC npc;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
this.npcLib = new NPCLib(this);
|
getLogger().info("NPC library loaded.");
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable() {
|
public void onDisable() {
|
||||||
if (npc != null) {
|
getLogger().info("NPC library unloaded.");
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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());
|
|
||||||
}
|
|
||||||
}
|
|
2
pom.xml
2
pom.xml
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<groupId>net.jitse</groupId>
|
<groupId>net.jitse</groupId>
|
||||||
<artifactId>npclib</artifactId>
|
<artifactId>npclib</artifactId>
|
||||||
<version>1.1.3</version>
|
<version>1.1.4</version>
|
||||||
|
|
||||||
<name>NPCLib</name>
|
<name>NPCLib</name>
|
||||||
<url>https://github.com/JitseB/npclib</url>
|
<url>https://github.com/JitseB/npclib</url>
|
||||||
|
|
Loading…
Reference in New Issue