Less verbose unsupported material warnings

This commit is contained in:
nossr50 2020-04-27 17:28:27 -07:00
parent 145b2432e0
commit 34fe19e35c
5 changed files with 52 additions and 12 deletions

View File

@ -3,6 +3,7 @@ Version 2.1.126
mcMMO now has a compatibility mode, any features that require specific versions of Minecraft for full functionality will be disabled if your server is not running a compatible version, mcMMO will still function in compatibility mode, but either the feature will be modified or disabled depending on the version of the server software
New command /mmocompat - Shows information about whether or not mcMMO is fully functional or if some features are disabled due to the server software not being fully supported. Can be used by players or console.
Fixed an exploit involving fishing rods
mcMMO is now less verbose about unsupported materials found in configs
Notes:
There are no features that rely on NMS in this version, it took a lot of work to write the NMS framework and I'm going to delay implementation for future versions.

View File

@ -11,15 +11,15 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.*;
public class RepairConfig extends ConfigLoader {
private List<Repairable> repairables;
private HashSet<String> notSupported;
public RepairConfig(String fileName) {
super(fileName);
notSupported = new HashSet<>();
loadKeys();
}
@ -48,7 +48,8 @@ public class RepairConfig extends ConfigLoader {
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) {
mcMMO.p.getLogger().info("No support for repair item "+key+ " in this version of Minecraft, skipping.");
//mcMMO.p.getLogger().info("No support for repair item "+key+ " in this version of Minecraft, skipping.");
notSupported.add(key); //Collect names of unsupported items
continue;
}
@ -95,7 +96,7 @@ public class RepairConfig extends ConfigLoader {
Material repairMaterial = (repairMaterialName == null ? repairMaterialType.getDefaultMaterial() : Material.matchMaterial(repairMaterialName));
if (repairMaterial == null) {
mcMMO.p.getLogger().info("Could not find a valid repair material for item named "+key+", skipping.");
notSupported.add(key); //Collect names of unsupported items
continue;
}
@ -152,6 +153,25 @@ public class RepairConfig extends ConfigLoader {
repairables.add(repairable);
}
}
//Report unsupported
StringBuilder stringBuilder = new StringBuilder();
if(notSupported.size() > 0) {
stringBuilder.append("mcMMO found the following materials in the Repair config that are not supported by the version of Minecraft running on this server: ");
for (Iterator<String> iterator = notSupported.iterator(); iterator.hasNext(); ) {
String unsupportedMaterial = iterator.next();
if(!iterator.hasNext()) {
stringBuilder.append(unsupportedMaterial);
} else {
stringBuilder.append(unsupportedMaterial).append(", ");
}
}
mcMMO.p.getLogger().info(stringBuilder.toString());
mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
}
}
protected List<Repairable> getLoadedRepairables() {

View File

@ -12,16 +12,15 @@ import org.bukkit.Material;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.inventory.ItemStack;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
import java.util.Set;
import java.util.*;
public class SalvageConfig extends ConfigLoader {
private List<Salvageable> salvageables;
private HashSet<String> notSupported;
public SalvageConfig(String fileName) {
super(fileName);
notSupported = new HashSet<>();
loadKeys();
}
@ -45,7 +44,7 @@ public class SalvageConfig extends ConfigLoader {
Material itemMaterial = Material.matchMaterial(key);
if (itemMaterial == null) {
mcMMO.p.getLogger().info("No support for salvage item "+key+ " in this version of Minecraft, skipping.");
notSupported.add(key);
continue;
}
@ -94,7 +93,7 @@ public class SalvageConfig extends ConfigLoader {
Material salvageMaterial = (salvageMaterialName == null ? salvageMaterialType.getDefaultMaterial() : Material.matchMaterial(salvageMaterialName));
if (salvageMaterial == null) {
mcMMO.p.getLogger().info("Could not find a salvage material for item named " + key + ", skipping.");
notSupported.add(key);
continue;
}
@ -153,6 +152,25 @@ public class SalvageConfig extends ConfigLoader {
salvageables.add(salvageable);
}
}
//Report unsupported
StringBuilder stringBuilder = new StringBuilder();
if(notSupported.size() > 0) {
stringBuilder.append("mcMMO found the following materials in the Salvage config that are not supported by the version of Minecraft running on this server: ");
for (Iterator<String> iterator = notSupported.iterator(); iterator.hasNext(); ) {
String unsupportedMaterial = iterator.next();
if(!iterator.hasNext()) {
stringBuilder.append(unsupportedMaterial);
} else {
stringBuilder.append(unsupportedMaterial).append(", ");
}
}
mcMMO.p.getLogger().info(stringBuilder.toString());
mcMMO.p.getLogger().info("Items using materials that are not supported will simply be skipped.");
}
}
protected List<Salvageable> getLoadedSalvageables() {

View File

@ -71,6 +71,7 @@ public class CompatibilityManager {
}
//TODO: move to text manager
public void reportCompatibilityStatus(CommandSender commandSender) {
if(isFullyCompatibleServerSoftware) {
commandSender.sendMessage(LocaleLoader.getString("mcMMO.Template.Prefix",

View File

@ -274,7 +274,7 @@ public final class CombatUtils {
}
if (archeryManager.canDaze(target)) {
finalDamage+=archeryManager.daze((Player) target);
finalDamage+=archeryManager.daze((Player) target); //the cast is checked by the if condition
}
if (!arrow.hasMetadata(mcMMO.infiniteArrowKey) && archeryManager.canRetrieveArrows()) {