Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yourgamespace.anticooldown.api;

import com.yourgamespace.anticooldown.utils.CooldownHandler;
import com.yourgamespace.anticooldown.modules.attackcooldown.utils.CooldownHandler;
import org.bukkit.entity.Player;

public class AntiCooldownApi {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.yourgamespace.anticooldown.api.events;

import com.yourgamespace.anticooldown.utils.CooldownHandler;
import com.yourgamespace.anticooldown.modules.attackcooldown.utils.CooldownHandler;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.yourgamespace.anticooldown.data.Data;
import com.yourgamespace.anticooldown.main.AntiCooldown;
import com.yourgamespace.anticooldown.utils.ItemDamageManager;
import com.yourgamespace.anticooldown.utils.ItemRestrictionManager;
import com.yourgamespace.anticooldown.utils.basics.AntiCooldownLogger;
import com.yourgamespace.anticooldown.utils.basics.ObjectTransformer;
Expand All @@ -29,14 +28,105 @@ public class PluginConfig {
public PluginConfig() {}

public void initConfigFile() {
if (!configFile.exists()) AntiCooldown.getInstance().saveResource(configFile.getName(), false);
config = YamlConfiguration.loadConfiguration(configFile);

// Pre-load config version for upgrade check
cacheContainer.add(Integer.class, "CONFIG_VERSION", config.getInt("ConfigVersion"));
}

public void setupConfig() {
if (!configFile.exists()) AntiCooldown.getInstance().saveResource(configFile.getName(), false);
// START Messages
config.addDefault("Messages.Prefix", "§7[§3AntiCooldown§7] ");
config.addDefault("Messages.ActionBarPrefix", "§3AntiCooldown§7 »");
config.addDefault("Messages.SwitchWorld.Bypassed", "§ePvP Cooldown is §c§lnot disabled §ein this world, but you have §2Bypass-Permissions§a! §aCooldown is disable for you.");
config.addDefault("Messages.SwitchWorld.Enabled", "§ePvP Cooldown is §a§ldisabled §ein this world!");
config.addDefault("Messages.SwitchWorld.Disabled", "§ePvP Cooldown is §c§lnot disabled §ein this world!");
config.addDefault("Messages.Login.Bypassed", "§aHey, welcome to the server! §ePvP Cooldown is §c§lnot disabled §ein this world, but you have §2Bypass-Permissions§a! §aCooldown is disable for you.");
config.addDefault("Messages.Login.Enabled", "§aHey, welcome to the server! §ePvP Cooldown is §a§ldisabled §ein this world!");
config.addDefault("Messages.Login.Disabled", "§aHey, welcome to the server! §ePvP Cooldown is §c§lnot disabled §ein this world!");
config.addDefault("Messages.CustomItemDamage.ActionBarMessage", "%actionbar_prefix% §aCustom-Damage applied: §7%finaldamage%§c❤ §7Damage");
config.addDefault("Messages.ItemRestriction.ActionBarMessage.Enabled", "%actionbar_prefix% §aItem is no longer restricted! PvP Cooldown is §a§ldisabled §aagain");
config.addDefault("Messages.ItemRestriction.ActionBarMessage.Disabled", "%actionbar_prefix% §cItem is restricted! PvP Cooldown is temporarily §c§lactivated");
config.addDefault("Messages.Setting.AddDisabledWorld", "§aOK! In the world §e%world% §athe cooldown is now activated.");
config.addDefault("Messages.Setting.RemoveDisabledWorld", "§aOK! In the world §e%world% §athe cooldown is now deactivated.");
config.addDefault("Messages.Error.WorldAlreadyDisabled", "§cThis world is already §c§ldeactivated§c!");
config.addDefault("Messages.Error.WorldAlreadyEnabled", "§cThis world is already §a§lactivated§c!");
config.addDefault("Messages.Error.PlayerNotOnline", "§cThe player is not online!");
config.addDefault("Messages.Error.NoPerms", "§cNo permissions!");
// END Messages

//Placeholder
config.addDefault("Placeholder.World.CooldownEnabled", "Enabled");
config.addDefault("Placeholder.World.CooldownDisabled", "Disabled");
config.addDefault("Placeholder.Player.CooldownEnabled", "Enabled");
config.addDefault("Placeholder.Player.CooldownDisabled", "Disabled");

// Config List Options
//List: Restricted Items
List<String> restrictedItems = config.getStringList("Settings.Values.RestrictedItems");
restrictedItems.add("DIAMOND_AXE");
restrictedItems.add("GOLDEN_AXE");
restrictedItems.add("IRON_AXE");
restrictedItems.add("STONE_AXE");
restrictedItems.add("NETHERITE_AXE");
restrictedItems.add("WOODEN_AXE");

//List: Disabled Worlds
List<String> disabledWorlds = config.getStringList("Settings.Values.DisabledWorlds");
disabledWorlds.add("YourWorldName");

//List: Item Damage Values
List<String> customItemDamage = config.getStringList("Settings.Values.CustomItemDamage");
customItemDamage.add("WOOD_AXE:3.0D");
customItemDamage.add("WOODEN_AXE:3.0D");
customItemDamage.add("GOLD_AXE:3.0D");
customItemDamage.add("GOLDEN_AXE:3.0D");
customItemDamage.add("STONE_AXE:4.0D");
customItemDamage.add("IRON_AXE:5.0D");
customItemDamage.add("DIAMOND_AXE:6.0D");
customItemDamage.add("WOOD_PICKAXE:2.0D");
customItemDamage.add("WOODEN_PICKAXE:2.0D");
customItemDamage.add("GOLD_PICKAXE:2.0D");
customItemDamage.add("GOLDEN_PICKAXE:2.0D");
customItemDamage.add("STONE_PICKAXE:3.0D");
customItemDamage.add("IRON_PICKAXE:4.0D");
customItemDamage.add("DIAMOND_PICKAXE:5.0D");
customItemDamage.add("WOODEN_SHOVEL:1.0D");
customItemDamage.add("GOLDEN_SHOVEL:1.0D");
customItemDamage.add("STONE_SHOVEL:2.0D");
customItemDamage.add("IRON_SHOVEL:3.0D");
customItemDamage.add("DIAMOND_SHOVEL:4.0D");

// START Settings
//Settings: Permissions
config.addDefault("Settings.Permissions.UsePermissions", false);
config.addDefault("Settings.Permissions.UseBypassPermission", false);
//Settings: Messages
config.addDefault("Settings.Messages.UseLoginMessage", true);
config.addDefault("Settings.Messages.UseSwitchWorldMessage", true);
//Settings: Values
config.addDefault("Settings.Values.AttackSpeed", 100);
config.addDefault("Settings.Values.DisabledWorlds", disabledWorlds);
config.addDefault("Settings.Values.RestrictedItems", restrictedItems);
config.addDefault("Settings.Values.CustomItemDamage", customItemDamage);
//Settings: Features
config.addDefault("Settings.Features.DisableSweepAttacks", true);
config.addDefault("Settings.Features.DisableNewCombatSounds", true);
config.addDefault("Settings.Features.DisablePlayerCollision", true);
config.addDefault("Settings.Features.DisableEnderpearlCooldown", true);
config.addDefault("Settings.Features.CustomItemDamage.EnableCustomItemDamage", true);
config.addDefault("Settings.Features.CustomItemDamage.SendActionBar", true);
config.addDefault("Settings.Features.ItemRestriction.EnableItemRestriction", false);
config.addDefault("Settings.Features.ItemRestriction.SendActionBar", true);
config.addDefault("Settings.Features.ItemRestriction.UseAsWhitelist", false);
//Settings: UpdateChecker
config.addDefault("Settings.Updates.UseUpdateChecker", true);
config.addDefault("Settings.Updates.ConsoleNotify", true);
config.addDefault("Settings.Updates.IngameNotify", true);
// END Settings

config.addDefault("ConfigVersion", data.getCurrentConfigVersion());
}

public void upgradeConfig() {
Expand Down Expand Up @@ -68,6 +158,10 @@ private void saveConfig() {
public void loadConfig() {
antiCooldownLogger.info("§aLoad configurations from config file §e" + configFile.getName() + " §a...");

config.set(AntiCooldown.getInstance().getDescription().getName() + "_COMMENT_" + 1, " " + "Test");
config.set("Test", "Test123123");
saveConfig();

//Messages
cacheContainer.add(String.class, "PREFIX", config.getString("Messages.Prefix"));
cacheContainer.add(String.class, "ACTIONBAR_PREFIX", config.getString("Messages.ActionBarPrefix"));
Expand Down Expand Up @@ -131,12 +225,12 @@ public void loadConfig() {
antiCooldownLogger.info("§aWorld §e" + disabledWorld + " §adisabled!");
}

//Values: CustomItemDamage
for (String customItemDamage : config.getStringList("Settings.Values.CustomItemDamage")) {
String[] itemParams = customItemDamage.split(":");

ItemDamageManager.addCache(itemParams[0], itemParams[1]);
}
// //Values: CustomItemDamage
// for (String customItemDamage : config.getStringList("Settings.Values.CustomItemDamage")) {
// String[] itemParams = customItemDamage.split(":");
//
// ItemDamageManager.addCache(itemParams[0], itemParams[1]);
// }

antiCooldownLogger.info("§aConfigurations from config file §e" + configFile.getName() + " §asuccessfully loaded!");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,19 @@
import com.yourgamespace.anticooldown.commands.CmdAntiCooldown;
import com.yourgamespace.anticooldown.data.Data;
import com.yourgamespace.anticooldown.files.PluginConfig;
import com.yourgamespace.anticooldown.modules.AttackCooldown;
import com.yourgamespace.anticooldown.modules.CombatSounds;
import com.yourgamespace.anticooldown.modules.CustomItemDamage;
import com.yourgamespace.anticooldown.modules.EnderpearlCooldown;
import com.yourgamespace.anticooldown.modules.ItemRestriction;
import com.yourgamespace.anticooldown.modules.PlayerCollision;
import com.yourgamespace.anticooldown.modules.SweepAttackDamage;
import com.yourgamespace.anticooldown.modules.SweepAttackParticle;
import com.yourgamespace.anticooldown.modules.UpdateNotifyOnJoin;
import com.yourgamespace.anticooldown.utils.CooldownHandler;
import com.yourgamespace.anticooldown.modules.attackcooldown.main.AttackCooldown;
import com.yourgamespace.anticooldown.modules.attackcooldown.utils.CooldownHandler;
import com.yourgamespace.anticooldown.utils.PlaceholderHandler;
import com.yourgamespace.anticooldown.utils.WorldManager;
import com.yourgamespace.anticooldown.utils.basics.AntiCooldownLogger;
import com.yourgamespace.anticooldown.utils.basics.ObjectTransformer;
import com.yourgamespace.anticooldown.utils.PlaceholderHandler;
import com.yourgamespace.anticooldown.utils.basics.VersionHandler;
import com.yourgamespace.anticooldown.utils.WorldManager;
import com.yourgamespace.anticooldown.utils.module.ModuleCommandHandler;
import com.yourgamespace.anticooldown.utils.module.ModuleDescription;
import com.yourgamespace.anticooldown.utils.module.ModuleHandler;
Expand Down Expand Up @@ -136,9 +134,9 @@ private void initialisation() {
private void manageConfigs() {
antiCooldownLogger.info("§aLoading config files ...");

pluginConfig.setupConfig();
pluginConfig.initConfigFile();
pluginConfig.upgradeConfig();
pluginConfig.setupConfig();
pluginConfig.loadConfig();

antiCooldownLogger.info("§aConfig files was successfully loaded!");
Expand All @@ -151,10 +149,8 @@ private void registerModules() {
moduleHandler.registerModule(new AttackCooldown(false, new ModuleDescription("AttackCooldown", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new SweepAttackDamage(false, new ModuleDescription("SweepAttackDamage", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new SweepAttackParticle(true, new ModuleDescription("SweepAttackParticle", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new CombatSounds(true, new ModuleDescription("CombatSounds", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new EnderpearlCooldown(false, new ModuleDescription("EnderpearlCooldown", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new PlayerCollision(true, new ModuleDescription("PlayerCollision", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new CustomItemDamage(false, new ModuleDescription("CustomItemDamage", "1.0", "Internal Module", "YourGameSpace")));
moduleHandler.registerModule(new ItemRestriction(false, new ModuleDescription("ItemRestriction", "1.0", "Internal Module", "YourGameSpace")));

moduleHandler.enableModules();
Expand Down
Loading