Skip to content
This repository has been archived by the owner on Jul 16, 2021. It is now read-only.

Commit

Permalink
add sun death
Browse files Browse the repository at this point in the history
  • Loading branch information
HeathLoganCampbell committed Feb 8, 2020
1 parent 4e96ed4 commit dc1286a
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 20 deletions.
24 changes: 4 additions & 20 deletions src/main/java/games/bevs/minecraftbut/MinecraftButPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.lang.reflect.Field;

import games.bevs.minecraftbut.senerario.senerarios.*;
import games.bevs.minecraftbut.senerario.senerarios.mathorstop.MathOrStop;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandMap;
Expand All @@ -10,24 +11,6 @@
import games.bevs.minecraftbut.commands.MinecraftButCommand;
import games.bevs.minecraftbut.listeners.WelcomeListener;
import games.bevs.minecraftbut.senerario.ScenerarioManager;
import games.bevs.minecraftbut.senerario.senerarios.AnvilRain;
import games.bevs.minecraftbut.senerario.senerarios.BedRockTrail;
import games.bevs.minecraftbut.senerario.senerarios.BlockPotions;
import games.bevs.minecraftbut.senerario.senerarios.EnderDragonAppears;
import games.bevs.minecraftbut.senerario.senerarios.FasterAndFaster;
import games.bevs.minecraftbut.senerario.senerarios.LinkedDeaths;
import games.bevs.minecraftbut.senerario.senerarios.LinkedHealth;
import games.bevs.minecraftbut.senerario.senerarios.MaducerWorld;
import games.bevs.minecraftbut.senerario.senerarios.MobsMultiple;
import games.bevs.minecraftbut.senerario.senerarios.NoJump;
import games.bevs.minecraftbut.senerario.senerarios.OneHit;
import games.bevs.minecraftbut.senerario.senerarios.RainingBlocks;
import games.bevs.minecraftbut.senerario.senerarios.ShrinkingInventory;
import games.bevs.minecraftbut.senerario.senerarios.TNTOnSelf;
import games.bevs.minecraftbut.senerario.senerarios.TNTRain;
import games.bevs.minecraftbut.senerario.senerarios.TheLavaRises;
import games.bevs.minecraftbut.senerario.senerarios.TheWaterRises;
import games.bevs.minecraftbut.senerario.senerarios.WorldDecay;
import games.bevs.minecraftbut.senerario.senerarios.deathout.DeathOut;
import games.bevs.minecraftbut.senerario.senerarios.gemeater.GemEater;
import games.bevs.minecraftbut.senerario.senerarios.linkedinvs.LinkedInventories;
Expand Down Expand Up @@ -87,9 +70,10 @@ private void populateScenerarios(ButWorld butWorld)
this.scenerarioManager.registerSenerario(new LinkedHealth(butWorld));
this.scenerarioManager.registerSenerario(new ShrinkingInventory(butWorld));
this.scenerarioManager.registerSenerario(new MobsMultiple(butWorld));
this.scenerarioManager.registerSenerario(new SunDeath(butWorld));





if(minecraft18)
{
this.scenerarioManager.registerSenerario(new MathOrStop(butWorld));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
package games.bevs.minecraftbut.senerario.senerarios;

import games.bevs.minecraftbut.senerario.Senerario;
import games.bevs.minecraftbut.world.ButWorld;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.player.PlayerMoveEvent;

public class SunDeath extends Senerario
{

public SunDeath(ButWorld butWorld)
{
super("Sun Death", butWorld, Material.LAVA_BUCKET, new String[] {"You die in the sun"}, "Sprock");
}


@Override
public void onStart()
{
this.repeat(() -> {
for (Player onlinePlayer : Bukkit.getOnlinePlayers())
{
long worldTime = onlinePlayer.getWorld().getTime() % 24_000;
if(!(worldTime > 0 && worldTime < 12_800))
return;

if(onlinePlayer.getGameMode() != GameMode.SURVIVAL)
continue;

if(onlinePlayer.isDead())
continue;

if(this.underSunLight(onlinePlayer))
onlinePlayer.damage(1000000.0);
}
}, 10l);
}

@Override
public void onFinish()
{

}

public boolean underSunLight(Player player)
{
Location loc = player.getLocation();
Block currentBlock = loc.getBlock();
while(currentBlock.getY() < 255)
{
if(currentBlock.getType() != Material.AIR)
return false;
currentBlock = currentBlock.getRelative(BlockFace.UP);
}
return true;
}
}

0 comments on commit dc1286a

Please sign in to comment.