Skip to content

Commit 557777f

Browse files
committed
refactored code and removed kicking when world is deleted
1 parent 7d739bd commit 557777f

4 files changed

Lines changed: 684 additions & 680 deletions

File tree

src/main/java/de/idiotischeryt/buildSystem/BuildManager.java

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import net.kyori.adventure.text.Component;
55
import net.kyori.adventure.text.format.NamedTextColor;
66
import net.kyori.adventure.text.format.TextDecoration;
7+
import net.kyori.adventure.title.Title;
78
import org.bukkit.Bukkit;
89
import org.bukkit.Location;
910
import org.bukkit.World;
@@ -20,10 +21,7 @@
2021
import java.io.IOException;
2122
import java.nio.file.*;
2223
import java.nio.file.attribute.BasicFileAttributes;
23-
import java.util.ArrayList;
24-
import java.util.Arrays;
25-
import java.util.List;
26-
import java.util.Map;
24+
import java.util.*;
2725

2826
public class BuildManager {
2927
public static void createWorld(Player p, String mapName, String minigame, boolean empty, Biome biome, boolean spawnMobs, boolean dayNightCycle, boolean weatherCycle) throws IOException, InvalidConfigurationException {
@@ -52,10 +50,21 @@ public static void createWorld(Player p, String mapName, String minigame, boolea
5250
}
5351

5452
public static void delete(@NotNull World world) {
55-
world.getPlayers().forEach(player ->
56-
player.kick(Component.text("World is getting deleted!")
57-
.decorate(TextDecoration.BOLD)
58-
.color(NamedTextColor.DARK_RED))
53+
world.getPlayers().forEach(player -> {
54+
player.teleport(
55+
Objects.requireNonNull(Bukkit.getWorld("world")).getSpawnLocation()
56+
);
57+
player.showTitle(Title.title(
58+
Component.text("World is getting")
59+
.color(NamedTextColor.DARK_RED)
60+
.decorate(TextDecoration.BOLD),
61+
Component.text("deleted")
62+
.color(NamedTextColor.DARK_RED)
63+
.decorate(TextDecoration.BOLD)
64+
));
65+
66+
67+
}
5968
);
6069

6170
Bukkit.getScheduler().runTask(BuildSystem.getInstance(), () -> {

src/main/java/de/idiotischeryt/buildSystem/command/BuildCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
5959

6060
String map = names[0];
6161
String minigame = names[1];
62-
62+
6363
if (args.length == 5) {
6464
String value2 = args[3];
6565
String value3 = args[4];
@@ -114,6 +114,11 @@ public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command
114114
String key = args[1];
115115
String[] names = BuildManager.namesByWorld(p.getWorld());
116116

117+
if (names == null) {
118+
commandSender.sendMessage(BuildSystem.prefix().append(Component.text("Can't find your world as build world. Please go into the right world!").color(NamedTextColor.DARK_RED)));
119+
return false;
120+
}
121+
117122
FileConfiguration config = new YamlConfiguration();
118123
Path dataFolder = Paths.get(BuildSystem.getInstance().getDataPath().toString(), names[1]);
119124
if (Files.notExists(dataFolder)) Files.createDirectories(dataFolder);

0 commit comments

Comments
 (0)