Fix wiki links being outdated

This commit is contained in:
nossr50 2024-04-06 15:10:02 -07:00
parent ffc6061f8b
commit 4d98d25215
6 changed files with 43 additions and 60 deletions

View File

@ -1,4 +1,6 @@
Version 2.2.006
Updated outdated wiki URLs in commands to point to the new wiki
Removed the msg about skills being migrated to a new system when using /mmoinfo command
Added new config custom_item_support.yml
Added setting to disable repair on items with custom models, this is not on by default
Added new locale entry 'Anvil.Repair.Reject.CustomModelData'
@ -9,6 +11,7 @@ Version 2.2.006
This update adds a new config file to allow server owners to disable repair or salvage on items with custom models,
This prevention mechanism is not enabled by default, change the settings in custom_item_support.yml if you want to enable it.
This feature is off by default for now to keep compatibility with existing servers, but it may be enabled by default in the future if feedback suggests it should be.
As a reminder, anyone can update the wiki by clicking on the "edit on github" link on various pages, this will take you to the wiki's source code on GitHub, submit a PR to make changes
Version 2.2.005
Fixed a bug where certain skills such as Dodge/Arrow Deflect had no skill cap and would continue improving forever

View File

@ -1,7 +1,6 @@
package com.gmail.nossr50.commands.skills;
import com.gmail.nossr50.datatypes.skills.SubSkillType;
import com.gmail.nossr50.listeners.InteractionManager;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions;
@ -29,14 +28,11 @@ public class MmoInfoCommand implements TabExecutor {
*/
if(commandSender instanceof Player player)
{
if(args.length < 1)
if(args == null || args.length < 1 || args[0] == null || args[0].isEmpty())
return false;
if(Permissions.mmoinfo(player))
{
if(args == null || args[0] == null)
return false;
if(args[0].equalsIgnoreCase( "???"))
{
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
@ -44,14 +40,15 @@ public class MmoInfoCommand implements TabExecutor {
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Mystery"));
return true;
} else if(InteractionManager.getAbstractByName(args[0]) != null || mcMMO.p.getSkillTools().EXACT_SUBSKILL_NAMES.contains(args[0]))
{
displayInfo(player, args[0]);
return true;
}
//Not a real skill
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.NoMatch"));
final SubSkillType subSkillType = matchSubSkill(args[0]);
if (subSkillType != null) {
displayInfo(player, subSkillType);
} else {
//Not a real skill
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.NoMatch"));
}
return true;
}
}
@ -59,6 +56,16 @@ public class MmoInfoCommand implements TabExecutor {
return false;
}
public SubSkillType matchSubSkill(String name) {
for(SubSkillType subSkillType : SubSkillType.values())
{
if(subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(name)
|| subSkillType.name().equalsIgnoreCase(name))
return subSkillType;
}
return null;
}
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, String[] args) {
if (args.length == 1) {
@ -67,20 +74,13 @@ public class MmoInfoCommand implements TabExecutor {
return ImmutableList.of();
}
private void displayInfo(Player player, String subSkillName)
private void displayInfo(Player player, SubSkillType subSkillType)
{
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.Header"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillName));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.SubSkillHeader", subSkillType.getLocaleName()));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.DetailsHeader"));
player.sendMessage(LocaleLoader.getString("Commands.MmoInfo.OldSkill"));
for(SubSkillType subSkillType : SubSkillType.values())
{
if(subSkillType.getNiceNameNoSpaces(subSkillType).equalsIgnoreCase(subSkillName))
subSkillName = subSkillType.getWikiName(subSkillType.toString());
}
//Send Player Wiki Link
TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillName);
TextComponentFactory.sendPlayerSubSkillWikiLink(player, subSkillType.getLocaleName(), subSkillType);
}
}

View File

@ -213,35 +213,12 @@ public enum SubSkillType {
return endResult.toString();
}
public String getWikiName(String subSkillName) {
/*
* Find where to begin our substring (after the prefix)
*/
StringBuilder endResult = new StringBuilder();
int subStringIndex = getSubStringIndex(subSkillName);
/*
* Split the string up so we can capitalize each part
*/
String subskillNameWithoutPrefix = subSkillName.substring(subStringIndex);
if(subskillNameWithoutPrefix.contains("_"))
{
String[] splitStrings = subskillNameWithoutPrefix.split("_");
for(int i = 0; i < splitStrings.length; i++)
{
if(i+1 >= splitStrings.length)
endResult.append(StringUtils.getCapitalized(splitStrings[i]));
else {
endResult.append(StringUtils.getCapitalized(splitStrings[i]));
endResult.append("_");
}
}
} else {
endResult.append(StringUtils.getCapitalized(subskillNameWithoutPrefix));
}
return endResult.toString();
public String getWikiUrl() {
// remove the text before the first underscore
int subStringIndex = getSubStringIndex(name());
String afterPrefix = name().substring(subStringIndex);
// replace _ or spaces with -
return afterPrefix.replace("_", "-").replace(" ", "-").toLowerCase(Locale.ENGLISH);
}
/**

View File

@ -34,8 +34,6 @@ import org.jetbrains.annotations.Nullable;
import java.util.Iterator;
import static java.util.Objects.requireNonNull;
public final class SkillUtils {
/**
* This is a static utility class, therefore we don't want any instances of

View File

@ -56,18 +56,23 @@ public class TextComponentFactory {
return Component.text(text);
}
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted) {
public static String getSubSkillWikiLink(SubSkillType subSkillType) {
return "https://wiki.mcmmo.org/en/skills/"
+ subSkillType.getParentSkill().toString().toLowerCase(Locale.ENGLISH) + "#"
+ subSkillType.getWikiUrl().toLowerCase(Locale.ENGLISH);
}
public static void sendPlayerSubSkillWikiLink(Player player, String subskillformatted, SubSkillType subSkillType) {
if (!mcMMO.p.getGeneralConfig().getUrlLinksEnabled())
return;
TextComponent.Builder wikiLinkComponent = Component.text().content(LocaleLoader.getString("Overhaul.mcMMO.MmoInfo.Wiki"));
wikiLinkComponent.decoration(TextDecoration.UNDERLINED, true);
String wikiUrl = "https://wiki.mcmmo.org/" + subskillformatted;
final String subSkillWikiLink = getSubSkillWikiLink(subSkillType);
wikiLinkComponent.clickEvent(ClickEvent.openUrl(subSkillWikiLink));
wikiLinkComponent.clickEvent(ClickEvent.openUrl(wikiUrl));
TextComponent.Builder componentBuilder = Component.text().content(subskillformatted).append(Component.newline()).append(Component.text(wikiUrl)).color(NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, true);
TextComponent.Builder componentBuilder = Component.text().content(subskillformatted).append(Component.newline()).append(Component.text(subSkillWikiLink)).color(NamedTextColor.GRAY).decoration(TextDecoration.ITALIC, true);
wikiLinkComponent.hoverEvent(HoverEvent.showText(componentBuilder.build()));

View File

@ -17,7 +17,6 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
@ -74,8 +73,9 @@ class WoodcuttingTest extends MMOTestEnvironment {
woodcuttingManager.processBonusDropCheck(blockState);
// verify bonus drops were spawned
// TODO: Can fail if triple drops happen, need to update test
Mockito.verify(woodcuttingManager, Mockito.times(1)).spawnHarvestLumberBonusDrops(blockState);
// TODO: using at least once since triple drops can also happen
// TODO: Change the test env to disallow triple drop in the future
Mockito.verify(woodcuttingManager, Mockito.atLeastOnce()).spawnHarvestLumberBonusDrops(blockState);
}
@Test