chore: pre-commit linting

This commit is contained in:
Sekwah 2024-09-07 03:22:03 +01:00
parent 5373620243
commit ee21d237d3
5 changed files with 24 additions and 18 deletions

View File

@ -75,8 +75,9 @@ public abstract class CreateTaggedSubCommand implements SubCommand {
String baseString = endsWithSplit String baseString = endsWithSplit
? argData ? argData
: argData.substring( : argData.substring(
0, 0,
argData.lastIndexOf(multiTagSplit) + 1); argData.lastIndexOf(multiTagSplit)
+ 1);
tagSuggestions = tagSuggestions =
tagSuggestions tagSuggestions

View File

@ -127,8 +127,8 @@ public class ReflectiveConstructor<T> extends Constructor {
} }
} catch (Exception e) { } catch (Exception e) {
infoLogger.warning("Failed to set field " + field.getName() infoLogger.warning("Failed to set field " + field.getName()
+ " in " + currentClass.getName() + ": " + " in " + currentClass.getName()
+ e.getMessage()); + ": " + e.getMessage());
infoLogger.error(e); infoLogger.error(e);
throw new RuntimeException("Failed to set field " throw new RuntimeException("Failed to set field "
+ field.getName() + " in " + field.getName() + " in "
@ -193,7 +193,6 @@ public class ReflectiveConstructor<T> extends Constructor {
*/ */
private void setField(Object instance, Field field, Object value) private void setField(Object instance, Field field, Object value)
throws IllegalAccessException { throws IllegalAccessException {
// Check for numeric type compatibility and cast if necessary // Check for numeric type compatibility and cast if necessary
if (field.getType() == float.class &&value instanceof Double) { if (field.getType() == float.class &&value instanceof Double) {
value = ((Double) value).floatValue(); value = ((Double) value).floatValue();

View File

@ -49,9 +49,9 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
ActivationData activeData, String[] argData) { ActivationData activeData, String[] argData) {
var commandPortals = configRepository.getCommandPortals(); var commandPortals = configRepository.getCommandPortals();
if(!commandPortals.enabled) { if (!commandPortals.enabled) {
player.sendMessage(Lang.translate("messageprefix.negative") player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.disabled")); + Lang.translate("tag.command.disabled"));
return false; return false;
} }
@ -60,22 +60,26 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
switch (executionCommand) { switch (executionCommand) {
case '!': case '!':
if (!commandPortals.op) { if (!commandPortals.op) {
player.sendMessage(Lang.translate("messageprefix.negative") player.sendMessage(
+ Lang.translate("tag.command.op.disabled")); Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.op.disabled"));
return false; return false;
} }
break; break;
case '#': case '#':
if (!commandPortals.console) { if (!commandPortals.console) {
player.sendMessage(Lang.translate("messageprefix.negative") player.sendMessage(
+ Lang.translate("tag.command.console.disabled")); Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.console.disabled"));
return false; return false;
} }
break; break;
case '^': case '^':
if (!commandPortals.permsWildcard) { if (!commandPortals.permsWildcard) {
player.sendMessage(Lang.translate("messageprefix.negative") player.sendMessage(
+ Lang.translate("tag.command.permswildcard.disabled")); Lang.translate("messageprefix.negative")
+ Lang.translate(
"tag.command.permswildcard.disabled"));
return false; return false;
} }
break; break;
@ -134,9 +138,9 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
String[] argData) { String[] argData) {
if (argData != null) { if (argData != null) {
var commandPortals = configRepository.getCommandPortals(); var commandPortals = configRepository.getCommandPortals();
if(!commandPortals.enabled) { if (!commandPortals.enabled) {
player.sendMessage(Lang.translate("messageprefix.negative") player.sendMessage(Lang.translate("messageprefix.negative")
+ Lang.translate("tag.command.disabled")); + Lang.translate("tag.command.disabled"));
return false; return false;
} }
for (String command : argData) { for (String command : argData) {

View File

@ -51,13 +51,15 @@ public class FriendlyDataOutput {
public void writeUtf(String text, int maxLength) { public void writeUtf(String text, int maxLength) {
if (text.length() > maxLength) { if (text.length() > maxLength) {
throw new EncoderException("String too big (was " + text.length() throw new EncoderException("String too big (was " + text.length()
+ " characters, max " + maxLength + ")"); + " characters, max " + maxLength
+ ")");
} else { } else {
byte[] abyte = text.getBytes(StandardCharsets.UTF_8); byte[] abyte = text.getBytes(StandardCharsets.UTF_8);
int i = getMaxEncodedUtfLength(maxLength); int i = getMaxEncodedUtfLength(maxLength);
if (abyte.length > i) { if (abyte.length > i) {
throw new EncoderException("String too big (was " + abyte.length throw new EncoderException("String too big (was " + abyte.length
+ " bytes encoded, max " + i + ")"); + " bytes encoded, max " + i
+ ")");
} else { } else {
this.writeVarInt(abyte.length); this.writeVarInt(abyte.length);
this.writeBytes(abyte); this.writeBytes(abyte);

View File

@ -51,7 +51,7 @@ public class TagReader {
currentIdentifier = arg.substring(0, colonIndex); currentIdentifier = arg.substring(0, colonIndex);
currentValue = new StringBuilder(arg.substring(colonIndex + 1)); currentValue = new StringBuilder(arg.substring(colonIndex + 1));
inQuotes = currentValue.toString().startsWith("\""); inQuotes = currentValue.toString().startsWith("\"");
if(inQuotes) { if (inQuotes) {
currentValue.deleteCharAt(0); currentValue.deleteCharAt(0);
} }
} else { } else {