Skip to content

Commit

Permalink
1.5.6 about-final -> 1.19.3 support; vault cost support.
Browse files Browse the repository at this point in the history
Signed-off-by: LSDog <2509863159@qq.com>
  • Loading branch information
LSDog committed Jan 17, 2023
1 parent 8424722 commit ba5d3be
Show file tree
Hide file tree
Showing 28 changed files with 746 additions and 626 deletions.
125 changes: 70 additions & 55 deletions src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,17 @@ debug: true
# |Debug (Out put image link and file size and log player's spraying)
# 默认|Default: true

msg_prefix: "§3§lCustomSprays >>§r "
msg_prefix: "&3&lCustomSprays >>&r "
# |插件发送消息的前缀
# |Message prefix by plugin
# 默认|Default: "§3§lCustomSprays >>§r "
# 默认|Default: "&3&lCustomSprays >>&r "

check_update: true
# |检查最新版本后发送给op
# |Check the newest version then tell op


############ NUMBER CONFIG #############
############ NUMBER CONFIGS ##############
############ 数字有关的配置 ##############

big_size: 3
Expand Down Expand Up @@ -139,8 +139,19 @@ download_limit: 3
# 默认|Default: 3


spray_cost: 0
# |喷小喷漆所要花的钱 (仅支持 Vault), 设为 0 禁用
# |The money cost for spraying (only support Vault), set to 0 to disable
# 默认|Default: 0

############ BOOLEAN CONFIG #############
spray_big_cost: 0
# |喷大喷漆所要花的钱 (仅支持 Vault), 设为 0 禁用
# |The money cost for big-spraying (only support Vault), set to 0 to disable
# 默认|Default: 0



############ BOOLEAN CONFIGS ##############
############ 填"是否" 的配置 ##############

F_spray: true
Expand All @@ -163,26 +174,26 @@ better_color: true
# If you want to disable bigspray, please set permission "CustomSprays.bigspray" to false


############ STRING CONFIG #############
############ STRING CONFIGS ##############
############ 字符有关的配置 ##############

url_regex: "^https?://.*"
# |url地址匹配的正则表达式 如果不匹配则会发送信息 {配置: Messages.NOT_URL}
# |The regex of url checking Send message if not matches {Config: Messages.NOT_URL}
# 默认|Default: "^https?://.*"

spray_item: "GOLDEN_HORSE_ARMOR" # 1.12 is "GOLD_BARDING"
spray_item: "GOLDEN_HORSE_ARMOR"
# |默认的右键喷漆物品
# |Default item that can spray with right click
# 默认|Default: "GOLD_BARDING"(←1.12) (1.13→)"GOLDEN_HORSE_ARMOR"
# 提示|Tip: 物品名列表,注意区分版本。 | Item name list, note the difference between versions.
# (1.13→): https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java
# (←1.12): https://hub.spigotmc.org/stash/projects/SPIGOT/repos/bukkit/browse/src/main/java/org/bukkit/Material.java?until=7eb6b52fb21699805eab4b074599030861227e64&untilPath=src%2Fmain%2Fjava%2Forg%2Fbukkit%2FMaterial.java

spray_item_lore: "§e§lRight Click To Spray!"
spray_item_lore: "&e&lRight Click To Spray!"
# |喷漆物品需要包含的一行lore, 也可以删掉这项来忽略lore
# |A line of lore that needs to be included in the spray item, you can also delete this to ignore
# 默认|Default: "§e§lRight Click To Spray!"
# 默认|Default: "&e&lRight Click To Spray!"

spray_sound: "default"
# 喷漆音效 | Spray sound
Expand All @@ -192,74 +203,76 @@ spray_sound: "default"

disabled_world: ["示例_世界名", "EXAMPLE_WORLD_NAME"]
# |禁用的世界名称列表,列表中的世界无法喷漆
# |List of disabled world names where prohibits spraying
# |List of disabled worlds where prohibits spraying

disabled_region: ["示例_区域/领地名", "EXAMPLE_REGION_NAME"]
# |禁用的区域名称列表,列表中的区域无法喷漆,可以判断父级领地
# |List of disabled region names where prohibits spraying, able to check parent region
# |可用的插件
# |Available plugins:
# * Residence - 5.0.1.3 <br>
# * WorldGuard - 6.2.2 & 7.0.6 <br>
# |List of disabled regions where prohibits spraying, also able to check parent region
# 可用的插件 | Available plugins:
# * Residence - 5.0.1.3
# * WorldGuard - 6.2.2 & 7.0.6
# * GriefDefender - 2.1.4



