Newer
Older
ChallengeSystem / src / main / java / net / brennholz / challenges / Reset_Command.java
@fantahund fantahund on 14 Jan 2020 1 KB Logblock Cleanup
package net.brennholz.challenges;



import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class Reset_Command implements CommandExecutor {

	private Challenges chl = Challenges.getplugin();
	Backpack backpack;

	@Override
	public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
		 {
			
		}
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lb clearlog all world world");
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lb clearlog all world world_nether");
		Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "lb clearlog all world world_the_end");
		
		chl.getConfig().set("World_Name", Bukkit.getWorlds().get(0).getName());
		chl.getConfig().set("World_Reset", true);
		chl.getConfig().set("timer.enabled", false);
		chl.getConfig().set("timer.time", 0);
		chl.getConfig().set("timer.sek", "00");
		chl.getConfig().set("timer.min", "00");
		chl.getConfig().set("timer.hrs", 0);
		for (String key : chl.getConfig().getConfigurationSection("Saved_Locations").getKeys(false)) {
			chl.getConfig().set("Saved_Locations." + key, null);
		}
		chl.saveConfig();

		Bukkit.getScheduler().scheduleSyncDelayedTask(chl, new Runnable() {
			@Override
			public void run() {
				for (Player p : Bukkit.getOnlinePlayers()) {
					p.sendTitle("§aWelt wird zurückgesetzt!", "§cBitte warte einen Moment§a.§b.§e.", 10, 400, 10);
					p.kickPlayer("§cWelt wird zurückgesetzt!\n§cBitte warte einen Moment...");
				}
				ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
				Bukkit.dispatchCommand(console, "restart");
			}
		}, 60);
		return true;
	}
}