2021-04-19 17:22:15 +02:00
|
|
|
package de.steamwar.bausystem.region;
|
|
|
|
|
2021-04-20 13:46:51 +02:00
|
|
|
import com.sk89q.worldedit.EditSession;
|
|
|
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
|
|
|
import de.steamwar.bausystem.region.loader.RegionLoader;
|
2021-04-19 17:22:15 +02:00
|
|
|
import de.steamwar.bausystem.region.utils.RegionExtensionType;
|
|
|
|
import de.steamwar.bausystem.region.utils.RegionType;
|
2021-04-20 13:46:51 +02:00
|
|
|
import de.steamwar.core.VersionedCallable;
|
2021-04-19 17:22:15 +02:00
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
|
import net.md_5.bungee.api.ChatMessageType;
|
|
|
|
import net.md_5.bungee.api.chat.TextComponent;
|
|
|
|
import org.bukkit.Bukkit;
|
|
|
|
|
2021-04-20 13:46:51 +02:00
|
|
|
import java.io.File;
|
|
|
|
|
2021-04-19 17:22:15 +02:00
|
|
|
@UtilityClass
|
|
|
|
public class RegionUtils {
|
|
|
|
|
|
|
|
public void actionBar(Region region, String s) {
|
|
|
|
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(s)));
|
|
|
|
}
|
|
|
|
|
2021-05-01 10:53:01 +02:00
|
|
|
public static void message(Region region, String s) {
|
|
|
|
Bukkit.getOnlinePlayers().stream().filter(player -> region.inRegion(player.getLocation(), RegionType.NORMAL, RegionExtensionType.NORMAL)).forEach(player -> player.sendMessage(s));
|
|
|
|
}
|
|
|
|
|
2021-04-20 13:46:51 +02:00
|
|
|
static EditSession paste(File file, Point pastePoint, PasteOptions pasteOptions) {
|
|
|
|
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(file, pastePoint, pasteOptions), 15));
|
|
|
|
}
|
|
|
|
|
|
|
|
static EditSession paste(Clipboard clipboard, Point pastePoint, PasteOptions pasteOptions) {
|
|
|
|
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.paste(clipboard, pastePoint, pasteOptions), 15));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void save(Region region) {
|
2021-04-22 19:44:32 +02:00
|
|
|
if (region.getPrototype() != null) {
|
|
|
|
region.regionData.add("prototype", region.getPrototype().getName());
|
|
|
|
}
|
2021-04-20 13:46:51 +02:00
|
|
|
region.regionData.add("flagStorage", FlagStorage.toYAPION(region.getFlagStorage()));
|
|
|
|
RegionLoader.save();
|
|
|
|
}
|
|
|
|
|
2021-04-19 17:22:15 +02:00
|
|
|
}
|