Skip to content

Commit

Permalink
Version 3.3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ItsLewizzz committed Jun 26, 2020
1 parent bc86eea commit fa825d5
Show file tree
Hide file tree
Showing 11 changed files with 182 additions and 25 deletions.
12 changes: 9 additions & 3 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fun.lewisdev</groupId>
<artifactId>DeluxeHub</artifactId>
<version>3.3.0</version>
<version>3.3.4</version>
<packaging>jar</packaging>

<name>DeluxeHub</name>
Expand Down Expand Up @@ -115,7 +115,13 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>net.md-5</groupId>
<artifactId>bungeecord-chat</artifactId>
<version>1.16-R0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -154,7 +160,7 @@
<dependency>
<groupId>de.tr7zw</groupId>
<artifactId>item-nbt-api</artifactId>
<version>2.3.1</version>
<version>2.4.1</version>
</dependency>
<dependency>
<groupId>com.github.shynixn.headdatabase</groupId>
Expand Down
2 changes: 2 additions & 0 deletions src/main/java/fun/lewisdev/deluxehub/DeluxeHub.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import fun.lewisdev.deluxehub.module.ModuleManager;
import fun.lewisdev.deluxehub.module.ModuleType;
import fun.lewisdev.deluxehub.module.modules.hologram.HologramManager;
import fun.lewisdev.deluxehub.utility.TextUtil;
import fun.lewisdev.deluxehub.utility.UpdateChecker;
import org.bstats.bukkit.MetricsLite;
import org.bukkit.Bukkit;
Expand Down Expand Up @@ -60,6 +61,7 @@ public void onEnable() {
}

SERVER_VERSION = Integer.parseInt(Bukkit.getBukkitVersion().split("-")[0].replace(".", "#").split("#")[1]);
if (SERVER_VERSION > 15) TextUtil.HEX_USE = true;

// Enable bStats metrics
new MetricsLite(this, BSTATS_ID);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import fun.lewisdev.deluxehub.DeluxeHub;
import fun.lewisdev.deluxehub.action.Action;
import fun.lewisdev.deluxehub.utility.TextUtil;
import fun.lewisdev.deluxehub.utility.reflection.ActionBar;
import org.bukkit.entity.Player;

Expand All @@ -14,6 +15,6 @@ public String getIdentifier() {

@Override
public void execute(DeluxeHub plugin, Player player, String data) {
ActionBar.sendActionBar(player, data);
ActionBar.sendActionBar(player, TextUtil.color(data));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public ConfigHandler getFile(ConfigType type) {

public void reloadFiles() {
configurations.values().forEach(ConfigHandler::reload);
Messages.setConfiguration(getFile(ConfigType.MESSAGES).getConfig());
}

public void saveFiles() {
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/fun/lewisdev/deluxehub/config/Messages.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,13 @@ public static void setConfiguration(FileConfiguration c) {

@Override
public String toString() {

String message = config.getString("Messages." + this.path);

if (message == null || message.isEmpty()) return "DeluxeHub: message not found (" + this.path + ")";
if (message == null || message.isEmpty()) {
return "DeluxeHub: message not found (" + this.path + ")";
}

String prefix = config.getString("Messages." + PREFIX.getPath());

return TextUtil.color(message.replace("%prefix%", prefix != null && !prefix.isEmpty() ? prefix : ""));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ public void loadHolograms() {
List<String> lines = config.getStringList("holograms." + key + ".lines");

Location loc = (Location) config.get("holograms." + key + ".location");
if (loc == null) continue;
deleteNearbyHolograms(loc);

Hologram holo = createHologram(key, loc);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fun.lewisdev.deluxehub.module.modules.visual.scoreboard;

import fun.lewisdev.deluxehub.utility.PlaceholderUtil;
import fun.lewisdev.deluxehub.utility.TextUtil;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -61,7 +62,7 @@ public void removeSlot(int slot) {
}

public String setPlaceholders(String text) {
return ChatColor.translateAlternateColorCodes('&', PlaceholderUtil.setPlaceholders(text, this.player));
return TextUtil.color(PlaceholderUtil.setPlaceholders(text, this.player));
}

public void setSlotsFromList(List<String> list) {
Expand Down
30 changes: 26 additions & 4 deletions src/main/java/fun/lewisdev/deluxehub/utility/TextUtil.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,36 @@
package fun.lewisdev.deluxehub.utility;

import org.bukkit.ChatColor;
import net.md_5.bungee.api.ChatColor;
import org.bukkit.Color;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class TextUtil {

private final static int CENTER_PX = 154;
private static final int CENTER_PX = 154;
private static final Pattern HEX_PATTERN = Pattern.compile("#<([A-Fa-f0-9]){6}>");
public static boolean HEX_USE = false;

public static String color(String message) {
if (HEX_USE) {
Matcher matcher = HEX_PATTERN.matcher(message);

while (matcher.find()) {
String hexString = matcher.group();

hexString = "#" + hexString.substring(2, hexString.length() - 1);

final ChatColor hex = ChatColor.of(hexString);
final String before = message.substring(0, matcher.start());
final String after = message.substring(matcher.end());

message = before + hex + after;
matcher = HEX_PATTERN.matcher(message);
}
}

public static String color(String s) {
return ChatColor.translateAlternateColorCodes('&', s);
return ChatColor.translateAlternateColorCodes('&', message);
}

public static String getCenteredMessage(String message) {
Expand Down
Loading

0 comments on commit fa825d5

Please sign in to comment.