Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.List;
- import org.bukkit.Location;
- import org.bukkit.World;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.EntityType;
- import org.bukkit.plugin.java.JavaPlugin;
- public final class TestPlugin extends JavaPlugin{
- private int burnStartTime = 23750;
- private int burnEndTime = 12750;
- private int updateFrequency = 1000;
- private boolean burnPlayer = false;
- private boolean burnSpider = true;
- private boolean burnCreeper = true;
- private boolean burnEnderman = true;
- private World world = getServer().getWorld(getName());
- public void main(String[]args)
- {
- burnMobs(world);
- }
- public final class BurningMobs
- extends JavaPlugin
- {
- }
- public boolean isDayTime(long time)
- {
- int trueTime = (int)(time % 24000L);
- if (trueTime < 0) {
- trueTime += 24000;
- }
- int start = this.burnStartTime;
- int end = this.burnEndTime;
- if (start < end) {
- return (start < trueTime) && (trueTime < end);
- }
- return (start < trueTime) || (trueTime < end);
- }
- private void burnMobs(World w)
- {
- if (w == null) {
- return;
- }
- List<Entity> entities = new ArrayList<Entity>(w.getLivingEntities());
- for (Entity e : entities) {
- if (isDayTime(w.getTime()) == true);
- if (shouldForceBurnEntityType(e.getType()))
- {
- Location loc = e.getLocation();
- if (loc.getBlockY() >= w.getHighestBlockYAt(loc)) {
- e.setFireTicks(updateFrequency * 20 / 1000);
- }
- }
- }
- }
- private boolean shouldForceBurnEntityType(EntityType type)
- {
- if (type == null) {
- return false;
- }
- if (type.equals(EntityType.CREEPER)) {
- return this.burnCreeper;
- }
- if (type.equals(EntityType.SPIDER)) {
- return this.burnSpider;
- }
- if (type.equals(EntityType.ENDERMAN)) {
- return this.burnEnderman;
- }
- if (type.equals(EntityType.PLAYER)) {
- return this.burnPlayer;
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment