Skip to content

Commit

Permalink
[SKIP-CI] Renamed Log#warn of files to Log#warnFromFile to not confus…
Browse files Browse the repository at this point in the history
…e between the two
  • Loading branch information
OmerBenGera committed Oct 17, 2022
1 parent 5632125 commit 2b519f2
Show file tree
Hide file tree
Showing 23 changed files with 83 additions and 86 deletions.
Expand Up @@ -117,7 +117,7 @@ public void execute(SuperiorSkyblockPlugin plugin, CommandSender sender, String[
rolesStrings.get(superiorPlayer.getPlayerRole())
.append(Message.ISLAND_INFO_PLAYER_LINE.getMessage(locale, superiorPlayer.getName())).append("\n");
} catch (NullPointerException ex) {
Log.warn("It seems like ", superiorPlayer.getName(), " isn't part of the island of "
Log.warnFromFile("It seems like ", superiorPlayer.getName(), " isn't part of the island of "
, island.getOwner().getName(), ".");
}
});
Expand Down
Expand Up @@ -232,7 +232,7 @@ public SettingsContainer(SuperiorSkyblockPlugin plugin, YamlConfiguration config
String[] sections = line.split(":");

if (sections.length < 2) {
Log.warn("Cannot parse block limit '", line, "', skipping...");
Log.warnFromFile("Cannot parse block limit '", line, "', skipping...");
continue;
}

Expand All @@ -248,7 +248,7 @@ public SettingsContainer(SuperiorSkyblockPlugin plugin, YamlConfiguration config
String[] sections = line.split(":");

if (sections.length < 2) {
Log.warn("Cannot parse entity limit '", line, "', skipping...");
Log.warnFromFile("Cannot parse entity limit '", line, "', skipping...");
continue;
}

Expand Down Expand Up @@ -330,7 +330,7 @@ else if (sections.length == 3)
String portalOffset = config.getString("worlds.end.dragon-fight.portal-offset");
endDragonFightPortalOffset = Serializers.OFFSET_SPACED_SERIALIZER.deserialize(portalOffset);
if (endDragonFightPortalOffset == null) {
Log.warn("Cannot parse portal-offset '", portalOffset, "' to a valid offset, skipping...");
Log.warnFromFile("Cannot parse portal-offset '", portalOffset, "' to a valid offset, skipping...");
}
}
this.endDragonFightPortalOffset = endDragonFightPortalOffset == null ? SBlockOffset.ZERO : endDragonFightPortalOffset;
Expand Down Expand Up @@ -453,7 +453,7 @@ else if (sections.length == 3)
}
}
} catch (IllegalArgumentException ex) {
Log.warn("Invalid container type ", container + ", skipping...");
Log.warnFromFile("Invalid container type ", container + ", skipping...");
}
}
}
Expand Down Expand Up @@ -552,7 +552,7 @@ private KeySet loadSafeBlocks(SuperiorSkyblockPlugin plugin) {
List<String> safeBlocks = cfg.getStringList("safe-blocks");

if (safeBlocks.isEmpty()) {
Log.warn(file, "There are no valid safe blocks! Generating default ones...");
Log.warnFromFile(file.getName(), "There are no valid safe blocks! Generating default ones...");
safeBlocks.addAll(Arrays.stream(Material.values())
.filter(Material::isSolid)
.map(Material::name)
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -38,14 +38,14 @@ public static void deserializeMissions(DatabaseBridge databaseBridge, DatabaseCa
Optional<String> name = missions.getString("name");

if (!name.isPresent()) {
Log.warn("Cannot load player mission of null mission for ", uuid, ", skipping...");
Log.warnFromFile("Cannot load player mission of null mission for ", uuid, ", skipping...");
return;
}

Optional<Integer> finishCount = missions.getInt("finish_count");

if (!finishCount.isPresent()) {
Log.warn("Cannot load player mission of invalid finish count for ", uuid, ", skipping...");
Log.warnFromFile("Cannot load player mission of invalid finish count for ", uuid, ", skipping...");
return;
}

Expand Down
Expand Up @@ -24,7 +24,7 @@ public static void setNumberFormatter(String numberFormat) {
numberFormat = numberFormat.replace("_", "-");

if (!NUMBER_PATTERN.matcher(numberFormat).matches()) {
Log.warn("&cThe number format \"", numberFormat, "\" is invalid. Using default one: en-US.");
Log.warnFromFile("&cThe number format \"", numberFormat, "\" is invalid. Using default one: en-US.");
numberFormat = "en-US";
}

Expand Down
Expand Up @@ -177,7 +177,7 @@ public static TemplateItem getItemStack(String fileName, ConfigurationSection se
try {
enchantment = Enchantment.getByName(_enchantment);
} catch (Exception ex) {
Log.warn(new File(fileName), "Couldn't convert ", section.getCurrentPath(),
Log.warnFromFile(fileName, "Couldn't convert ", section.getCurrentPath(),
".enchants.", _enchantment, " into an enchantment, skipping...");
continue;
}
Expand Down Expand Up @@ -209,7 +209,7 @@ public static TemplateItem getItemStack(String fileName, ConfigurationSection se
PotionEffectType potionEffectType = PotionEffectType.getByName(_effect);

if (potionEffectType == null) {
Log.warn(new File(fileName), "Couldn't convert ", effectsSection.getCurrentPath(),
Log.warnFromFile(fileName, "Couldn't convert ", effectsSection.getCurrentPath(),
".", _effect, " into a potion effect, skipping...");
continue;
}
Expand All @@ -218,7 +218,7 @@ public static TemplateItem getItemStack(String fileName, ConfigurationSection se
int amplifier = effectsSection.getInt(_effect + ".amplifier", 0);

if (duration == -1) {
Log.warn(new File(fileName), "Potion effect ", effectsSection.getCurrentPath(),
Log.warnFromFile(fileName, "Potion effect ", effectsSection.getCurrentPath(),
".", _effect, " is missing duration, skipping...");
continue;
}
Expand All @@ -232,7 +232,7 @@ public static TemplateItem getItemStack(String fileName, ConfigurationSection se
try {
itemBuilder.withEntityType(EntityType.valueOf(entity.toUpperCase(Locale.ENGLISH)));
} catch (IllegalArgumentException ex) {
Log.warn(new File(fileName), "Couldn't convert ", entity, " into an entity type, skipping...");
Log.warnFromFile(fileName, "Couldn't convert ", entity, " into an entity type, skipping...");
}
}

Expand All @@ -248,7 +248,7 @@ public static TemplateItem getItemStack(String fileName, ConfigurationSection se
try {
itemBuilder.withLeatherColor(Integer.parseInt(leatherColor, 16));
} catch (IllegalArgumentException error) {
Log.warn(new File(fileName), "Couldn't convert ", leatherColor, " into a color, skipping...");
Log.warnFromFile(fileName, "Couldn't convert ", leatherColor, " into a color, skipping...");
}
}

Expand Down
Expand Up @@ -26,8 +26,8 @@ public static void warn(Object first, Object... parts) {
logInternal(Level.WARNING, first, parts);
}

public static void warn(File file, Object first, Object... parts) {
logInternal(Level.WARNING, file, first, parts);
public static void warnFromFile(String fileName, Object first, Object... parts) {
logInternal(Level.WARNING, fileName, first, parts);
}

public static void error(Object first, Object... parts) {
Expand Down Expand Up @@ -98,8 +98,8 @@ private static void enteringInternal(Level level, String clazz, String method, @
logInternal(level, clazz, "::", method, message == null ? "" : " " + message, paramsMessage.toString());
}

private static void logInternal(Level level, File file, Object first, Object... parts) {
plugin.getLogger().log(level, buildFromParts(file, first, parts));
private static void logInternal(Level level, String fileName, Object first, Object... parts) {
plugin.getLogger().log(level, buildFromParts(fileName, first, parts));
}

private static void logInternal(Level level, Object first, Object... parts) {
Expand All @@ -113,8 +113,8 @@ private static String buildFromParts(Object first, Object... parts) {
return builder.toString();
}

private static String buildFromParts(File prefixFile, Object first, Object... parts) {
StringBuilder builder = new StringBuilder("[").append(prefixFile.getName()).append("] ").append(first);
private static String buildFromParts(String prefixFile, Object first, Object... parts) {
StringBuilder builder = new StringBuilder("[").append(prefixFile).append("] ").append(first);
for (Object part : parts)
builder.append(part);
return builder.toString();
Expand Down
Expand Up @@ -86,7 +86,7 @@ public static void init() {
try {
biome = Biome.valueOf(biomeName.toUpperCase(Locale.ENGLISH));
} catch (IllegalArgumentException error) {
Log.warn(new File("biomes.yml"), "Biome '", biomeName, "' is not valid, skipping...");
Log.warnFromFile("biomes.yml", "Biome '", biomeName, "' is not valid, skipping...");
continue;
}

Expand Down
Expand Up @@ -17,7 +17,6 @@
import com.bgsoftware.superiorskyblock.core.menu.pattern.impl.PagedMenuPattern;
import org.bukkit.configuration.ConfigurationSection;

import java.io.File;
import java.util.Arrays;
import java.util.List;

Expand Down Expand Up @@ -70,12 +69,12 @@ public static void init() {
ConfigurationSection invalidPageSection = cfg.getConfigurationSection("items." + slotChar + ".invalid-page");

if (validPageSection == null) {
Log.warn(new File("island-chest.yml"), "The slot char ", slotChar, " is missing the valid-page section.");
Log.warnFromFile("island-chest.yml", "The slot char ", slotChar, " is missing the valid-page section.");
continue;
}

if (invalidPageSection == null) {
Log.warn(new File("island-chest.yml"), "&cThe slot char ", slotChar, " is missing the invalid-page section.");
Log.warnFromFile("island-chest.yml", "&cThe slot char ", slotChar, " is missing the invalid-page section.");
continue;
}

Expand Down
Expand Up @@ -84,7 +84,7 @@ public static void init() {
Schematic schematic = plugin.getSchematics().getSchematic(itemSection.getString("schematic"));

if (schematic == null) {
Log.warn(new File("island-creation.yml"), "Invalid schematic for item ", itemSectionName);
Log.warnFromFile("island-creation.yml", "Invalid schematic for item ", itemSectionName);
continue;
}

Expand All @@ -96,7 +96,7 @@ public static void init() {
Biome biome = Biome.valueOf(biomeName.toUpperCase(Locale.ENGLISH));
buttonBuilder.setBiome(biome);
} catch (IllegalArgumentException error) {
Log.warn(new File("island-creation.yml"), "Invalid biome name for item ",
Log.warnFromFile("island-creation.yml", "Invalid biome name for item ",
itemSectionName, ": ", biomeName);
}
}
Expand Down
Expand Up @@ -104,7 +104,7 @@ public static void init() {
try {
updatePermission(IslandPrivilege.getByName(permission), cfg, position++);
} catch (NullPointerException error) {
Log.warn(new File("permissions.yml"), "The island-privilege '", permission, "' is not a valid privilege, skipping...");
Log.warnFromFile("permissions.yml", "The island-privilege '", permission, "' is not a valid privilege, skipping...");
}
}
}
Expand Down
Expand Up @@ -67,13 +67,13 @@ public static void init() {
try {
playerRole = SPlayerRole.of((String) roleObject);
} catch (IllegalArgumentException error) {
Log.warn(new File("member-role.yml"), "Invalid role name: ", roleObject);
Log.warnFromFile("member-role.yml", "Invalid role name: ", roleObject);
continue;
}
} else if (roleObject instanceof Integer) {
playerRole = SPlayerRole.of((Integer) roleObject);
if (playerRole == null) {
Log.warn(new File("member-role.yml"), "&cInvalid role id: ", roleObject);
Log.warnFromFile("member-role.yml", "&cInvalid role id: ", roleObject);
continue;
}
}
Expand Down
Expand Up @@ -13,8 +13,6 @@
import com.bgsoftware.superiorskyblock.player.PlayerLocales;
import org.bukkit.configuration.ConfigurationSection;

import java.io.File;

public class MenuPlayerLanguage extends SuperiorMenu<MenuPlayerLanguage> {

private static RegularMenuPattern<MenuPlayerLanguage> menuPattern;
Expand Down Expand Up @@ -60,7 +58,7 @@ public static void init() {
}

if (locale == null) {
Log.warn(new File("player-language.yml"), "The language ", languageName, " is not valid.");
Log.warnFromFile("player-language.yml", "The language ", languageName, " is not valid.");
continue;
}

Expand Down
Expand Up @@ -100,7 +100,7 @@ public static void init() {
SortingType sortingType = SortingType.getByName(itemSection.getString("sorting-type"));

if (sortingType == null) {
Log.warn(new File("top-islands.yml"), "The sorting type is invalid for the item ", itemSectionName);
Log.warnFromFile("top-islands.yml", "The sorting type is invalid for the item ", itemSectionName);
continue;
}

Expand Down
Expand Up @@ -88,7 +88,7 @@ public static void init() {
}

if (slot == -1) {
Log.warn(new File("upgrades.yml"), "The item of the upgrade ", upgrade.getName(),
Log.warnFromFile("upgrades.yml", "The item of the upgrade ", upgrade.getName(),
" (level ", level, ") is not inside the pattern, skipping...");
continue;
}
Expand All @@ -98,13 +98,13 @@ public static void init() {
if (upgradeLevel != null) {
TemplateItem hasNextLevel = MenuParser.getItemStack("upgrades.yml", upgradeSection.getConfigurationSection(level + ".has-next-level"));
if (hasNextLevel == null) {
Log.warn(new File("upgrades.yml"), "The upgrade ", upgrade.getName(),
Log.warnFromFile("upgrades.yml", "The upgrade ", upgrade.getName(),
" (level ", level, ") is missing has-next-level item.");
}

TemplateItem noNextLevel = MenuParser.getItemStack("upgrades.yml", upgradeSection.getConfigurationSection(level + ".no-next-level"));
if (noNextLevel == null) {
Log.warn(new File("upgrades.yml"), "&cThe upgrade ", upgrade.getName(),
Log.warnFromFile("upgrades.yml", "&cThe upgrade ", upgrade.getName(),
" (level ", level, ") is missing no-next-level item.");
}

Expand Down
Expand Up @@ -59,7 +59,7 @@ public static void createMenu(File file) {
ConfigurationSection commandsSection = cfg.getConfigurationSection("command");

if (commandsSection == null) {
Log.warn(new File(fileName), "Custom menu doesn't have it's command section configured correctly, skipping...");
Log.warnFromFile(fileName, "Custom menu doesn't have it's command section configured correctly, skipping...");
return;
}

Expand Down
Expand Up @@ -870,7 +870,7 @@ public static void reload() {
try {
fileLocale = PlayerLocales.getLocale(fileName);
} catch (IllegalArgumentException ex) {
Log.warn("The language ", fileName, " is invalid, skipping...");
Log.warnFromFile("The language ", fileName, " is invalid, skipping...");
continue;
}

Expand Down
Expand Up @@ -26,7 +26,7 @@ public void loadDefaultValues(SuperiorSkyblockPlugin plugin) {
try {
setBlockValue(KeyImpl.of(key), new BigDecimal(value));
} catch (Exception ex) {
Log.warn("Cannot parse level value for ", key + ", skipping...");
Log.warnFromFile("Cannot parse level value for ", key + ", skipping...");
}
}
}
Expand Down
Expand Up @@ -32,7 +32,7 @@ public void loadDefaultValues(SuperiorSkyblockPlugin plugin) {
try {
setBlockValue(KeyImpl.of(key), new BigDecimal(value));
} catch (Exception ex) {
Log.warn("Cannot parse worth value for ", key + ", skipping...");
Log.warnFromFile("Cannot parse worth value for ", key + ", skipping...");
}
}
}
Expand Down
Expand Up @@ -181,20 +181,20 @@ private boolean canLoadCategory(SuperiorSkyblockPlugin plugin, String categoryNa
File categoryFolder = new File(getModuleFolder(), "categories/" + categoryName);

if (!categoryFolder.exists()) {
Log.warn("The directory of the mission category ", categoryName, " doesn't exist, skipping...");
Log.warnFromFile("The directory of the mission category ", categoryName, " doesn't exist, skipping...");
return false;
}

if (!categoryFolder.isDirectory()) {
Log.warn("The directory of the mission category ", categoryName, " is not valid, skipping...");
Log.warnFromFile("The directory of the mission category ", categoryName, " is not valid, skipping...");
return false;
}

File[] missionFiles = categoryFolder.listFiles(file ->
file.isFile() && file.getName().endsWith(".yml"));

if (missionFiles == null || missionFiles.length == 0) {
Log.warn("The mission category ", categoryName, " doesn't have missions, skipping...");
Log.warnFromFile("The mission category ", categoryName, " doesn't have missions, skipping...");
return false;
}

Expand Down Expand Up @@ -229,7 +229,7 @@ private boolean canLoadCategory(SuperiorSkyblockPlugin plugin, String categoryNa
}

if (categoryMissions.isEmpty()) {
Log.warn("The mission category ", categoryName, " doesn't have missions, skipping...");
Log.warnFromFile("The mission category ", categoryName, " doesn't have missions, skipping...");
return false;
}

Expand Down

0 comments on commit 2b519f2

Please sign in to comment.