Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.esinia.server.events;
- import org.spongepowered.api.Sponge;
- import org.spongepowered.api.entity.Entity;
- import org.spongepowered.api.event.Listener;
- import org.spongepowered.api.event.entity.SpawnEntityEvent;
- import org.spongepowered.api.text.Text;
- //Class name and main method
- public class EventSpawnEntity {
- //listener for the event
- @Listener
- //event for when enities spawn
- public void onEntitySpawn(SpawnEntityEvent event) {
- //loops for every entity during the event. Entity variable titled entity is set to each the entity during that specific loop
- for (Entity entity : event.getEntities()){
- //creating string variable with the name of the entity during the loop
- String entityType = entity.getType().getName();
- //if the string variable entityType contains any of the following strings it proceeds
- if(entityType.contains("customnpc") || entityType.contains("item") || entityType.contains("arrow") || entityType.contains("coraliumarrow") || entityType.contains("projectile")){
- //if the previous method is false
- } else{
- //cancels the event
- event.setCancelled(true);
- }
- //Sponge.getServer().getBroadcastChannel().send(Text.of("test"));
- //Sponge.getServer().getBroadcastChannel().send(Text.of(entityType));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement