World Reset

Discussion in 'Plugin Development' started by Oh_Tack, Jun 17, 2023.

Thread Status:
Not open for further replies.
  1. Offline


    I'm trying to create a plug-in that resets the world when a player dies in version 1.20.
    paper bukkit

    package oh.example.hardcore;import org.bukkit.Bukkit;import org.bukkit.Location;import org.bukkit.World;import org.bukkit.WorldCreator;import org.bukkit.command.Command;import org.bukkit.command.CommandExecutor;import org.bukkit.command.CommandSender;import org.bukkit.configuration.file.FileConfiguration;import org.bukkit.entity.Player;import;public class ResetCommand implements CommandExecutor {
    private Hardcore plugin; public ResetCommand(Hardcore plugin) {
    this.plugin = plugin;}
    @Overridepublic boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    Player p = (Player) sender;p.sendMessage("실행");FileConfiguration config = plugin.getConfig();World worldtp = Bukkit.getWorld(config.getString("Spawn.World")); double x = config.getDouble("Spawn.X"); double y = config.getDouble("Spawn.Y"); double z = config.getDouble("Spawn.Z"); float yaw = (float) config.getDouble("Spawn.Yaw"); float pitch = (float) config.getDouble("Spawn.Pitch");Location location = new Location(worldtp, x, y, z, yaw, pitch);World world = p.getWorld(); // The world you want to resetfor(Player player : Bukkit.getOnlinePlayers()){

    String worldName = world.getName(); // The world nameif (!Bukkit.unloadWorld(world, false)) return false; // unload the world, return if not successfulFile worldFolder = new File(plugin.getDataFolder().getParentFile().getParentFile(), worldName); // World folderworldFolder.delete(); // Delete world folderBukkit.createWorld(new WorldCreator(worldName)); // Create the worldreturn false;}


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jun 18, 2023
  2. Offline

    timtower Administrator Administrator Moderator

Thread Status:
Not open for further replies.

Share This Page