Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Apocalypse;
- import java.util.HashMap;
- import org.bukkit.Bukkit;
- import org.bukkit.GameMode;
- import org.bukkit.Location;
- import org.bukkit.block.Block;
- import org.bukkit.entity.Player;
- import org.bukkit.plugin.Plugin;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main extends JavaPlugin{
- public static Plugin plugin;
- public static String prefix = "Apocalypse";
- //## PLUGIN ACTIVATION ##
- @Override
- public void onEnable() {
- super.onEnable();
- System.out.println("["+ prefix +"] ##############################");
- System.out.println("["+ prefix +"] Plugin made by Rail");
- System.out.println("["+ prefix +"] ------------------------------");
- System.out.println("["+ prefix +"] <> Activating Plugin <>");
- System.out.println("["+ prefix +"] Starting System..");
- plugin = this;
- repeatingTask();
- System.out.println("["+ prefix +"] - Ok!");
- System.out.println("["+ prefix +"] ##############################");
- }
- //## PLUGIN DEACTIVATION ##
- @Override
- public void onDisable() {
- System.out.println("["+ prefix +"] - Plugin deactivated!");
- }
- //## Plugin GET Method ##
- public static Plugin getPlugin() {
- return plugin;
- }
- static int burnInSeconds = 5;
- static int burnAfterSeconds = 3;
- static HashMap<Player, Integer> timerList = new HashMap<>();
- public void repeatingTask(){
- Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
- {
- @Override
- public void run() // This runs every 5 Ticks (~ 4 Times /second)
- {
- for(Player p : Bukkit.getOnlinePlayers()){ // Cycle thru every Player Online
- if(p.getGameMode() != GameMode.CREATIVE && p.getGameMode() != GameMode.SPECTATOR){ // Filter Creative & Spectator Players
- if(timerList.get(p) != null){ // Catch Errors
- int timer = timerList.get(p);
- boolean isUnderBlock = isUnderBlock(p);
- if(!isUnderBlock){ // Player is not under a Block
- if(timer < 0){ // Set timer (to 'burnAfterSeconds')
- timer = burnAfterSeconds*4;
- timerList.put(p, timer);
- }else if(timer > 0){ // Run timer
- timer--;
- timerList.put(p, timer);
- }else if(timer == 0){ // Timer has reached 0, BURN!! (for 'burnInSeconds')
- p.setFireTicks(burnInSeconds*20);
- }
- }else{ // Player is under a Block
- if(timer >= 0){
- timer = -1; // Stop & Reset Timer
- timerList.put(p, timer);
- }
- }
- }else{
- timerList.put(p, -1); // Put new Player in List (default: timer off)
- }
- }
- }
- }
- }, 20, 5);
- }
- public boolean isUnderBlock(Player p){
- Location loc = p.getLocation();
- Block highestBlock = loc.getWorld().getHighestBlockAt(loc);
- Location locBlock = highestBlock.getLocation();
- double y = loc.getY();
- double yBlock = locBlock.getY();
- if(y < yBlock){
- return true;
- }else{
- return false;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement