Compare commits

..

No commits in common. "5e2355c24e1d99324baae65192497c1a3ec432e7" and "06c738b8549a2a4000623561e0fd0a0eaddec249" have entirely different histories.

24 changed files with 5 additions and 8 deletions

View File

@ -1,6 +1,5 @@
package CoswayUtil; package CoswayUtil;
import org.bukkit.*;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
@ -10,7 +9,10 @@ import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityDeathEvent; import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.World;
import org.bukkit.Location;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -29,11 +31,9 @@ public class WitherContract implements Listener {
public void onWitherSkullPlace(BlockPlaceEvent event) { public void onWitherSkullPlace(BlockPlaceEvent event) {
// Check if the block placed is Wither Skull on Soul Sand // Check if the block placed is Wither Skull on Soul Sand
Block block = event.getBlockPlaced(); Block block = event.getBlockPlaced();
Block blockBellow = block.getLocation().clone().subtract(0,1,0).getBlock(); if (block.getType() == Material.SOUL_SAND && event.getItemInHand().getType() == Material.WITHER_SKELETON_SKULL) {
if (blockBellow.getType() == Material.SOUL_SAND && event.getItemInHand().getType() == Material.WITHER_SKELETON_SKULL) {
Player player = event.getPlayer(); Player player = event.getPlayer();
World world = block.getWorld(); World world = block.getWorld();
plugin.serverMessage("&6Wither Contract has been Activated!");
// Find a random hostile mob within 30 blocks // Find a random hostile mob within 30 blocks
LivingEntity target = findRandomHostileEntity(block.getLocation(), 30); LivingEntity target = findRandomHostileEntity(block.getLocation(), 30);
@ -73,15 +73,12 @@ public class WitherContract implements Listener {
@Override @Override
public void run() { public void run() {
if (target.isDead()) { if (target.isDead()) {
target.getWorld().playEffect(target.getLocation().clone().subtract(0.5,0,0.5),Effect.END_GATEWAY_SPAWN,1);
cancel(); // Stop task if the mob is dead cancel(); // Stop task if the mob is dead
} else { } else {
target.getWorld().playEffect(target.getLocation().clone().subtract(0,0,0),Effect.TRIAL_SPAWNER_BECOME_OMINOUS,1);
target.getWorld().spawnParticle(Particle.DUST, target.getLocation().clone().subtract(0,-2,0), 1, new Particle.DustOptions(Color.RED, 2));
target.damage(1); // Deal 1 damage per tick (20 ticks = 1 second) target.damage(1); // Deal 1 damage per tick (20 ticks = 1 second)
} }
} }
}.runTaskTimer(plugin, 0, 10); // Run every 10 ticks (0.5 second) }.runTaskTimer(plugin, 0, 20); // Run every 20 ticks (1 second)
// Listen for the mob's death and apply curse to nearby mobs // Listen for the mob's death and apply curse to nearby mobs
target.getServer().getPluginManager().registerEvents(new Listener() { target.getServer().getPluginManager().registerEvents(new Listener() {