############ MESSAGE CONFIG ############
############ 消息有关的配置 ##############
############ MESSAGE CONFIG #############
############ 消息有关的配置 #############

# ⚠ |English messages please scroll down to see|
# ⚠ |English messages please scroll down to see|

# |English version please scroll down|
# |English version please scroll down|
# |所有信息支持 PlaceholderAPI
# |All messages support PlaceholderAPI

# |请注意, 此处不支持"&"作为颜色符号, 请使用"§" (Windows用户提示: Alt按住 + 小键盘:0 1 6 7)
# |Mention that we're not support color code "&", please use "§", (Windows user tip: Alt + NumberKeypad:0 1 6 7)
# |已支持 & 作为颜色代码
# |Color code "&" supported

Messages:
# |所有信息支持 PlaceholderAPI
# |All messages support PlaceholderAPI

UNKNOWN_COMMAND: "未知指令,使用 §3/sprays§r 查看帮助!"
NO_PERMISSION: "§c无权限!"
IN_COOLING: "§c冷却中!"
UNKNOWN_COMMAND: "未知指令,使用 &3/sprays&r 查看帮助!"
NO_PERMISSION: "&c无权限!"
IN_COOLING: "&c冷却中!"

SPRAY:
TOO_MANY_ARGUMENTS: "此为喷漆指令 查看帮助请使用 §b/sprays§r 哦!"
TOO_MANY_ARGUMENTS: "此为喷漆指令 查看帮助请使用 &b/sprays&r 哦!"
NO_IMAGE: "笨蛋! 你还没有上传图片呢!!!"
NO_IMAGE_TIP: "使用 §b/sprays§r §3upload§l <url>§r 来上传图片!"
DISABLED_WORLD: "§7这里... 不可以的哟...❤ (此世界被禁用)"
DISABLED_REGION: "§7这.. 这里不可以呀啊!! (此区域被禁用)"
NO_IMAGE_TIP: "使用 &b/sprays&r &3upload&l <url>&r 来上传图片!"
DISABLED_WORLD: "&7这里... 不可以的哟...❤ (此世界被禁用)"
DISABLED_REGION: "&7这.. 这里不可以呀啊!! (此区域被禁用)"
NO_MONEY: "喂!傻瓜,你根本没带够钱来喷漆!! 这需要 %cost% 元!"
COST: "- %cost%¥ &7(喷漆)"

COMMAND_HELP:
UPLOAD: "上传图片链接 (尺寸§c建议为384*384px§r)"
UPLOAD: "上传图片链接 (尺寸&c建议为384*384px&r)"
COPY: "复制某玩家的图片"
VIEW: "查看某玩家的自定义喷漆"
CHECK: "检查喷漆者"
DELETE: "删除指向的喷漆"
RELOAD: "重载插件"
GETITEM: "获取一个喷漆物品"
TIP: "\n§7TIP: §7§l\"在线图床 和 在线修改图片 很有用哦~\"\n §7§l使用 §e§l/spray §b§l(big)§7 或在 §e§l1.9+版本§b§l(蹲下)§e§l双击F §7来§e§l喷漆§b§l(大)§7! "
TIP: "\n&7TIP: &7&l\"在线图床 和 在线修改图片 很有用哦~\"\n &7&l使用 &e&l/spray &b&l(big)&7 或在 &e&l1.9+版本&b&l(蹲下)&e&l双击F &7来&e&l喷漆&b&l(大)&7! "

COMMAND_UPLOAD:
IN_BUSY: "服务器正忙,请稍后再传......"
NO_URL: "你忘了写图片的地址了! 笨蛋!!"
NOT_URL: "你给的URL完全无效啊! 笨蛋!!!!"
CONNECT_FAILED: "url连接失败了!"
CONNECT_HTTPS_FAILED: "如果你提供的是§e§l https§r 那么可以改成§e§l http§r 链接尝试!"
FILE_TOO_BIG: "你提供的文件太大了! 有足足{size}K! §7(最大可以上传 §f§l{limit}k§r§7 的图片!)"
CANT_GET_SIZE: "我们无法获取文件的大小!\n 请换一个以图片后缀§7(.png/.jpg/.jpeg)§r结尾的url试试吧......"
UPLOADING: "§7加载中... 请稍候......"
CONNECT_HTTPS_FAILED: "如果你提供的是&e&l https&r 那么可以改成&e&l http&r 链接尝试!"
FILE_TOO_BIG: "你提供的文件太大了! 有足足{size}K! &7(最大可以上传 &f&l{limit}k&r&7 的图片!)"
CANT_GET_SIZE: "我们无法获取文件的大小!\n 请换一个以图片后缀&7(.png/.jpg/.jpeg)&r结尾的url试试吧......"
UPLOADING: "&7加载中... 请稍候......"
FAILED_GET_IMAGE: "获取文件失败! 可恶!!!"
OK: "喷图图案保存成功!\n"

