Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customizable plugin prefix and RGB support in strings #608

Open
wants to merge 41 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
1cdd29f
Customizable prefix and RGB support in strings
Jsinco Jan 12, 2024
8f3901f
Interface for commands
Jsinco Jan 14, 2024
bfc8fac
multi-puke items, rename main class
Jsinco Jan 14, 2024
386e797
multi-puke items, rename main class
Jsinco Jan 20, 2024
7f9d14a
addons
Jsinco Jan 27, 2024
8b36a9e
Update README.md
Jsinco Jan 27, 2024
4cd3ec5
Finish addons v1 and add AddonLogger
Jsinco Jan 27, 2024
aba52e9
Merge remote-tracking branch 'origin/master'
Jsinco Jan 27, 2024
b979080
addons additions and edits
Jsinco Jan 27, 2024
b1b07fc
use file seperator char instead of "/"
Jsinco Jan 27, 2024
041e3df
disable update checker
Jsinco Jan 27, 2024
fe635c6
bump version
Jsinco Jan 27, 2024
b51b4a0
command support for addons
Jsinco Jan 27, 2024
48055a0
command support for addons
Jsinco Jan 27, 2024
5c2acaa
remove debug stuff, add support for custommodeldata in custom items
Jsinco Jan 28, 2024
457a4ec
patch #541, bump version
Jsinco Jan 28, 2024
82c1b3e
fix addon resources
Jsinco Jan 30, 2024
de49c88
prep 3.1.5
Jsinco Feb 3, 2024
87cc0dc
add spigot page link
Jsinco Feb 3, 2024
0f7615f
fix bugs, reformat AddonLoggers, and add kotlin as a standard library
Jsinco Feb 3, 2024
18f30b2
forgot to remove this
Jsinco Feb 3, 2024
86f1761
3.1.6 reloadable addons
Jsinco Feb 9, 2024
c9b0ed1
Folia support using Anon8281's UniversalScheduler
Jsinco Feb 10, 2024
45697ea
puke fix using region-specific scheduler
Jsinco Feb 10, 2024
9265f8c
puke fix using region-specific scheduler
Jsinco Feb 10, 2024
d2754d1
Cauldron ticking fixes & /brew reloadaddons warning
Jsinco Feb 10, 2024
4cb2f5f
/brew reloadaddons warning
Jsinco Feb 10, 2024
10c489c
bump version, etc
Jsinco Feb 10, 2024
eaa2d7f
Merge pull request #1 from Jsinco/folia
Jsinco Feb 10, 2024
525c9af
Merge remote-tracking branch 'origin/master'
Jsinco Feb 10, 2024
3203ecf
version cmd, minor stuff
Jsinco Feb 14, 2024
4eefbe3
show who brewed potion, methods for Depenizen support
Jsinco Feb 25, 2024
c9c1723
oops dont change plugin/project name yet
Jsinco Feb 25, 2024
f99df71
oops dont change plugin/project name yet
Jsinco Feb 25, 2024
66c8201
include all langs and config langs
Jsinco Apr 1, 2024
3f51fe2
Add brew glint #617
Jsinco Apr 5, 2024
f0b5e50
catch with a throwable in case we can't check vault for items
Jsinco Apr 6, 2024
c79cf70
update cook/ingredient lore while aging, fix #603
Jsinco Apr 11, 2024
21fcd3a
update langs for glint, bump to 3.1.9
Jsinco Apr 11, 2024
8f6cca7
update langs for glint, bump to 3.1.9
Jsinco Apr 11, 2024
d0dfc05
Merge remote-tracking branch 'origin/master'
Jsinco Apr 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions pom.xml
Expand Up @@ -96,6 +96,11 @@
</plugins>
</build>
<repositories>
<repository>
<!-- GriefPrevention, SlimeFun, Towny, Brewery -->
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>md_5-public</id>
<url>https://repo.md-5.net/content/groups/public/</url>
Expand All @@ -113,11 +118,6 @@
<id>enginehub-maven</id>
<url>https://maven.enginehub.org/repo/</url>
</repository>
<repository>
<!-- GriefPrevention, SlimeFun, Towny, Brewery -->
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<!-- LWC Extended -->
<id>ender-repo</id>
Expand Down Expand Up @@ -248,7 +248,7 @@
<!-- https://www.spigotmc.org/resources/griefprevention.1884/history -->
<groupId>com.github.TechFortress</groupId>
<artifactId>GriefPrevention</artifactId>
<version>16.18.1</version>
<version>16.18</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -296,7 +296,7 @@
<!-- https://www.spigotmc.org/resources/towny-advanced.72694/history -->
<groupId>com.github.TownyAdvanced</groupId>
<artifactId>Towny</artifactId>
<version>0.100.0.0</version>
<version>0.100.1.0</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down
3 changes: 3 additions & 0 deletions resources/config/v12/de/config.yml
Expand Up @@ -7,6 +7,9 @@
# Sprachedatei die genutzt werden sollte (befindet sich in plugins/Brewery/languages)
language: de

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# Ob der Spieler beim nächsten Einloggen nach starker Trunkenheit am nächsten morgen Zuhause "aufwacht" (Ein home Plugin muss installiert sein!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v12/en/config.yml
Expand Up @@ -7,6 +7,9 @@
# Languagefile to be used (found in plugins/Brewery/languages)
language: en

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# If the player wakes up at /home when logging in after excessive drinking (/home plugin must be installed!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v12/fr/config.yml
Expand Up @@ -8,6 +8,9 @@
# Fichier de langage utilisé (trouvable dans plugins/Brewery/languages)
language: fr

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# Si le joueur se réveille à son /home lors de sa connexion après un excès alcool (Un plugin de /home est nécessaire!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v12/it/config.yml
Expand Up @@ -7,6 +7,9 @@
# Lingua da usare (fra quelle in plugins/Brewery/languages)
language: it

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# Se il giocatore si sveglia nella sua /home dopo aver bevuto troppo(il plugin di /home deve essere installato!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v13/de/config.yml
Expand Up @@ -7,6 +7,9 @@
# Sprachedatei die genutzt werden sollte (befindet sich in plugins/Brewery/languages)
language: de

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# Ob der Spieler beim nächsten Einloggen nach starker Trunkenheit am nächsten morgen Zuhause "aufwacht" (Ein home Plugin muss installiert sein!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v13/en/config.yml
Expand Up @@ -7,6 +7,9 @@
# Languagefile to be used (found in plugins/Brewery/languages)
language: en

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# If the player wakes up at /home when logging in after excessive drinking (/home plugin must be installed!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v13/es/config.yml
Expand Up @@ -7,6 +7,9 @@
# Languagefile to be used (found in plugins/Brewery/languages)
language: es

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# If the player wakes up at /home when logging in after excessive drinking (/home plugin must be installed!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v13/fr/config.yml
Expand Up @@ -8,6 +8,9 @@
# Fichier de langage utilisé (trouvable dans plugins/Brewery/languages)
language: fr

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# Si le joueur se réveille à son /home lors de sa connexion après un excès alcool (Un plugin de /home est nécessaire!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v13/it/config.yml
Expand Up @@ -7,6 +7,9 @@
# Lingua da usare (fra quelle in plugins/Brewery/languages)
language: it

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# Se il giocatore si sveglia nella sua /home dopo aver bevuto troppo(il plugin di /home deve essere installato!) [true]
enableHome: true

