9
0
mirror of https://github.com/Xiao-MoMi/Custom-Nameplates.git synced 2025-12-21 16:09:32 +00:00
This commit is contained in:
XiaoMoMi
2024-10-08 03:32:11 +08:00
parent 047852eed9
commit a424c3345a
20 changed files with 39 additions and 59 deletions

View File

@@ -21,10 +21,10 @@ public enum StorageType {
JSON, JSON,
YAML, YAML,
H2, H2,
SQLite, SQLITE,
MySQL, MYSQL,
MariaDB, MARIADB,
MongoDB, MONGODB,
Redis, Redis,
NONE NONE
} }

View File

@@ -303,13 +303,13 @@ public class PlaceholderManagerImpl implements PlaceholderManager {
Image empty = requireNonNull(plugin.getImageManager().imageById(inner.getString("images.empty")), "image.empty should not be null"); Image empty = requireNonNull(plugin.getImageManager().imageById(inner.getString("images.empty")), "image.empty should not be null");
Image half = requireNonNull(plugin.getImageManager().imageById(inner.getString("images.half")), "image.half should not be null"); Image half = requireNonNull(plugin.getImageManager().imageById(inner.getString("images.half")), "image.half should not be null");
Image full = requireNonNull(plugin.getImageManager().imageById(inner.getString("images.full")), "image.full should not be null"); Image full = requireNonNull(plugin.getImageManager().imageById(inner.getString("images.full")), "image.full should not be null");
String currentValue = section.getString("placeholder.value", "1"); String currentValue = inner.getString("placeholder.value", "1");
String maxValue = section.getString("placeholder.max-value", currentValue); String maxValue = inner.getString("placeholder.max-value", currentValue);
VanillaHud vanillaHud = new VanillaHud(empty, half, full, reverse, currentValue, maxValue); VanillaHud vanillaHud = new VanillaHud(empty, half, full, reverse, currentValue, maxValue);
List<PreParsedDynamicText> list = List.of(vanillaHud.getCurrent(), vanillaHud.getMax()); List<PreParsedDynamicText> list = List.of(vanillaHud.getCurrent(), vanillaHud.getMax());
Placeholder placeholder1 = registerSharedPlaceholder("%shared_np_vanilla_" + id + "%", vanillaHud::create); Placeholder placeholder1 = registerSharedPlaceholder("%shared_np_vanilla_" + id + "%", vanillaHud::create);
Placeholder placeholder2 = registerPlayerPlaceholder("%np_vanilla_" + id + "%", vanillaHud::create); Placeholder placeholder2 = registerPlayerPlaceholder("%np_vanilla_" + id + "%", vanillaHud::create);
Placeholder placeholder3 = registerRelationalPlaceholder("%np_vanilla_" + id + "%", vanillaHud::create); Placeholder placeholder3 = registerRelationalPlaceholder("%rel_np_vanilla_" + id + "%", vanillaHud::create);
childrenText.put(placeholder1, list); childrenText.put(placeholder1, list);
childrenText.put(placeholder2, list); childrenText.put(placeholder2, list);
childrenText.put(placeholder3, list); childrenText.put(placeholder3, list);

View File

@@ -27,6 +27,7 @@ import org.jetbrains.annotations.NotNull;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.Executor; import java.util.concurrent.Executor;
@@ -111,7 +112,7 @@ public class StorageManagerImpl implements StorageManager, JoinQuitListener {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
// Check if storage type has changed and reinitialize if necessary // Check if storage type has changed and reinitialize if necessary
StorageType storageType = StorageType.valueOf(config.getString("data-storage-method", "H2")); StorageType storageType = StorageType.valueOf(config.getString("data-storage-method", "H2").toUpperCase(Locale.ENGLISH));
if (storageType != previousType) { if (storageType != previousType) {
if (this.dataSource != null) this.dataSource.disable(); if (this.dataSource != null) this.dataSource.disable();
this.previousType = storageType; this.previousType = storageType;
@@ -119,10 +120,10 @@ public class StorageManagerImpl implements StorageManager, JoinQuitListener {
case H2 -> this.dataSource = new H2Provider(plugin); case H2 -> this.dataSource = new H2Provider(plugin);
case JSON -> this.dataSource = new JsonProvider(plugin); case JSON -> this.dataSource = new JsonProvider(plugin);
case YAML -> this.dataSource = new YAMLProvider(plugin); case YAML -> this.dataSource = new YAMLProvider(plugin);
case SQLite -> this.dataSource = new SQLiteProvider(plugin); case SQLITE -> this.dataSource = new SQLiteProvider(plugin);
case MySQL -> this.dataSource = new MySQLProvider(plugin); case MYSQL -> this.dataSource = new MySQLProvider(plugin);
case MariaDB -> this.dataSource = new MariaDBProvider(plugin); case MARIADB -> this.dataSource = new MariaDBProvider(plugin);
case MongoDB -> this.dataSource = new MongoDBProvider(plugin); case MONGODB -> this.dataSource = new MongoDBProvider(plugin);
case NONE -> this.dataSource = new DummyStorage(plugin); case NONE -> this.dataSource = new DummyStorage(plugin);
} }
if (this.dataSource != null) this.dataSource.initialize(config); if (this.dataSource != null) this.dataSource.initialize(config);

View File

@@ -94,7 +94,7 @@ public class MongoDBProvider extends AbstractStorage {
@Override @Override
public StorageType storageType() { public StorageType storageType() {
return StorageType.MongoDB; return StorageType.MONGODB;
} }
@Override @Override

View File

@@ -21,14 +21,14 @@ public abstract class AbstractHikariDatabase extends AbstractSQLDatabase {
public AbstractHikariDatabase(CustomNameplates plugin) { public AbstractHikariDatabase(CustomNameplates plugin) {
super(plugin); super(plugin);
this.driverClass = storageType() == StorageType.MariaDB ? "org.mariadb.jdbc.Driver" : "com.mysql.cj.jdbc.Driver"; this.driverClass = storageType() == StorageType.MARIADB ? "org.mariadb.jdbc.Driver" : "com.mysql.cj.jdbc.Driver";
this.sqlBrand = storageType() == StorageType.MariaDB ? "MariaDB" : "MySQL"; this.sqlBrand = storageType() == StorageType.MARIADB ? "MariaDB" : "MySQL";
try { try {
Class.forName(this.driverClass); Class.forName(this.driverClass);
} catch (ClassNotFoundException e1) { } catch (ClassNotFoundException e1) {
if (storageType() == StorageType.MariaDB) { if (storageType() == StorageType.MARIADB) {
plugin.getPluginLogger().warn("No MariaDB driver is found"); plugin.getPluginLogger().warn("No MariaDB driver is found");
} else if (storageType() == StorageType.MySQL) { } else if (storageType() == StorageType.MYSQL) {
try { try {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
} catch (ClassNotFoundException e2) { } catch (ClassNotFoundException e2) {

View File

@@ -11,6 +11,6 @@ public class MariaDBProvider extends AbstractHikariDatabase {
@Override @Override
public StorageType storageType() { public StorageType storageType() {
return StorageType.MariaDB; return StorageType.MARIADB;
} }
} }

View File

@@ -11,6 +11,6 @@ public class MySQLProvider extends AbstractHikariDatabase {
@Override @Override
public StorageType storageType() { public StorageType storageType() {
return StorageType.MySQL; return StorageType.MYSQL;
} }
} }

View File

@@ -63,7 +63,7 @@ public class SQLiteProvider extends AbstractSQLDatabase {
@Override @Override
public StorageType storageType() { public StorageType storageType() {
return StorageType.SQLite; return StorageType.SQLITE;
} }
/** /**

View File

@@ -88,7 +88,7 @@ other-settings:
default-condition-refresh-interval: 1 default-condition-refresh-interval: 1
# Set the default placeholder refresh interval # Set the default placeholder refresh interval
default-placeholder-refresh-interval: 1 default-placeholder-refresh-interval: 1
# Set the refresh interval for better performance in ticks (Especially for those heavy placeholders) # Set the refresh interval for better performance (Especially for those heavy placeholders)
placeholder-refresh-interval: placeholder-refresh-interval:
"%player_name%": 100 "%player_name%": 100
"%vault_prefix%": 1 "%vault_prefix%": 1

View File

@@ -21,8 +21,6 @@ bossbar_1:
# Display for 10 seconds # Display for 10 seconds
duration: 200 duration: 200
text: '%np_background_time% %np_background_location% %np_background_weather%' text: '%np_background_time% %np_background_location% %np_background_weather%'
# How often to refresh this text, in ticks (1 tick = 1/20 of a second)
refresh-frequency: 1
3: 3:
# Show for 5 seconds # Show for 5 seconds
duration: 100 duration: 100

View File

@@ -34,6 +34,14 @@ conditional-text:
weather: weather:
- thunder - thunder
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/bubble-text
bubble-text:
chat:
bubble: chat_1
text: '<black>Nice to meet you!</black>'
left-margin: 1
right-margin: 1
# https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/nameplate-text # https://mo-mi.gitbook.io/xiaomomi-plugins/plugin-wiki/customnameplates/custom-placeholders/nameplate-text
nameplate-text: nameplate-text:
halloween: halloween:

View File

@@ -1,6 +1,3 @@
image: bell image: bell
height: 10 height: 10
ascent: 4 ascent: 4
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: bubble image: bubble
height: 10 height: 10
ascent: 4 ascent: 4
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: clock image: clock
height: 10 height: 10
ascent: 4 ascent: 4
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: coin image: coin
height: 10 height: 10
ascent: -14 ascent: -14
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: compass image: compass
height: 10 height: 10
ascent: 4 ascent: 4
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: stamina_0 image: stamina_0
height: 9 height: 9
ascent: -16 ascent: -16
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: stamina_1 image: stamina_1
height: 9 height: 9
ascent: -16 ascent: -16
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: stamina_2 image: stamina_2
height: 9 height: 9
ascent: -16 ascent: -16
shadow:
remove: true
opacity: 254

View File

@@ -1,6 +1,3 @@
image: weather image: weather
height: 10 height: 10
ascent: 4 ascent: 4
shadow:
remove: true
opacity: 254