COMMAND_VIEW:
NO_PLAYER: "查无此人啦..."
PLAYER_NO_IMAGE: " 还没有上传图片呢!"
WARN: "§7注意: 这是个假物品"
WARN: "&7注意: 这是个假物品"

COMMAND_COPY:
HELP: "\n | /§7sprays copy§r§l <Player> §r§7- 复制某个玩家的喷漆\n | /§7sprays copy§r§l x §r§7- 禁止他人复制你的图片\n | /§7sprays copy§r§l o §r§7- 允许他人复制你的图片"
HELP: "\n | /&7sprays copy&r&l <Player> &r&7- 复制某个玩家的喷漆\n | /&7sprays copy&r&l x &r&7- 禁止他人复制你的图片\n | /&7sprays copy&r&l o &r&7- 允许他人复制你的图片"
NO_PLAYER: "查无此人啦..."
COPY_SELF: "§7...你是不是很无聊啊"
COPY_SELF: "&7...你是不是很无聊啊"
NOT_ALLOW: " 不允许复制图片!"
PLAYER_NO_IMAGE: " 还没有上传图片呢!"
OK: "喷图图案复制成功!嘿嘿~\n"
Expand All @@ -277,48 +290,50 @@ Messages:
# # |所有信息支持 PlaceholderAPI
# # |All messages support PlaceholderAPI
#
# UNKNOWN_COMMAND: "Unkown command,please use §3/sprays§r to find helps!"
# NO_PERMISSION: "§cNo permission!"
# IN_COOLING: "§cCooling!"
# UNKNOWN_COMMAND: "Unkown command,please use &3/sprays&r to find helps!"
# NO_PERMISSION: "&cNo permission!"
# IN_COOLING: "&cCooling!"
#
# SPRAY:
# TOO_MANY_ARGUMENTS: "This command is for spraying. Please use the §b/sprays§r !"
# TOO_MANY_ARGUMENTS: "This command is for spraying. Please use the &b/sprays&r !"
# NO_IMAGE: "Sorry! You haven't uploaded the image yet."
# NO_IMAGE_TIP: "Please use §b/sprays§r §3upload§l <url>§r to upload your image!"
# DISABLED_WORLD: "§7Sorry! This world has been disabled!"
# DISABLED_REGION: "§7Sorry! This region has been disabled!"
# NO_IMAGE_TIP: "Please use &b/sprays&r &3upload&l <url>&r to upload your image!"
# DISABLED_WORLD: "&7Sorry! This world has been disabled!"
# DISABLED_REGION: "&7Sorry! This region has been disabled!"
# NO_MONEY: "Hey!You don't have enough money! It costs %cost%$ !"
# COST: "- %cost%$ &7(spray)"
#
# COMMAND_HELP:
# UPLOAD: "Upload image link (Size:§cBetter be 384*384px§r)"
# UPLOAD: "Upload image link (Size:&cBetter be 384*384px&r)"
# COPY: "Copy the image from a player"
# VIEW: "View player's custom spray."
# CHECK: "Check the sprayer."
# DELETE: "Delete the spray you point at."
# RELOAD: "Reload the plugin."
# GETITEM: "Get a spray item."
# TIP: "\n§7TIP: §7§l\"Image Hosting Website and Online Pictures Modifying are useful~\"\n §7§lUse §e§l/spray §b§l(big)§7 or Double click 'F' §b§l(in snaking) in §e§l1.9+ §7to §e§lspray §b§l(big)§7!"
# TIP: "\n&7TIP: &7&l\"Image Hosting Website and Online Pictures Modifying are useful~\"\n &7&lUse &e&l/spray &b&l(big)&7 or Double click 'F' &b&l(in snaking) in &e&l1.9+ &7to &e&lspray &b&l(big)&7!"
#
# COMMAND_UPLOAD:
# IN_BUSY: "Server in busy, please upload later!"
# NO_URL: "Hey! You forgot to write the image url!"
# NOT_URL: "Sorry! The url is invalid!"
# CONNECT_FAILED: "oops, an error occurred while linking the image!"
# CONNECT_HTTPS_FAILED: "If your are using the URL that starts with §e§l https§r ,please try §e§l http§r!"
# FILE_TOO_BIG: "The size of image is too big! Its {size}K! §7(Up to §f§l{limit}k§r§7 can be uploaded!)"
# CANT_GET_SIZE: "We couldn't get the size of the image!\n Please change the URL that ending in §7(.png/.jpg/.jpeg)§r......"
# UPLOADING: "§7Loading... Please wait for a while..."
# CONNECT_HTTPS_FAILED: "If your are using the URL that starts with &e&l https&r ,please try &e&l http&r!"
# FILE_TOO_BIG: "The size of image is too big! Its {size}K! &7(Up to &f&l{limit}k&r&7 can be uploaded!)"
# CANT_GET_SIZE: "We couldn't get the size of the image!\n Please change the URL that ending in &7(.png/.jpg/.jpeg)&r......"
# UPLOADING: "&7Loading... Please wait for a while..."
# FAILED_GET_IMAGE: "Oops! An error occurred while downloading the image!"
# OK: "Success! The image has been saved! \n"
#
# COMMAND_VIEW:
# NO_PLAYER: "No player found..."
# PLAYER_NO_IMAGE: "baka! You haven't uploaded the image yet!"
# WARN: "§7Warning: This is a fake item."
# WARN: "&7Warning: This is a fake item."
#
# COMMAND_COPY:
# HELP: "\n | /§7sprays copy§r§l <Player> §r§7-§r Copy some one's image\n | /§7sprays copy§r§l x §r§7-§r deny others copying your image\n | /§7sprays copy§r§l o §r§7-§r allow others copying your image"
# HELP: "\n | /&7sprays copy&r&l <Player> &r&7-&r Copy some one's image\n | /&7sprays copy&r&l x &r&7-&r deny others copying your image\n | /&7sprays copy&r&l o &r&7-&r allow others copying your image"
# NO_PLAYER: "No player found..."
# COPY_SELF: "§7... do you really know that you are making a big trouble?"
# COPY_SELF: "&7... do you really know that you are making a big trouble?"
# NOT_ALLOW: " doesn't allow copying the image!"
# PLAYER_NO_IMAGE: " haven't uploaded the image yet!"
# OK: "Image has been copied! ho~ ho~\n"
Expand All @@ -327,4 +342,4 @@ Messages:

