Displays animations for all players in the same world
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				KnarCraft/BlacksmithVisuals/pipeline/head This commit looks good
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	KnarCraft/BlacksmithVisuals/pipeline/head This commit looks good
				
			This commit is contained in:
		@@ -1,4 +1,5 @@
 | 
			
		||||
# Blacksmith Visuals
 | 
			
		||||
 | 
			
		||||
This plugin adds additional visual and audial details to blacksmiths while they are working, so it's easier to see if 
 | 
			
		||||
they are working or not. It is recommended to put a mace or other hammer-like item in the NPC's off-hand for full effect.
 | 
			
		||||
This plugin adds additional visual and audial details to blacksmiths while they are working, so it's easier to see if
 | 
			
		||||
they are working or not. It is recommended to put a mace or other hammer-like item in the NPC's off-hand for full
 | 
			
		||||
effect.
 | 
			
		||||
@@ -24,7 +24,6 @@ import org.bukkit.event.Listener;
 | 
			
		||||
import org.bukkit.scheduler.BukkitScheduler;
 | 
			
		||||
import org.jetbrains.annotations.NotNull;
 | 
			
		||||
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
@@ -71,7 +70,7 @@ public class BlacksmithListener implements Listener {
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * A method performing actions required when a blacksmith or scrapper action starts
 | 
			
		||||
     * 
 | 
			
		||||
     *
 | 
			
		||||
     * @param event <p>The event that's starting</p>
 | 
			
		||||
     */
 | 
			
		||||
    private void onActionStart(@NotNull ActionStartEvent event) {
 | 
			
		||||
@@ -93,17 +92,16 @@ public class BlacksmithListener implements Listener {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        List<Entity> nearby = event.getNpc().getEntity().getNearbyEntities(16, 16, 5);
 | 
			
		||||
        nearby.removeIf((entity) -> !(entity instanceof Player));
 | 
			
		||||
        
 | 
			
		||||
        this.playWorkSound(event.getNpc().getEntity());
 | 
			
		||||
        ProtocolManager manager = ProtocolLibrary.getProtocolManager();
 | 
			
		||||
        PacketContainer packet = manager.createPacket(PacketType.Play.Server.ANIMATION);
 | 
			
		||||
        packet.getIntegers().write(0, event.getNpc().getEntity().getEntityId());
 | 
			
		||||
        packet.getIntegers().write(1, 3);
 | 
			
		||||
        
 | 
			
		||||
        for (Entity entity : nearby) {
 | 
			
		||||
            manager.sendServerPacket((Player) entity, packet);
 | 
			
		||||
 | 
			
		||||
        for (Player player : Bukkit.getOnlinePlayers()) {
 | 
			
		||||
            if (player.getWorld().equals(event.getNpc().getEntity().getWorld())) {
 | 
			
		||||
                manager.sendServerPacket(player, packet);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ public final class BlacksmithVisuals extends JavaPlugin {
 | 
			
		||||
    public void onEnable() {
 | 
			
		||||
        // Plugin startup logic
 | 
			
		||||
        getServer().getPluginManager().registerEvents(new BlacksmithListener(), this);
 | 
			
		||||
        
 | 
			
		||||
 | 
			
		||||
        //TODO: Allow customization of sounds, volumes and pitches
 | 
			
		||||
        // Allow setting an idle position and a working position, and move the NPC to the right position at the right time.
 | 
			
		||||
        // Use the distance between the two locations to decide how much sooner before the success/fail sounds are played the NPC should start walking
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user