-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: nether npc teleporting
- Loading branch information
Showing
3 changed files
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
src/main/java/me/ShermansWorld/AlathraExtras/npcs/NPCListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package me.ShermansWorld.AlathraExtras.npcs; | ||
|
||
import net.citizensnpcs.api.event.NPCSpawnEvent; | ||
import org.bukkit.event.EventHandler; | ||
|
||
import org.bukkit.event.Listener; | ||
|
||
public class NPCListener implements Listener { | ||
@EventHandler | ||
public void npcSpawnListener(NPCSpawnEvent e) { | ||
if (e.getNPC().getId() == bossItemMerchantNPC.ID){ | ||
bossItemMerchantNPC.teleportMerchant(); | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
src/main/java/me/ShermansWorld/AlathraExtras/npcs/bossItemMerchantNPC.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package me.ShermansWorld.AlathraExtras.npcs; | ||
|
||
import net.citizensnpcs.api.CitizensAPI; | ||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.World; | ||
import org.bukkit.event.player.PlayerTeleportEvent; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Random; | ||
|
||
/** | ||
* Handles code for the boss item merchant, specifically the one for the nether update. | ||
*/ | ||
public class bossItemMerchantNPC{ | ||
public static final int ID = 83; | ||
|
||
/** | ||
* Teleports the merchant to one of their random locations | ||
*/ | ||
public static void teleportMerchant(){ | ||
// Location information | ||
final World world = Bukkit.getWorld("world"); | ||
if (world == null) return; | ||
|
||
ArrayList<Location> locationArrayList = new ArrayList<>(); | ||
locationArrayList.add(new Location(world, -14.5, 109, 157.5)); // | ||
locationArrayList.add(new Location(world, -66.5, 65, -95.5)); // | ||
locationArrayList.add(new Location(world, 109.5, 73, 259.5)); // | ||
locationArrayList.add(new Location(world, 92.5, 121, 70.5)); // | ||
locationArrayList.add(new Location(world, 50.5, 100, 58.5)); // | ||
locationArrayList.add(new Location(world, 7.5, 118, 56.5)); // | ||
locationArrayList.add(new Location(world, 66.5, 111, 31.5)); // | ||
locationArrayList.add(new Location(world, 38.5, 121, 122.5)); // | ||
locationArrayList.add(new Location(world, 95.5, 66, -147.5)); // | ||
locationArrayList.add(new Location(world, -168.5, 64, 111.5)); // | ||
locationArrayList.add(new Location(world, -135.5, 73, 100.5)); // | ||
locationArrayList.add(new Location(world, 95.5, 82, 71.5)); // | ||
|
||
Random random = new Random(); | ||
int newLocationIndex = random.nextInt(locationArrayList.size()); //Pick random location | ||
|
||
//Teleport the npc | ||
CitizensAPI.getNPCRegistry().getById(ID).teleport(locationArrayList.get(newLocationIndex), PlayerTeleportEvent.TeleportCause.COMMAND); | ||
} | ||
} |