Expand Down
3 changes: 3 additions & 0 deletions resources/config/v13/zh/config.yml
Expand Up @@ -9,6 +9,9 @@
# 语言文件(可在plugins/Brewery/languages下找到)
language: zh

# Prefix used on messages
pluginPrefix: '&2[Brewery]&f '

# 喝高了的下线玩家会在家里醒来(需要/home等功能支持)[true]
enableHome: true

Expand Down
6 changes: 3 additions & 3 deletions src/com/dre/brewery/P.java
Expand Up @@ -312,7 +312,7 @@ public static P getInstance() {
// Utility

public void msg(CommandSender sender, String msg) {
sender.sendMessage(color("&2[Brewery] &f" + msg));
sender.sendMessage(color(BConfig.pluginPrefix + msg));
}

public void log(String msg) {
Expand All @@ -326,9 +326,9 @@ public void debugLog(String msg) {
}

public void errorLog(String msg) {
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GREEN + "[Brewery] " + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_GREEN + BConfig.pluginPrefix + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
if (BConfig.reloader != null) {
BConfig.reloader.sendMessage(ChatColor.DARK_GREEN + "[Brewery] " + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
BConfig.reloader.sendMessage(ChatColor.DARK_GREEN + BConfig.pluginPrefix + ChatColor.DARK_RED + "ERROR: " + ChatColor.RED + msg);
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/com/dre/brewery/filedata/BConfig.java
Expand Up @@ -95,6 +95,7 @@ public class BConfig {
//Features
public static boolean craftSealingTable; // Allow Crafting of Sealing Table
public static boolean enableSealingTable; // Allow Usage of Sealing Table
public static String pluginPrefix = "&2[Brewery]&f ";

//Item
public static List<RecipeItem> customItems = new ArrayList<>();
Expand Down Expand Up @@ -234,6 +235,7 @@ public static void readConfig(FileConfiguration config) {
enableWake = config.getBoolean("enableWake", false);
craftSealingTable = config.getBoolean("craftSealingTable", false);
enableSealingTable = config.getBoolean("enableSealingTable", false);
pluginPrefix = config.getString("pluginPrefix", "&2[Brewery]&f ");
colorInBarrels = config.getBoolean("colorInBarrels", false);
colorInBrewer = config.getBoolean("colorInBrewer", false);
alwaysShowQuality = config.getBoolean("alwaysShowQuality", false);
Expand Down
28 changes: 25 additions & 3 deletions src/com/dre/brewery/utility/BUtil.java
Expand Up @@ -38,18 +38,40 @@ public class BUtil {
/* ********* ********* */
/* **************************************** */

private static final String WITH_DELIMITER = "((?<=%1$s)|(?=%1$s))";

/**
* Check if the Chunk of a Block is loaded !without loading it in the process!
*/
public static boolean isChunkLoaded(Block block) {
return block.getWorld().isChunkLoaded(block.getX() >> 4, block.getZ() >> 4);
}

/**
* Color code a message. Supports HEX colors and default minecraft colors! &2 &#FFFFFF
* @param msg The message to color
* @return The colored message, or null if msg was null
*/
public static String color(String msg) {
if (msg != null) {
msg = ChatColor.translateAlternateColorCodes('&', msg);
if (msg == null) return null;
String[] texts = msg.split(String.format(WITH_DELIMITER, "&"));

StringBuilder finalText = new StringBuilder();

for (int i = 0; i < texts.length; i++) {
if (texts[i].equalsIgnoreCase("&")) {
//get the next string
i++;
if (texts[i].charAt(0) == '#') {
finalText.append(net.md_5.bungee.api.ChatColor.of(texts[i].substring(0, 7)) + texts[i].substring(7));
} else {
finalText.append(ChatColor.translateAlternateColorCodes('&', "&" + texts[i]));
}
} else {
finalText.append(texts[i]);
}
}
return msg;
return finalText.toString();
}

/**
Expand Down