Skip to content

Commit

Permalink
style(code-style): remove unnecessary spaces and add a method style
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanGmG committed Aug 3, 2023
1 parent 2475dc1 commit d955310
Show file tree
Hide file tree
Showing 27 changed files with 59 additions and 61 deletions.
2 changes: 1 addition & 1 deletion plugin/src/main/java/me/bryang/chatlab/ChatLab.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public void onEnable() {
logger.info("Thanks for using my plugin!");
}


@Override
public void onDisable() {
services.forEach(Service::stop);
}

}
2 changes: 0 additions & 2 deletions plugin/src/main/java/me/bryang/chatlab/LocalPluginLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,5 @@ private List<RemoteRepository> mapRepositories(RepoInput... repositoryCoords){
private record RepoInput(String id, String url) {

}


}

Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public class UpdateCheckHandler {
public void init() {

URI uri;

try {
uri = new URI("https://api.github.com/repos/DevBlook/ChatLab/releases/latest");

} catch (URISyntaxException exception) {
exception.fillInStackTrace();
return;
Expand Down Expand Up @@ -69,14 +69,14 @@ public CompletableFuture<Void> request() {
});
}


public boolean updated() {
return updated;
}

public boolean requestSuccess() {
return requestSuccess;
}

public String lastVersion() {
return lastVersion;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ public void execute(@Sender Player sender, OfflinePlayer targetFormatted) {

User user = userData.get(sender.getUniqueId().toString());


if (user.containsIgnoredPlayers(target.getUniqueId())) {
messageManager.sendMessage(sender, messageSection.error.playerAlreadyIgnored,
Placeholder.unparsed("player", target.getName()));
Expand All @@ -86,9 +85,6 @@ public void execute(@Sender Player sender, OfflinePlayer targetFormatted) {
user.ignore(target.getUniqueId());
messageManager.sendMessage(sender, rootSection.ignore.ignoredPlayer,
Placeholder.unparsed("player", target.getName()));

}



}
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ public class MainCommand implements CommandClass {

@Command(names = {""})
public void executeMainSubCommand(@Sender Player sender) {

messageManager.sendMessage(sender, """
<blue>ChatLab: <white>Main plugin command.
<dark_grey>- <white>/clab reload <dark_grey>: <green>Reload the plugin.
<dark_grey>- <white>/clab check-update <dark_grey>: <green>Check update.
<dark_grey>- <white>/clab re-check <dark_grey>: <green>Send a request if has a new update.
<dark_grey>- <white>/clab about <dark_grey>: <green>See about the plugin.""");

}
@Command(names = "about")
public void executeAboutSubCommand(@Sender Player sender) {
Expand All @@ -45,7 +45,6 @@ public void executeAboutSubCommand(@Sender Player sender) {
<blue><version>
<green>>> <white>Source code: <green><u><click:open_url:'https://github.com/devblook/chatlab>[GitHub]</click></u>""",
Placeholder.unparsed("version", pluginVersion));

}

@Command(names = "reload", permission = "clab.reload")
Expand All @@ -54,7 +53,6 @@ public void executeReloadSubCommand(@Sender Player sender) {
configurationContainer.reload();
messageContainer.reload();
messageManager.sendMessage(sender, "<blue>[ChatLab] <dark_grey>| <white>Plugin has been reloaded.");

}

@Command(names = "check-update", permission = "clab.check-update")
Expand All @@ -69,7 +67,6 @@ public void executeCheckUpdateSubCommand(@Sender Player sender){

}
checkUpdate(sender);

}

@Command(names = "re-check", permission = "clab.check-update")
Expand All @@ -82,6 +79,7 @@ public void executeReCheckUpdateSubCommand(@Sender Player sender){
}

private void checkUpdate(Player sender){

if (!updateChecker.updated()){
messageManager.sendMessage(sender, """
<green>Checked! <white>The plugin has a new update.
Expand All @@ -90,7 +88,6 @@ private void checkUpdate(Player sender){
}else{
messageManager.sendMessage(sender, "<green>Checked! <white>You have the latest update!");
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public class MessageCommand implements CommandClass {
private ConfigurationContainer<MessageSection> messageContainer;
private Map<String, User> userData;
private MessageManager messageManager;

@Command(
names = {"msg", "pm", "m", "message", "tell", "w"},
desc = "Command to send a private message.")
Expand Down Expand Up @@ -63,4 +64,5 @@ public void execute(@Sender Player sender, Player target, @Text String senderMes
senderUser.recentMessenger(target.getUniqueId());
targetUser.recentMessenger(sender.getUniqueId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public void execute(@Sender Player sender, @Text String senderMessage) {
messageManager.sendMessage(target, configFile.privateMessage.toReceptor,
Placeholder.unparsed("sender", sender.getName()),
Placeholder.unparsed("message", senderMessage));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ public void execute(@Sender Player sender) {

user.privateMessages(!user.privateMessages());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ public void execute(@Sender Player sender, Player target) {
user.unIgnore(target.getUniqueId());
messageManager.sendMessage(sender, rootSection.ignore.unignoredPlayer,
Placeholder.unparsed("player", target.getName()));

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ public void reload() {
} catch (IOException exception) {
exception.fillInStackTrace();
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,5 @@ public void onChat(AsyncChatEvent event) {
messagePlaceholder);

});

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.bryang.chatlab.configuration.section.RootSection;
import me.bryang.chatlab.message.MessageManager;
import me.bryang.chatlab.user.User;
import me.bryang.chatlab.user.UserDataHandler;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
Expand All @@ -23,6 +24,7 @@ public class PlayerRegistryListener implements Listener {
private ConfigurationContainer<RootSection> configurationContainer;
private MessageManager messageManager;
private UpdateCheckHandler updateChecker;
private UserDataHandler userDataHandler;

@EventHandler
public void onRegistry(PlayerJoinEvent event) {
Expand All @@ -41,9 +43,6 @@ public void onRegistry(PlayerJoinEvent event) {
}

users.putIfAbsent(sender.getUniqueId().toString(), new User());



}

@EventHandler
Expand All @@ -64,5 +63,7 @@ public void onUnRegistry(PlayerQuitEvent event) {
user.recentMessenger(null);
target.recentMessenger(null);

userDataHandler.update(user);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ public Component formatChat(Player target, String formatMessage, TagResolver mes
}

return miniMessage.deserialize(formatMessage, tagBuilder.build());

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ private Logger provideLogger(ChatLab plugin) {
}

@Override

public void configure() {
bind(ChatLab.class)
.toInstance(plugin);
Expand All @@ -43,6 +42,7 @@ public void configure() {
bind(String.class)
.named("plugin-version")
.toInstance(plugin.getPluginMeta().getVersion());

bind(new TypeReference<Map<String, User>>() {
})
.toInstance(new HashMap<>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public void configure() {
.to(IgnoreCommand.class)
.to(UnIgnoreCommand.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@ public void configure() {
.to(PlayerRegistryListener.class)
.to(PlayerChatListener.class);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ public void configure() {
.to(CommandService.class)
.to(ListenerService.class)
.to(ManagerService.class);


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ public void start() {
listeners
.forEach(listener -> pluginManager.registerEvents(listener, plugin));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public class ManagerService implements Service {
@Override
public void start() {

userDataHandler.init();

userDataHandler.start();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ public interface Service {
default void stop() {
// do nothing
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class CommandService implements Service {

@Override
public void start() {

CommandManager commandManager = new BukkitCommandManager("ChatLab");

commandManager.setUsageBuilder(localUsageBuilder);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ public String getTranslation(Namespace namespace, String path) {


return LegacyComponentSerializer.legacySection().serialize(MiniMessage.miniMessage().deserialize(text));


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ public enum CommandUsage {
public String usage() {
return usage;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ public Component getUsage(CommandContext commandContext) {

return MiniMessage.miniMessage().deserialize(messageSection.error.noArgument,
Placeholder.unparsed("usage", commandUsage.usage()));

}

}
4 changes: 0 additions & 4 deletions plugin/src/main/java/me/bryang/chatlab/user/User.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
package me.bryang.chatlab.user;

import me.bryang.chatlab.user.gson.GsonIgnore;

import javax.annotation.Nullable;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;

public class User {

@GsonIgnore
private UUID recentMessenger;
private boolean privateMessages = true;

private final Set<String> ignoredPlayers = new HashSet<>();

@Nullable
Expand Down
Loading

0 comments on commit d955310

Please sign in to comment.