chore: pre-commit changes [skip ci]

This commit is contained in:
github-actions[bot] 2024-08-31 01:48:02 +00:00 committed by Sekwah
parent 833399e8d0
commit 901b4a9989
6 changed files with 59 additions and 61 deletions

View File

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

View File

@ -13,7 +13,6 @@ import com.sekwah.advancedportals.core.tags.activation.TriggerBlockTag;
import com.sekwah.advancedportals.core.util.Lang;
import com.sekwah.advancedportals.core.warphandler.ActivationData;
import com.sekwah.advancedportals.core.warphandler.Tag;
import java.util.*;
/**
@ -105,7 +104,8 @@ public class AdvancedPortal implements TagTarget {
}*/
/**
* @param player The player on the server attempting to use an advanced
* @param player The player on the server attempting to use an
* advanced
* portal
* @param moveActivated if the portal was activated by a move event (won't
* trigger knockback)
@ -117,15 +117,15 @@ public class AdvancedPortal implements TagTarget {
return false;
if (playerData.hasJoinCooldown()) {
var cooldown =
(int) Math.ceil(playerData.getJoinCooldownLeft() / 1000D);
(int) Math.ceil(playerData.getJoinCooldownLeft() / 1000D);
player.sendMessage(Lang.translateInsertVariables(
"portal.cooldown.join", cooldown,
Lang.translate(cooldown == 1 ? "time.second"
: "time.seconds")));
"portal.cooldown.join", cooldown,
Lang.translate(cooldown == 1 ? "time.second"
: "time.seconds")));
if (configRepository.playFailSound()) {
var rand = new Random();
player.playSound("block.portal.travel", 0.05f,
rand.nextFloat() * 0.4F + 0.8F);
rand.nextFloat() * 0.4F + 0.8F);
}
return false;
}
@ -139,28 +139,28 @@ public class AdvancedPortal implements TagTarget {
for (DataTag portalTag : portalTags) {
Tag.Activation activationHandler =
tagRegistry.getActivationHandler(portalTag.NAME);
if (activationHandler != null && !activationHandler.preActivated(
this, player, data,
this.getArgValues(portalTag.NAME))) {
tagRegistry.getActivationHandler(portalTag.NAME);
if (activationHandler != null
&& !activationHandler.preActivated(
this, player, data, this.getArgValues(portalTag.NAME))) {
return false;
}
}
for (DataTag portalTag : portalTags) {
Tag.Activation activationHandler =
tagRegistry.getActivationHandler(portalTag.NAME);
if (activationHandler != null && !activationHandler.activated(
this, player, data,
this.getArgValues(portalTag.NAME))) {
tagRegistry.getActivationHandler(portalTag.NAME);
if (activationHandler != null
&& !activationHandler.activated(
this, player, data, this.getArgValues(portalTag.NAME))) {
return false;
}
}
for (DataTag portalTag : portalTags) {
Tag.Activation activationHandler =
tagRegistry.getActivationHandler(portalTag.NAME);
tagRegistry.getActivationHandler(portalTag.NAME);
if (activationHandler != null) {
activationHandler.postActivated(
this, player, data, this.getArgValues(portalTag.NAME));
this, player, data, this.getArgValues(portalTag.NAME));
}
}
if (data.hasActivated()) {
@ -189,12 +189,12 @@ public class AdvancedPortal implements TagTarget {
double playerZ = loc.getPosZ();
return Objects.equals(loc.getWorldName(), this.minLoc.getWorldName())
&& playerX >= this.minLoc.getPosX() - additionalArea
&& playerX < this.maxLoc.getPosX() + 1 + additionalArea
&& playerY >= this.minLoc.getPosY() - additionalArea
&& playerY < this.maxLoc.getPosY() + 1 + additionalArea
&& playerZ >= this.minLoc.getPosZ() - additionalArea
&& playerZ < this.maxLoc.getPosZ() + 1 + additionalArea;
&& playerX >= this.minLoc.getPosX() - additionalArea
&& playerX < this.maxLoc.getPosX() + 1 + additionalArea
&& playerY >= this.minLoc.getPosY() - additionalArea
&& playerY < this.maxLoc.getPosY() + 1 + additionalArea
&& playerZ >= this.minLoc.getPosZ() - additionalArea
&& playerZ < this.maxLoc.getPosZ() + 1 + additionalArea;
}
public void setArgValues(DataTag portalTag) {

View File

@ -127,8 +127,8 @@ public class ReflectiveConstructor<T> extends Constructor {
}
} catch (Exception e) {
infoLogger.warning("Failed to set field " + field.getName()
+ " in " + currentClass.getName()
+ ": " + e.getMessage());
+ " in " + currentClass.getName() + ": "
+ e.getMessage());
infoLogger.error(e);
throw new RuntimeException("Failed to set field "
+ field.getName() + " in "

View File

@ -10,7 +10,6 @@ import com.sekwah.advancedportals.core.warphandler.Tag;
import javax.annotation.Nullable;
public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
@Inject
ConfigRepository configRepository;
@ -59,40 +58,41 @@ public class CommandTag implements Tag.Activation, Tag.Split, Tag.Creation {
@Override
public void postActivated(TagTarget target, PlayerContainer player,
ActivationData activationData, String[] argData) {
for (String command : argData) {
char executionCommand = command.charAt(0);
String formattedCommand =
command.replaceAll("@player", player.getName());
for (String command : argData) {
char executionCommand = command.charAt(0);
String formattedCommand =
command.replaceAll("@player", player.getName());
switch (executionCommand) {
case '!':
player.getServer().dispatchCommand(
player.getUUID(), formattedCommand.substring(1),
CommandLevel.OP);
break;
case '#':
player.getServer().dispatchCommand(
player.getUUID(), formattedCommand.substring(1),
CommandLevel.CONSOLE);
break;
case '^':
player.getServer().dispatchCommand(
player.getUUID(), formattedCommand.substring(1),
CommandLevel.PERMISSION_WILDCARD);
break;
default:
player.getServer().dispatchCommand(player.getUUID(),
formattedCommand,
CommandLevel.PLAYER);
break;
}
switch (executionCommand) {
case '!':
player.getServer().dispatchCommand(
player.getUUID(), formattedCommand.substring(1),
CommandLevel.OP);
break;
case '#':
player.getServer().dispatchCommand(
player.getUUID(), formattedCommand.substring(1),
CommandLevel.CONSOLE);
break;
case '^':
player.getServer().dispatchCommand(
player.getUUID(), formattedCommand.substring(1),
CommandLevel.PERMISSION_WILDCARD);
break;
default:
player.getServer().dispatchCommand(player.getUUID(),
formattedCommand,
CommandLevel.PLAYER);
break;
}
}
}
@Override
public boolean activated(TagTarget target, PlayerContainer player,
ActivationData activationData, String[] argData) {
// Will trigger in the post activation stage to make sure the command triggers after any teleportation
// Will trigger in the post activation stage to make sure the command
// triggers after any teleportation
activationData.setWarpStatus(ActivationData.WarpedStatus.ACTIVATED);
return true;
}

View File

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

View File

@ -25,7 +25,8 @@ public class ActivationData {
}
public void setWarpStatus(WarpedStatus warped) {
if (this.warpStatus == WarpedStatus.WARPED || (this.warpStatus == WarpedStatus.ACTIVATED
if (this.warpStatus == WarpedStatus.WARPED
|| (this.warpStatus == WarpedStatus.ACTIVATED
&& warped != WarpedStatus.WARPED)) {
return;
}