mirror of
https://github.com/filoghost/HolographicDisplays.git
synced 2024-11-20 01:15:15 +01:00
Simplify image rendering settings
This commit is contained in:
parent
0cb6fed921
commit
6948afcfa9
@ -10,7 +10,6 @@ import me.filoghost.fcommons.Strings;
|
|||||||
import me.filoghost.fcommons.logging.ErrorCollector;
|
import me.filoghost.fcommons.logging.ErrorCollector;
|
||||||
import me.filoghost.holographicdisplays.common.DebugLogger;
|
import me.filoghost.holographicdisplays.common.DebugLogger;
|
||||||
import me.filoghost.holographicdisplays.plugin.format.DisplayFormat;
|
import me.filoghost.holographicdisplays.plugin.format.DisplayFormat;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
import java.time.DateTimeException;
|
import java.time.DateTimeException;
|
||||||
import java.time.ZoneId;
|
import java.time.ZoneId;
|
||||||
@ -27,7 +26,6 @@ public class Settings {
|
|||||||
|
|
||||||
public static String imageSymbol;
|
public static String imageSymbol;
|
||||||
public static String transparencySymbol;
|
public static String transparencySymbol;
|
||||||
public static ChatColor transparencyColor;
|
|
||||||
|
|
||||||
public static int bungeeRefreshSeconds;
|
public static int bungeeRefreshSeconds;
|
||||||
public static boolean useRedisBungee;
|
public static boolean useRedisBungee;
|
||||||
@ -47,7 +45,6 @@ public class Settings {
|
|||||||
|
|
||||||
imageSymbol = DisplayFormat.apply(config.imageSymbol);
|
imageSymbol = DisplayFormat.apply(config.imageSymbol);
|
||||||
transparencySymbol = DisplayFormat.apply(config.transparencySymbol);
|
transparencySymbol = DisplayFormat.apply(config.transparencySymbol);
|
||||||
transparencyColor = parseTransparencyColor(config.transparencyColor, errorCollector);
|
|
||||||
|
|
||||||
bungeeRefreshSeconds = parseBungeeRefreshInterval(config.bungeeRefreshSeconds, errorCollector);
|
bungeeRefreshSeconds = parseBungeeRefreshInterval(config.bungeeRefreshSeconds, errorCollector);
|
||||||
useRedisBungee = config.useRedisBungee;
|
useRedisBungee = config.useRedisBungee;
|
||||||
@ -90,19 +87,6 @@ public class Settings {
|
|||||||
return timeFormat;
|
return timeFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ChatColor parseTransparencyColor(String transparencyColor, ErrorCollector errorCollector) {
|
|
||||||
transparencyColor = transparencyColor.replace('&', ChatColor.COLOR_CHAR);
|
|
||||||
|
|
||||||
for (ChatColor chatColor : ChatColor.values()) {
|
|
||||||
if (chatColor.toString().equals(transparencyColor)) {
|
|
||||||
return chatColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
errorCollector.add("chat color for transparency in the configuration is not valid, light gray (&7) will be used");
|
|
||||||
return ChatColor.GRAY;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int parseBungeeRefreshInterval(int interval, ErrorCollector errorCollector) {
|
private static int parseBungeeRefreshInterval(int interval, ErrorCollector errorCollector) {
|
||||||
if (interval < 1) {
|
if (interval < 1) {
|
||||||
errorCollector.add("the minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set");
|
errorCollector.add("the minimum interval for pinging BungeeCord's servers is 1 second. It has been automatically set");
|
||||||
|
@ -26,9 +26,6 @@ public class SettingsModel implements MappedConfig {
|
|||||||
@Path("images.transparency.space")
|
@Path("images.transparency.space")
|
||||||
String transparencySymbol = " [|] ";
|
String transparencySymbol = " [|] ";
|
||||||
|
|
||||||
@Path("images.transparency.color")
|
|
||||||
String transparencyColor = "&7";
|
|
||||||
|
|
||||||
@Path("bungee.refresh-seconds")
|
@Path("bungee.refresh-seconds")
|
||||||
int bungeeRefreshSeconds = 3;
|
int bungeeRefreshSeconds = 3;
|
||||||
|
|
||||||
@ -88,7 +85,8 @@ public class SettingsModel implements MappedConfig {
|
|||||||
"using-RedisBungee",
|
"using-RedisBungee",
|
||||||
"bungee-online-format",
|
"bungee-online-format",
|
||||||
"bungee-offline-format",
|
"bungee-offline-format",
|
||||||
"precise-hologram-movement"
|
"precise-hologram-movement",
|
||||||
|
"images.transparency.color"
|
||||||
);
|
);
|
||||||
|
|
||||||
boolean modified = false;
|
boolean modified = false;
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
*/
|
*/
|
||||||
package me.filoghost.holographicdisplays.plugin.image;
|
package me.filoghost.holographicdisplays.plugin.image;
|
||||||
|
|
||||||
|
import me.filoghost.fcommons.Colors;
|
||||||
import me.filoghost.holographicdisplays.plugin.disk.Settings;
|
import me.filoghost.holographicdisplays.plugin.disk.Settings;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -53,35 +54,26 @@ public class ImageMessage {
|
|||||||
|
|
||||||
private List<String> toChatLines(BufferedImage image) {
|
private List<String> toChatLines(BufferedImage image) {
|
||||||
List<String> lines = new ArrayList<>(image.getHeight());
|
List<String> lines = new ArrayList<>(image.getHeight());
|
||||||
ChatColor transparencyColor = Settings.transparencyColor;
|
|
||||||
String transparencySymbol = Settings.transparencySymbol;
|
String transparencySymbol = Settings.transparencySymbol;
|
||||||
String imageSymbol = Settings.imageSymbol;
|
String imageSymbol = Settings.imageSymbol;
|
||||||
|
|
||||||
for (int y = 0; y < image.getHeight(); y++) {
|
for (int y = 0; y < image.getHeight(); y++) {
|
||||||
StringBuilder line = new StringBuilder();
|
StringBuilder line = new StringBuilder();
|
||||||
ChatColor previousColor = null;
|
|
||||||
|
|
||||||
for (int x = 0; x < image.getWidth(); x++) {
|
for (int x = 0; x < image.getWidth(); x++) {
|
||||||
ChatColor currentColor = getClosestChatColor(image, x, y);
|
ChatColor pixelColor = getClosestChatColor(image, x, y);
|
||||||
String symbol;
|
|
||||||
|
|
||||||
if (currentColor == null) {
|
if (pixelColor == null) {
|
||||||
// Use the transparent char
|
// "null" means transparent is the closest color
|
||||||
currentColor = transparencyColor;
|
line.append(ChatColor.RESET);
|
||||||
symbol = transparencySymbol;
|
line.append(transparencySymbol);
|
||||||
} else {
|
} else {
|
||||||
symbol = imageSymbol;
|
line.append(pixelColor);
|
||||||
|
line.append(imageSymbol);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentColor != previousColor) {
|
lines.add(Colors.optimize(line.toString()));
|
||||||
// Append the different color and save it
|
|
||||||
line.append(currentColor);
|
|
||||||
previousColor = currentColor;
|
|
||||||
}
|
|
||||||
line.append(symbol);
|
|
||||||
}
|
|
||||||
|
|
||||||
lines.add(line.toString());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return lines;
|
return lines;
|
||||||
|
Loading…
Reference in New Issue
Block a user