Skip to content

Commit 618c4d6

Browse files
committed
Stuffs
1 parent 9fa79e2 commit 618c4d6

10 files changed

Lines changed: 58 additions & 42 deletions

File tree

src/main/java/me/nik/combatplus/CombatPlus.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import me.nik.combatplus.modules.impl.GoldenAppleCooldown;
2727
import me.nik.combatplus.modules.impl.HealthBar;
2828
import me.nik.combatplus.modules.impl.HideToolFlags;
29-
import me.nik.combatplus.utils.Messenger;
29+
import me.nik.combatplus.utils.ChatUtils;
3030
import org.bukkit.Bukkit;
3131
import org.bukkit.ChatColor;
3232
import org.bukkit.attribute.Attribute;
@@ -132,7 +132,7 @@ public void onEnable() {
132132
if (Config.Setting.CHECK_FOR_UPDATES.getBoolean()) {
133133
new UpdateChecker(this).runTaskAsynchronously(this);
134134
} else {
135-
Messenger.consoleMessage(MsgType.CONSOLE_UPDATE_DISABLED.getMessage());
135+
ChatUtils.consoleMessage(MsgType.CONSOLE_UPDATE_DISABLED.getMessage());
136136
}
137137

138138
//Load bStats

src/main/java/me/nik/combatplus/files/Config.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,19 @@ public class Config {
3131

3232
private final CombatPlus plugin;
3333
private CommentedFileConfiguration configuration;
34+
private static boolean exists;
3435

3536
public Config(CombatPlus plugin) {
3637
this.plugin = plugin;
3738
}
3839

3940
public void setup() {
4041
File configFile = new File(this.plugin.getDataFolder(), "config.yml");
41-
boolean setHeaderFooter = !configFile.exists();
42+
43+
exists = configFile.exists();
44+
45+
boolean setHeaderFooter = !exists;
46+
4247
boolean changed = setHeaderFooter;
4348

4449
this.configuration = CommentedFileConfiguration.loadConfiguration(this.plugin, configFile);
@@ -208,6 +213,7 @@ public enum Setting {
208213

209214
private final String key;
210215
private final Object defaultValue;
216+
private boolean excluded;
211217
private final String[] comments;
212218
private Object value = null;
213219

@@ -217,6 +223,13 @@ public enum Setting {
217223
this.comments = comments != null ? comments : new String[0];
218224
}
219225

226+
Setting(String key, Object defaultValue, boolean excluded, String... comments) {
227+
this.key = key;
228+
this.defaultValue = defaultValue;
229+
this.excluded = excluded;
230+
this.comments = comments != null ? comments : new String[0];
231+
}
232+
220233
/**
221234
* Gets the setting as a boolean
222235
*
@@ -297,6 +310,8 @@ public List<String> getStringList() {
297310
private boolean setIfNotExists(CommentedFileConfiguration fileConfiguration) {
298311
this.loadValue();
299312

313+
if (exists && this.excluded) return false;
314+
300315
if (fileConfiguration.get(this.key) == null) {
301316
List<String> comments = Stream.of(this.comments).collect(Collectors.toList());
302317
if (this.defaultValue != null) {

src/main/java/me/nik/combatplus/gui/Menu.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import me.nik.combatplus.CombatPlus;
44
import me.nik.combatplus.files.Config;
5-
import me.nik.combatplus.utils.Messenger;
5+
import me.nik.combatplus.utils.ChatUtils;
66
import org.bukkit.Bukkit;
77
import org.bukkit.Material;
88
import org.bukkit.event.inventory.InventoryClickEvent;
@@ -48,11 +48,11 @@ protected ItemStack makeItem(Material material, int amount, String displayName,
4848

4949
ItemStack item = new ItemStack(material, amount);
5050
ItemMeta itemMeta = item.getItemMeta();
51-
itemMeta.setDisplayName(Messenger.format(displayName));
51+
itemMeta.setDisplayName(ChatUtils.format(displayName));
5252
if (lore != null) {
5353
List<String> loreList = new ArrayList<>();
5454
for (String l : lore) {
55-
loreList.add(Messenger.format(l));
55+
loreList.add(ChatUtils.format(l));
5656
}
5757
itemMeta.setLore(loreList);
5858
}

src/main/java/me/nik/combatplus/managers/MsgType.java

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
package me.nik.combatplus.managers;
22

33
import me.nik.combatplus.CombatPlus;
4-
import me.nik.combatplus.utils.Messenger;
4+
import me.nik.combatplus.utils.ChatUtils;
55

66
public enum MsgType {
7-
PREFIX(Messenger.format(CombatPlus.getInstance().getLang().get().getString("prefix"))),
8-
NO_PERMISSION(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("no_perm"))),
9-
RELOADED(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("reloaded"))),
10-
UPDATE_REMINDER(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("update_reminder"))),
11-
GOLDEN_APPLE_COOLDOWN(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("golden_apple_cooldown"))),
12-
GOLDEN_APPLE_COOLDOWN_ACTIONBAR(Messenger.format(CombatPlus.getInstance().getLang().get().getString("golden_apple_cooldown_actionbar"))),
13-
ENCHANTED_GOLDEN_APPLE_COOLDOWN(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("enchanted_golden_apple_cooldown"))),
14-
ENCHANTED_GOLDEN_APPLE_COOLDOWN_ACTIONBAR(Messenger.format(CombatPlus.getInstance().getLang().get().getString("enchanted_golden_apple_cooldown_actionbar"))),
15-
ENDERPEARL_COOLDOWN(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("enderpearl_cooldown"))),
16-
ENDERPEARL_COOLDOWN_ACTIONBAR(Messenger.format(CombatPlus.getInstance().getLang().get().getString("enderpearl_cooldown_actionbar"))),
17-
COMBATLOG_TAGGED(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("combatlog_tagged"))),
18-
COMBATLOG_ACTIONBAR(Messenger.format(CombatPlus.getInstance().getLang().get().getString("combatlog_actionbar"))),
19-
COMBATLOG_BROADCAST(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("combatlog_broadcast"))),
20-
COMBATLOG_ITEM_DROP(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("combatlog_item_drop"))),
21-
COMBATLOG_TELEPORT(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("combatlog_teleport"))),
22-
COMBATLOG_COMMAND(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("combatlog_command"))),
23-
GUI_MAIN(Messenger.format(CombatPlus.getInstance().getLang().get().getString("gui_main"))),
24-
GUI_PLUGIN(Messenger.format(CombatPlus.getInstance().getLang().get().getString("gui_plugin"))),
25-
GUI_COMBAT(Messenger.format(CombatPlus.getInstance().getLang().get().getString("gui_combat"))),
26-
GUI_GENERAL(Messenger.format(CombatPlus.getInstance().getLang().get().getString("gui_general"))),
27-
CONSOLE_UPDATE_NOT_FOUND(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("console_update_not_found"))),
28-
CONSOLE_UPDATE_DISABLED(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("console_update_disabled"))),
29-
CONSOLE_COMMANDS(PREFIX.getMessage() + Messenger.format(CombatPlus.getInstance().getLang().get().getString("console_commands")));
7+
PREFIX(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("prefix"))),
8+
NO_PERMISSION(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("no_perm"))),
9+
RELOADED(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("reloaded"))),
10+
UPDATE_REMINDER(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("update_reminder"))),
11+
GOLDEN_APPLE_COOLDOWN(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("golden_apple_cooldown"))),
12+
GOLDEN_APPLE_COOLDOWN_ACTIONBAR(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("golden_apple_cooldown_actionbar"))),
13+
ENCHANTED_GOLDEN_APPLE_COOLDOWN(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("enchanted_golden_apple_cooldown"))),
14+
ENCHANTED_GOLDEN_APPLE_COOLDOWN_ACTIONBAR(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("enchanted_golden_apple_cooldown_actionbar"))),
15+
ENDERPEARL_COOLDOWN(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("enderpearl_cooldown"))),
16+
ENDERPEARL_COOLDOWN_ACTIONBAR(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("enderpearl_cooldown_actionbar"))),
17+
COMBATLOG_TAGGED(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("combatlog_tagged"))),
18+
COMBATLOG_ACTIONBAR(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("combatlog_actionbar"))),
19+
COMBATLOG_BROADCAST(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("combatlog_broadcast"))),
20+
COMBATLOG_ITEM_DROP(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("combatlog_item_drop"))),
21+
COMBATLOG_TELEPORT(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("combatlog_teleport"))),
22+
COMBATLOG_COMMAND(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("combatlog_command"))),
23+
GUI_MAIN(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("gui_main"))),
24+
GUI_PLUGIN(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("gui_plugin"))),
25+
GUI_COMBAT(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("gui_combat"))),
26+
GUI_GENERAL(ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("gui_general"))),
27+
CONSOLE_UPDATE_NOT_FOUND(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("console_update_not_found"))),
28+
CONSOLE_UPDATE_DISABLED(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("console_update_disabled"))),
29+
CONSOLE_COMMANDS(PREFIX.getMessage() + ChatUtils.format(CombatPlus.getInstance().getLang().get().getString("console_commands")));
3030

3131
private final String message;
3232

src/main/java/me/nik/combatplus/managers/UpdateChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package me.nik.combatplus.managers;
22

33
import me.nik.combatplus.CombatPlus;
4-
import me.nik.combatplus.utils.Messenger;
4+
import me.nik.combatplus.utils.ChatUtils;
55
import org.bukkit.event.EventHandler;
66
import org.bukkit.event.Listener;
77
import org.bukkit.event.player.PlayerJoinEvent;
@@ -33,10 +33,10 @@ public void run() {
3333
}
3434

3535
if (!plugin.getDescription().getVersion().equals(newVersion)) {
36-
Messenger.consoleMessage(MsgType.UPDATE_REMINDER.getMessage().replaceAll("%current%", plugin.getDescription().getVersion()).replaceAll("%new%", newVersion));
36+
ChatUtils.consoleMessage(MsgType.UPDATE_REMINDER.getMessage().replaceAll("%current%", plugin.getDescription().getVersion()).replaceAll("%new%", newVersion));
3737
plugin.getServer().getPluginManager().registerEvents(this, plugin);
3838
} else {
39-
Messenger.consoleMessage(MsgType.CONSOLE_UPDATE_NOT_FOUND.getMessage());
39+
ChatUtils.consoleMessage(MsgType.CONSOLE_UPDATE_NOT_FOUND.getMessage());
4040
}
4141
}
4242

src/main/java/me/nik/combatplus/modules/Module.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
import me.nik.combatplus.files.Config;
55
import me.nik.combatplus.managers.MsgType;
66
import me.nik.combatplus.managers.Permissions;
7-
import me.nik.combatplus.utils.Messenger;
7+
import me.nik.combatplus.utils.ChatUtils;
88
import org.bukkit.Bukkit;
99
import org.bukkit.entity.Player;
1010
import org.bukkit.event.HandlerList;
1111
import org.bukkit.event.Listener;
1212

13-
public abstract class Module implements Listener {
13+
public class Module implements Listener {
1414

1515
private final boolean enabled;
1616
private final String name;
@@ -36,7 +36,7 @@ public void shutdown() {
3636

3737
protected void debug(Player player, String information) {
3838
if (Config.Setting.DEVELOPER_MODE.getBoolean() && player.hasPermission(Permissions.DEBUG.getPermission())) {
39-
player.sendMessage(MsgType.PREFIX.getMessage() + this.name + Messenger.format(" &f&l>> &r" + information));
39+
player.sendMessage(MsgType.PREFIX.getMessage() + this.name + ChatUtils.format(" &f&l>> &r" + information));
4040
}
4141
}
4242
}

src/main/java/me/nik/combatplus/modules/impl/CustomPlayerKnockback.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public void onVelocity(PlayerVelocityEvent e) {
129129

130130
Player player = e.getPlayer();
131131

132-
Vector velocity = this.knockbackQueue.getIfPresent(player.getUniqueId());
132+
Vector velocity = this.knockbackQueue.get(player.getUniqueId());
133133

134134
if (velocity == null) return;
135135

src/main/java/me/nik/combatplus/modules/impl/HealthBar.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import me.nik.combatplus.files.Config;
44
import me.nik.combatplus.modules.Module;
5-
import me.nik.combatplus.utils.Messenger;
5+
import me.nik.combatplus.utils.ChatUtils;
66
import net.md_5.bungee.api.ChatMessageType;
77
import net.md_5.bungee.api.chat.TextComponent;
88
import org.bukkit.attribute.Attribute;
@@ -42,7 +42,7 @@ public void onCombat(EntityDamageByEntityEvent e) {
4242

4343
if (player == null || disabledWorld(player)) return;
4444

45-
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(Messenger.format(getHealth((LivingEntity) e.getEntity()))));
45+
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatUtils.format(getHealth((LivingEntity) e.getEntity()))));
4646
}
4747

4848
private boolean disabledWorld(Player player) {

src/main/java/me/nik/combatplus/utils/Messenger.java renamed to src/main/java/me/nik/combatplus/utils/ChatUtils.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
import org.bukkit.Bukkit;
55
import org.bukkit.ChatColor;
66

7-
public final class Messenger {
7+
public final class ChatUtils {
88

9-
private Messenger() {
9+
private ChatUtils() {
1010
throw new CombatPlusException("This is a static class dummy!");
1111
}
1212

src/main/java/me/nik/combatplus/utils/custom/ExpiringMap.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ public ExpiringMap(long expireMillis) {
1414
this.expireMillis = expireMillis;
1515
}
1616

17-
public V getIfPresent(K key) {
17+
@Override
18+
public V get(Object key) {
1819

1920
validate();
2021

0 commit comments

Comments
 (0)