Compare commits

...

7 Commits
v2.1 ... master

Author SHA1 Message Date
710d2679a6 更新版本
All checks were successful
Java CI-CD with Maven / build (push) Successful in 6m48s
2024-08-24 19:24:26 +08:00
a6a710f671 Merge remote-tracking branch 'origin/master' 2024-08-24 19:18:19 +08:00
dfb821ca23 新增获取图片时的报错提示
All checks were successful
Java CI-CD with Maven / build (push) Successful in 6m54s
2024-08-24 19:17:47 +08:00
9c462690dc 更新 README.md 2024-08-20 20:48:17 +08:00
7744442575 修复启用经济后加载时报错的问题
All checks were successful
Java CI-CD with Maven / build (push) Successful in 22m22s
2024-08-13 15:50:59 +08:00
78bb6c9447 新增图床地址白名单
All checks were successful
Java CI-CD with Maven / build (push) Successful in 12m23s
2024-08-05 16:43:08 +08:00
5896a30928 更新文档 不支持spigot! 2024-07-30 17:34:38 +08:00
7 changed files with 65 additions and 9 deletions

View File

@ -18,9 +18,7 @@
## 说明
本插件大约相当于 [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 核心。
## 功能介绍
@ -31,7 +29,7 @@
## 支持版本
- 1.20.1+ (Spigot、Paper、Folia)
- 1.20.1+ (Paper、Folia)
## 安装方法
@ -76,15 +74,21 @@
### 配置文件参考
```yaml
# 地图画阵列的最大尺寸 宽
MaxFrameX: 32
# 地图画阵列的最大尺寸 高
MaxFrameY: 18
CheckUpdate: true
# 是否启用经济系统 消耗玩家金钱生成地图画
Economy:
Enable: false
CostPerMap: 100.0
CostPerMap: 100.0 # 每张地图画的单价 - 3*3的地图画需要9张地图画 也就是 9*100 = 900
# 图床地址白名单,不在白名单中的图床将无法使用,留空表示不启用地址白名单
AddressWhiteList: []
CheckUpdate: true
Debug: false
```

View File

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

View File

@ -14,8 +14,8 @@ public final class ColorfulMap extends JavaPlugin {
public void onEnable() {
// Plugin startup logic
instance = this;
config = new Configuration(this);
new XLogger(this);
config = new Configuration(this);
XLogger.setDebug(config.isDebug());
new Notification(this);
new Scheduler(this);

View File

@ -4,6 +4,8 @@ import cn.lunadeer.colorfulmap.utils.VaultConnect.VaultConnect;
import cn.lunadeer.colorfulmap.utils.XLogger;
import org.bukkit.configuration.file.FileConfiguration;
import java.util.List;
public class Configuration {
public Configuration(ColorfulMap plugin) {
@ -22,10 +24,12 @@ public class Configuration {
_check_update = _file.getBoolean("CheckUpdate", true);
_economy_enable = _file.getBoolean("Economy.Enable", false);
_price = (float) _file.getDouble("Economy.CostPerMap", 100.0);
_address_white_list = _file.getStringList("AddressWhiteList");
if (_economy_enable) {
XLogger.info("已启用经济系统");
new VaultConnect(_plugin);
}
saveAll();
}
public void saveAll() {
@ -35,6 +39,7 @@ public class Configuration {
_file.set("CheckUpdate", _check_update);
_file.set("Economy.Enable", _economy_enable);
_file.set("Economy.CostPerMap", _price);
_file.set("AddressWhiteList", _address_white_list);
_plugin.saveConfig();
}
@ -98,6 +103,16 @@ public class Configuration {
_plugin.saveConfig();
}
public List<String> getAddressWhiteList() {
return _address_white_list;
}
public void setAddressWhiteList(List<String> address_white_list) {
_address_white_list = address_white_list;
_file.set("AddressWhiteList", address_white_list);
_plugin.saveConfig();
}
private final ColorfulMap _plugin;
private FileConfiguration _file;
private Boolean _debug;
@ -106,4 +121,5 @@ public class Configuration {
private Boolean _check_update;
private Boolean _economy_enable;
private Float _price;
private List<String > _address_white_list;
}

View File

@ -4,6 +4,7 @@ import cn.lunadeer.colorfulmap.ColorfulMap;
import cn.lunadeer.colorfulmap.StorageMaps;
import cn.lunadeer.colorfulmap.utils.ImageTool;
import cn.lunadeer.colorfulmap.utils.Notification;
import cn.lunadeer.colorfulmap.utils.UrlTools;
import cn.lunadeer.colorfulmap.utils.VaultConnect.VaultConnect;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
@ -24,8 +25,16 @@ public class Multi {
public static ItemStack generate(Player player, String url, Float scale) {
try {
if (!UrlTools.isInWhiteList(url)) {
Notification.error(player, "无法生成地图画: 此图床地址不被允许使用");
return null;
}
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

@ -0,0 +1,25 @@
package cn.lunadeer.colorfulmap.utils;
import cn.lunadeer.colorfulmap.ColorfulMap;
public class UrlTools {
public static boolean isInWhiteList(String url) {
if (ColorfulMap.config.getAddressWhiteList().isEmpty()) {
return true;
}
for (String whiteUrl : ColorfulMap.config.getAddressWhiteList()) {
if (url.startsWith(whiteUrl)) {
return true;
}
if (url.startsWith("http://" + whiteUrl)) {
return true;
}
if (url.startsWith("https://" + whiteUrl)) {
return true;
}
}
return false;
}
}

View File

@ -6,6 +6,8 @@ Economy:
Enable: false
CostPerMap: 100.0
AddressWhiteList: []
CheckUpdate: true
Debug: false