# |Checking compatibility, take care of this (✿◕‿◕✿)
# |检测配置兼容性,别乱改喔 (づ ̄3 ̄)づ
configVersion: 1.6
configVersion: 1.7
38 changes: 11 additions & 27 deletions src/fun/LSDog/CustomSprays/CustomSprays.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import fun.LSDog.CustomSprays.commands.CommandSpray;
import fun.LSDog.CustomSprays.data.DataManager;
import fun.LSDog.CustomSprays.map.MapViewId;
import fun.LSDog.CustomSprays.metrics.Metrics;
import fun.LSDog.CustomSprays.utils.MapColors;
import fun.LSDog.CustomSprays.utils.NMS;
import fun.LSDog.CustomSprays.utils.UpdateChecker;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
Expand All @@ -17,22 +17,21 @@

public class CustomSprays extends JavaPlugin {

public static CustomSprays instant;
public CustomSprays() { instant = this; }
public static final double LEAST_CONFIG_VERSION = 1.7;
public static CustomSprays instance;

public static String prefix = "§3§lCustomSprays >>§r ";
private static String version = null;
private static int subVer = 0;

public File config = new File(getDataFolder() + File.separator + "config.yml");
public File playerDataFolder = new File(getDataFolder() + File.separator + "playerData");
public CustomSprays() { instance = this; }

public static String latestVersion = null;

@Override
public void onDisable() {
try { // ↓ SpraysManager.removeAllSpray();
Class.forName("fun.LSDog.CustomSprays.spray.SpraysManager").getMethod("removeAllSpray").invoke(null);
Class.forName("fun.LSDog.CustomSprays.spray.SprayManager").getMethod("removeAllSpray").invoke(null);
} catch (Exception ignored) { }
// cancel async tasks
Bukkit.getScheduler().getActiveWorkers().forEach(bukkitWorker -> {
Expand All @@ -48,7 +47,7 @@ public void onEnable() {
saveDefaultConfig();
} else {
//TODO 每次更迭配置版本的时候别忘了改这里!!
if (YamlConfiguration.loadConfiguration(config).getDouble("configVersion") < 1.6) {
if (YamlConfiguration.loadConfiguration(config).getDouble("configVersion") < LEAST_CONFIG_VERSION) {
log("\n\n\n\n\n\n\n=====================\n");
log("| 检测到不支持的配置!请删除 config.yml 重新配置!");
log("| Unsupported config detected! please delete config.yml and re-config me! \n");
Expand All @@ -73,13 +72,13 @@ public void onEnable() {
getCommand("spray").setExecutor(new CommandSpray());

// 检测条件并启用 双击F 喷漆
if (getSubVer() >= 9 && getConfig().getBoolean("F_spray")) {
if (NMS.getSubVer() >= 9 && getConfig().getBoolean("F_spray")) {
Bukkit.getPluginManager().registerEvents(new Events(), this);
log("§8[F_spray] enabled.");
}

// 1.13 及以上 MapView 支持int
if (getSubVer() >= 13) {
if (NMS.getSubVer() >= 13) {
MapViewId.setNumbers(-2048_000_000,-2048_000_999);
}

Expand All @@ -88,7 +87,7 @@ public void onEnable() {
new Metrics(this, 13633);

if (getConfig().getBoolean("check_update")) Bukkit.getScheduler().runTaskAsynchronously(this, () -> {
String nVersion = CustomSprays.instant.getDescription().getVersion();
String nVersion = CustomSprays.instance.getDescription().getVersion();
String lVersion = UpdateChecker.check();
if (lVersion == null) return;
if (nVersion.equals(lVersion)) return;
Expand All @@ -101,27 +100,12 @@ public void onEnable() {
if (!MapColors.loadColorPalette()) {
MapColors.calculateColorPalette();
} else {
log("Color Palette Loaded! :" + MapColors.isColorPaletteAvailable());
log("Color Palette Loaded! current state: " + MapColors.isColorPaletteAvailable());
}
}
});

log("§eCustomSprays§r Enabled! plugin by §b§lLSDog§r."+" §8(Running on "+getMcVer()+")");
}

/**
* 返回 NMS 版本 (例如 v1_12_R1)
*/
public static String getMcVer() {
return version == null ? version = Bukkit.getServer().getClass().getPackage().getName().split("\\.")[3] : version;
}

/**
* 返回版本号的第二项<br>
* v1_12_R1 -> 12
*/
public static int getSubVer() {
return subVer == 0 ? subVer = Integer.parseInt(getMcVer().split("_")[1]) : subVer;
log("§eCustomSprays§r Enabled! plugin by §b§lLSDog§r."+" §8(Running on "+ NMS.getMcVer()+")");
}

public static void log(Object object) {
Expand Down
15 changes: 7 additions & 8 deletions src/fun/LSDog/CustomSprays/CustomSpraysAPI.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package fun.LSDog.CustomSprays;

import fun.LSDog.CustomSprays.data.DataManager;
import fun.LSDog.CustomSprays.spray.Spray;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;

Expand All @@ -19,14 +18,14 @@ public class CustomSpraysAPI {
* @see fun.LSDog.CustomSprays.CustomSprays
*/
public static Plugin getPlugin() {
return CustomSprays.instant;
return CustomSprays.instance;
}

/**
* Get the manager of sprays
* @see fun.LSDog.CustomSprays.spray.SpraysManager
* Let player spray his/her image
*/
public static class SpraysManager extends fun.LSDog.CustomSprays.spray.SpraysManager {
public static void spray(Player player, boolean isBigSpray) {
fun.LSDog.CustomSprays.spray.SprayManager.spray(player, isBigSpray);
}

/**
Expand All @@ -37,10 +36,10 @@ public static class ImageUtil extends fun.LSDog.CustomSprays.utils.ImageUtil {
}

/**
* Let player spray his/her image
* Get the manager of sprays
* @see fun.LSDog.CustomSprays.spray.SprayManager
*/
public static void spray(Player player, boolean isBigSpray) {
Spray.spray(player, isBigSpray);
public static class SprayManager extends fun.LSDog.CustomSprays.spray.SprayManager {
}

/**
Expand Down
Loading

0 comments on commit ba5d3be

Please sign in to comment.