Untitled

mail@pastecode.io avatar
unknown
plain_text
7 months ago
1.7 kB
0
Indexable
Never
package org.lifestealsmp.deadlydisasters;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;

public class Main extends JavaPlugin{
	
    List<String> disasterTypes = Arrays.asList("acidstorm", "blizzard", "cavein", "doomsday", 
    		"earthquake", "extremewinds", "geyser", "hurricane", "meteorshowers", "plague", 
    		"purge", "sinkhole", "soulstorm", "supernova", "tornado", "tsunami");
    
    int disasterCount = 0;
    int count = 1;
    int amount = 0;
	
	@Override
    public void onEnable() {
		Collections.shuffle(disasterTypes);
		Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
			public void run() {
	            String currentDisaster = disasterTypes.get(disasterCount % disasterTypes.size());
	            
	            // Pre-construct the command strings for each player
	            List<String> commands = new ArrayList<>();
	            for (Player player : Bukkit.getOnlinePlayers()) {
	                commands.add("disasters start " + currentDisaster + " " + count + " " + player.getName());
	            }

	            // Dispatch commands in quick succession
	            for (String command : commands) {
	                Bukkit.dispatchCommand(Bukkit.getConsoleSender(), command);
	            }
	            
				disasterCount++;
				if(amount == 15) {
					amount = 0;
					if(count != 6) {
						count++;
					}
				} else {
					amount++;
				}
			}
		}, (20 * 60) * 3, (20 * 60) * 3);
	}
}
Leave a Comment