This repository has been archived by the owner on Jul 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4e96ed4
commit dc1286a
Showing
2 changed files
with
69 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/java/games/bevs/minecraftbut/senerario/senerarios/SunDeath.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |