Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakubk15 committed Jul 7, 2024
1 parent 6239d4f commit f4832c0
Show file tree
Hide file tree
Showing 15 changed files with 38 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public void handle(Invocation<CommandSender> invocation, InvalidUsage<CommandSen

for (String scheme : schematics) {
Formatter formatter = new Formatter()
.register("{USAGE}", scheme);
.register("{USAGE}", scheme);

this.announcer.sendMessage(invocation.sender(), formatter.format(this.config.messages.invalidUsage));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public void handle(Invocation<CommandSender> invocation, MissingPermissions miss
String permissions = missingPermissions.asJoinedText();

Formatter formatter = new Formatter()
.register("{PERMISSION}", permissions);
.register("{PERMISSION}", permissions);

this.announcer.sendMessage(invocation.sender(), formatter.format(this.config.messages.noPermission));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
public class ConfigurationManager {

private static final Cdn CDN = CdnFactory
.createYamlLike()
.getSettings()
.withComposer(PositionComposer.class, new PositionComposer())
.build();
.createYamlLike()
.getSettings()
.withComposer(PositionComposer.class, new PositionComposer())
.build();

private final Set<ReloadableConfig> configs = new HashSet<>();
private final File dataFolder;
Expand All @@ -25,10 +25,10 @@ public ConfigurationManager(File dataFolder) {

public <T extends ReloadableConfig> T load(T config) {
CDN.load(config.resource(this.dataFolder), config)
.orThrow(RuntimeException::new);
.orThrow(RuntimeException::new);

CDN.render(config, config.resource(this.dataFolder))
.orThrow(RuntimeException::new);
.orThrow(RuntimeException::new);

this.configs.add(config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import org.bukkit.Material;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

import java.util.List;

import static com.eternalcode.parcellockers.util.AdventureUtil.RESET_ITEM;
import org.bukkit.inventory.ItemStack;
import org.jetbrains.annotations.NotNull;

@Contextual
public class ConfigItem {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public void onBlockBurn(BlockBurnEvent event) {
Block block = event.getBlock();
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
event.setCancelled(true);
}
Expand All @@ -80,7 +80,7 @@ public void onBlockExplode(BlockExplodeEvent event) {
Block block = event.getBlock();
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
event.setCancelled(true);
}
Expand All @@ -100,7 +100,7 @@ public void onBlockIgnite(BlockIgniteEvent event) {
Block block = event.getBlock();
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
event.setCancelled(true);
}
Expand All @@ -111,7 +111,7 @@ public void onBlockDamage(BlockDamageEvent event) {
Block block = event.getBlock();
Location location = block.getLocation();
Position position = PositionAdapter.convert(location);

if (this.parcelLockerRepository.isInCache(position)) {
event.setCancelled(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
public class NotificationAnnouncer {

private static final Map<NotificationType, BiConsumer<Audience, Component>> NOTIFICATION_HANDLERS = Map.of(
NotificationType.CHAT, Audience::sendMessage,
NotificationType.ACTION_BAR, Audience::sendActionBar,
NotificationType.TITLE, (audience, component) -> audience.showTitle(Title.title(component, Component.empty())),
NotificationType.SUBTITLE, (audience, component) -> audience.showTitle(Title.title(Component.empty(), component))
NotificationType.CHAT, Audience::sendMessage,
NotificationType.ACTION_BAR, Audience::sendActionBar,
NotificationType.TITLE, (audience, component) -> audience.showTitle(Title.title(component, Component.empty())),
NotificationType.SUBTITLE, (audience, component) -> audience.showTitle(Title.title(Component.empty(), component))
);

private final AudienceProvider audienceProvider;
Expand Down Expand Up @@ -50,7 +50,7 @@ public void sendMessage(CommandSender commandSender, String text) {
public void broadcast(String text) {
Audience audience = this.audienceProvider.all();
Component message = this.miniMessage.deserialize(text);

audience.sendMessage(message);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ protected ParseResult<Parcel> parse(Invocation<CommandSender> invocation, Argume
@Override
public SuggestionResult suggest(Invocation<CommandSender> invocation, Argument<Parcel> argument, SuggestionContext context) {
return this.databaseService.cache().values().stream()
.map(Parcel::uuid)
.map(UUID::toString)
.collect(SuggestionResult.collector());
.map(Parcel::uuid)
.map(UUID::toString)
.collect(SuggestionResult.collector());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.concurrent.CompletableFuture;

public class UpdaterService {

private static final GitRepository GIT_REPOSITORY = GitRepository.of("EternalCodeTeam", "ParcelLockers");
private final GitCheck gitCheck = new GitCheck();
private final Lazy<GitCheckResult> gitCheckResult;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ void onLoad(ServerLoadEvent event) {
for (Player player : this.server.getOnlinePlayers()) {
this.userManager.create(player.getUniqueId(), player.getName());
}
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/eternalcode/parcellockers/user/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.util.UUID;

public record User(UUID uuid, String name) {
public record User(UUID uuid, String name) {

}

Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
public final class AdventureUtil {

public static final Component RESET_ITEM = Component.text()
.decoration(TextDecoration.ITALIC, false)
.build();
.decoration(TextDecoration.ITALIC, false)
.build();

private AdventureUtil() {
throw new UnsupportedOperationException("This is a utility class and cannot be instantiated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public static String format(Duration duration, boolean removeMillis) {
}

return duration.toString()
.substring(2)
.replaceAll("(\\d[HMS])(?!$)", "$1 ")
.toLowerCase();
.substring(2)
.replaceAll("(\\d[HMS])(?!$)", "$1 ")
.toLowerCase();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public static String generateDeliveryCode() {
}

@TestOnly
public static <T> T randomEnum(Class<T> clazz){
public static <T> T randomEnum(Class<T> clazz) {
int x = RANDOM.nextInt(clazz.getEnumConstants().length);
return clazz.getEnumConstants()[x];
}
Expand All @@ -30,7 +30,7 @@ public static String randomParcelDescription() {
int rightLimit = 122; // letter 'z'
int targetStringLength = 16;

return RANDOM.ints(leftLimit, rightLimit + 1)
return RANDOM.ints(leftLimit, rightLimit + 1)
.limit(targetStringLength)
.collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append)
.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
public class Legacy {

private static final LegacyComponentSerializer AMPERSAND_SERIALIZER = LegacyComponentSerializer.builder()
.character('&')
.hexColors()
.useUnusualXRepeatedCharacterHexFormat()
.build();
.character('&')
.hexColors()
.useUnusualXRepeatedCharacterHexFormat()
.build();

public static Component component(String text) {
return AMPERSAND_SERIALIZER.deserialize(text);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ public class LegacyColorProcessor implements UnaryOperator<Component> {
@Override
public Component apply(Component component) {
return component.replaceText(builder -> builder.match(Pattern.compile(".*"))
.replacement((matchResult, builder1) -> Legacy.component(matchResult.group())));
.replacement((matchResult, builder1) -> Legacy.component(matchResult.group())));
}
}

0 comments on commit f4832c0

Please sign in to comment.