Compare commits

..

No commits in common. "master" and "v2.2" have entirely different histories.
master ... v2.2

8 changed files with 5 additions and 116 deletions

View File

@ -18,7 +18,9 @@
## 说明
本插件大约相当于 [ImageFrame](https://github.com/LOOHP/ImageFrame)的简版以及 [ImageMaps](https://github.com/SydMontague/ImageMaps) 的高版本重制版。前者功能丰富不过可能由于项目体量较大对于新版本的兼容较慢后者在1.18 开始就停止了更新,且不支持 Folia 核心。
本插件大约相当于 [ImageFrame](https://github.com/LOOHP/ImageFrame)
的简版以及 [ImageMaps](https://github.com/SydMontague/ImageMaps) 的高版本重制版。前者功能丰富,不过可能由于项目体量较大,对于新版本的兼容较慢,后者在
1.18 开始就停止了更新,切不支持 Folia 核心。
## 功能介绍

View File

@ -6,7 +6,7 @@
<groupId>cn.lunadeer</groupId>
<artifactId>ColorfulMap</artifactId>
<version>2.6</version>
<version>2.2</version>
<packaging>jar</packaging>
<name>ColorfulMap</name>

View File

@ -1,6 +1,5 @@
package cn.lunadeer.colorfulmap;
import cn.lunadeer.colorfulmap.commands.Purge;
import cn.lunadeer.colorfulmap.commands.Reload;
import cn.lunadeer.colorfulmap.commands.ToMap;
import cn.lunadeer.colorfulmap.utils.*;
@ -15,15 +14,14 @@ public final class ColorfulMap extends JavaPlugin {
public void onEnable() {
// Plugin startup logic
instance = this;
new XLogger(this);
config = new Configuration(this);
new XLogger(this);
XLogger.setDebug(config.isDebug());
new Notification(this);
new Scheduler(this);
Objects.requireNonNull(Bukkit.getPluginCommand("tomap")).setExecutor(new ToMap());
Objects.requireNonNull(Bukkit.getPluginCommand("reloadColorfulMap")).setExecutor(new Reload());
Objects.requireNonNull(Bukkit.getPluginCommand("purgeColorfulMap")).setExecutor(new Purge());
Bukkit.getPluginManager().registerEvents(new Events(), this);

View File

@ -122,27 +122,6 @@ public class MapManager implements Listener {
return savedImages.get(world_name.getName()).get(id);
}
public List<Integer> getMapIds(World world) {
if (!savedImages.containsKey(world.getName())) {
return new ArrayList<>();
}
return new ArrayList<>(savedImages.get(world.getName()).keySet());
}
public void removeMap(World world, Integer id) {
if (!savedImages.containsKey(world.getName())) {
return;
}
FileConfiguration config = dataFile.getConfig();
String path = config.getString(world.getName() + "." + id);
if (path == null) {
return;
}
new File(path).delete();
config.set(world.getName() + "." + id, null);
dataFile.saveConfig();
savedImages.get(world.getName()).remove(id);
}
static class MapsFile {

View File

@ -110,34 +110,4 @@ public class StorageMaps {
return null;
}
}
public static void purgeStorageFolder() {
File[] map_folders = new File(data_folder, "maps").listFiles();
if (map_folders == null) {
return;
}
for (File map_folder : map_folders) {
if (!map_folder.isDirectory()) {
continue;
}
File[] files = map_folder.listFiles();
if (files == null) {
return;
}
List<String> filenames = new ArrayList<>();
for (File file : files) {
filenames.add(file.getName());
}
if (filenames.isEmpty()) {
map_folder.delete();
continue;
}
if (!filenames.contains("meta.txt")) {
continue;
}
if (files.length == 3 && filenames.contains("raw.png") && filenames.contains("thumb.png") && filenames.contains("meta.txt")) {
map_folder.delete();
}
}
}
}

View File

@ -1,49 +0,0 @@
package cn.lunadeer.colorfulmap.commands;
import cn.lunadeer.colorfulmap.ColorfulMap;
import cn.lunadeer.colorfulmap.MapManager;
import cn.lunadeer.colorfulmap.StorageMaps;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Item;
import org.bukkit.entity.ItemFrame;
import org.bukkit.inventory.ItemStack;
import org.bukkit.map.MapView;
import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
public class Purge implements CommandExecutor {
@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
ColorfulMap.instance.getServer().getWorlds().forEach(world -> {
List<Integer> worldMapIds = new ArrayList<>();
world.getEntities().forEach(entity -> {
if (!(entity instanceof org.bukkit.entity.ItemFrame)) {
return;
}
ItemFrame itemFrame = (ItemFrame) entity;
if (!itemFrame.getItem().getType().equals(org.bukkit.Material.FILLED_MAP)) {
return;
}
ItemStack item = itemFrame.getItem();
MapView mapView = ((org.bukkit.inventory.meta.MapMeta) item.getItemMeta()).getMapView();
if (mapView == null) {
return;
}
worldMapIds.add(mapView.getId());
});
List<Integer> currentIds = MapManager.instance.getMapIds(world);
for (Integer id : currentIds) {
if (!worldMapIds.contains(id)) {
MapManager.instance.removeMap(world, id);
}
}
});
StorageMaps.purgeStorageFolder();
MapManager.instance.reloadImages();
return true;
}
}

View File

@ -31,10 +31,6 @@ public class Multi {
}
URL _url = new URL(url);
BufferedImage raw_image = ImageIO.read(_url);
if (raw_image == null) {
Notification.error(player, "无法读取有效图片,请检查图片地址是否正确或者更换图床");
return null;
}
BufferedImage resized_image;
if (scale != 1.0) {
resized_image = ImageTool.resize(raw_image, scale);

View File

@ -13,10 +13,6 @@ commands:
description: 重载ColorfulMap配置
usage: /reloadColorfulMap
permission: colorfulmap.reload
purgeColorfulMap:
description: 清除无效的地图画
usage: /purgeColorfulMap
permission: colorfulmap.purge
permissions:
colorfulmap.tomap:
description: 允许使用/tomap命令
@ -24,6 +20,3 @@ permissions:
colorfulmap.reload:
description: 允许使用/reloadColorfulMap命令
default: op
colorfulmap.purge:
description: 允许使用/purgeColorfulMap命令
default: op