I want to make Lol Towers that makes 5 Hearts damage when you come in the radius of 7 Blocks but i want it so that you can spawn a tower from a schematic. Maybe i can spawn a armorstand in the middle of the tower that testfor players and shoot something?!
You could try something like this: Code (Text): int radius = 5; for (Entity entity : player.getNearbyEntities(radius, radius, radius)) { if (!(entity instanceof Block)) { continue; } else { ArmorStand stand = (ArmorStand) entity; if (!(stand.isVisible()) && (stand.isCustomNameVisible())) { //Your code } } } I havent tested this so far, so i dont know if this works. Im using it in my plugin, to test, if a player is in range of an ArmorStand.
There are a few options here. 1. Use a BukkitRunnable, check for nearby players every X tick(s), and damage them. 2. Place Guardian's with a special name or metadata in the towers, and let them attack the players. Listen for EntityDamageByEntityEvent, check if they were attacked by the guardians, if so set the damage. 3. Use the PlayerMoveEvent, check if they are near a tower, if so damage them. (Down side to this is that they won't get damaged when they are standing still, so not recommended!)
Blocks aren't entities. You could most likely store your own cooldowns, and cancel the EntityDamageEntityEvents and EntityTargetEvents accordingly.
Code (Text): onEntityDamageByEntity: if damager is a guardian: add guardian to a cooldown set target to null onEntityTarget: if entity is a guardian: if guardian is on cooldown: set target to null
It takes quite some time before the guardian's beam deals damage. The guardian also already has a cooldown by himself. What if he doesn't want a cooldown?
The time between each guardian hit can be timed and returned, and with a little bit of work you can make an all version compatible plugin. If he doesn't want cooldowns (which he said a few posts above that he did want them), he can have fun poking around the NMS class for the guardian for every version. That's his call, I was just trying to offer an NMS-free version, less hassle. I've been working with a lot of NMS lately for my employer, and it's not something that's too enjoyable after searching through the obfuscated blob of fields in every class from one package.
Hint: if you are trying to use nms, have a look at the int field "b" in "EntityGuardian#PathfinderGoalGuardianAttack". It handles the ticks and so the cooldown when the guardian attacks. Edit: by default it has a 10 ticks of warmup and 60 ticks of cooldown if elder and 80 ticks if not.
Ok now I looked into NMS. Well, where can I find this packet?! I cant find it in this wiki: http://wiki.vg/Protocol
It's not a packet and you can't find it anywhere but decompiling the spigot.jar file and looking for the class I above mentioned in the net.minecraft.server package If you don't know what nms is or never done anything like that before I suggest you to find another way as @Msrules123 suggested.