Skip to content

Commit 50c400a

Browse files
style: apply openrewrite
1 parent aade61e commit 50c400a

18 files changed

Lines changed: 68 additions & 41 deletions

File tree

PistonChat/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ description = "Advanced chat plugin for survival/anarchy servers."
88
dependencies {
99
compileOnly("com.google.code.findbugs:jsr305:3.0.2")
1010
compileOnly("io.github.miniplaceholders:miniplaceholders-api:3.1.0")
11+
compileOnly("jakarta.annotation:jakarta.annotation-api:1.3.5")
1112
compileOnly("org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT")
1213

1314
implementation("net.pistonmaster:PistonUtils:1.4.0")

PistonChat/src/main/java/net/pistonmaster/pistonchat/PistonChat.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ public void onEnable() {
7373

7474
log.info(ChatColor.DARK_GREEN + "Loading storage");
7575
var storageType = configManager.get().getString("storage");
76-
if (storageType.equalsIgnoreCase("mysql")) {
76+
if ("mysql".equalsIgnoreCase(storageType)) {
7777
storage = MySQLStorage.create(log, configManager);
78-
} else if (storageType.equalsIgnoreCase("file")) {
78+
} else if ("file".equalsIgnoreCase(storageType)) {
7979
storage = new FileStorage(log, getDataFolder().toPath());
8080
}
8181

PistonChat/src/main/java/net/pistonmaster/pistonchat/api/PistonChatEvent.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.pistonmaster.pistonchat.api;
22

3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34
import org.bukkit.entity.Player;
45
import org.bukkit.event.Cancellable;
56
import org.bukkit.event.Event;
@@ -15,7 +16,7 @@ public final class PistonChatEvent extends Event implements Cancellable {
1516
private boolean isCancelled;
1617
private String message;
1718

18-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Bukkit API convention - Player objects are meant to be shared")
19+
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Bukkit API convention - Player objects are meant to be shared")
1920
public PistonChatEvent(Player player, String message, boolean isAsync) {
2021
super(isAsync);
2122

@@ -60,7 +61,7 @@ public void setCancelled(boolean cancel) {
6061
*
6162
* @return the player who sends the message
6263
*/
63-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Bukkit API convention - Player objects are meant to be shared")
64+
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Bukkit API convention - Player objects are meant to be shared")
6465
public Player getPlayer() {
6566
return player;
6667
}

PistonChat/src/main/java/net/pistonmaster/pistonchat/api/PistonChatReceiveEvent.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.pistonmaster.pistonchat.api;
22

3+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
34
import net.kyori.adventure.text.Component;
45
import org.bukkit.entity.Player;
56
import org.bukkit.event.Cancellable;
@@ -18,7 +19,7 @@ public class PistonChatReceiveEvent extends Event implements Cancellable {
1819
private String message;
1920
private Component format;
2021

21-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Bukkit API convention - Player objects are meant to be shared")
22+
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Bukkit API convention - Player objects are meant to be shared")
2223
public PistonChatReceiveEvent(Player sender, Player receiver, String message, boolean isAsync) {
2324
super(isAsync);
2425

@@ -64,7 +65,7 @@ public void setCancelled(boolean cancel) {
6465
*
6566
* @return the player who sends the message
6667
*/
67-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Bukkit API convention - Player objects are meant to be shared")
68+
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Bukkit API convention - Player objects are meant to be shared")
6869
public Player getSender() {
6970
return sender;
7071
}
@@ -74,7 +75,7 @@ public Player getSender() {
7475
*
7576
* @return the player who receives the message
7677
*/
77-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Bukkit API convention - Player objects are meant to be shared")
78+
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Bukkit API convention - Player objects are meant to be shared")
7879
public Player getReceiver() {
7980
return receiver;
8081
}
@@ -102,7 +103,7 @@ public void setMessage(String message) {
102103
*
103104
* @return the format
104105
*/
105-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Adventure Component is immutable")
106+
@SuppressFBWarnings(value = "EI_EXPOSE_REP", justification = "Adventure Component is immutable")
106107
public Component getFormat() {
107108
return format;
108109
}
@@ -112,7 +113,7 @@ public Component getFormat() {
112113
*
113114
* @param format the format to set
114115
*/
115-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Adventure Component is immutable")
116+
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Adventure Component is immutable")
116117
public void setFormat(Component format) {
117118
this.format = format;
118119
}

PistonChat/src/main/java/net/pistonmaster/pistonchat/commands/ignore/IgnoreListCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
4545
return true;
4646
}
4747

48-
if (args[0].equalsIgnoreCase("clear")) {
48+
if ("clear".equalsIgnoreCase(args[0])) {
4949
plugin.runAsync(() -> {
5050
if (noPlayersIgnored(player)) {
5151
return;

PistonChat/src/main/java/net/pistonmaster/pistonchat/commands/whisper/MessageCommandHelper.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,7 @@ public static void sendWhisper(PistonChat plugin, CommandSender sender, CommandS
2121

2222
plugin.getCommonTool().sendWhisperTo(sender, message, receiver);
2323
}
24+
25+
private MessageCommandHelper() {
26+
}
2427
}

PistonChat/src/main/java/net/pistonmaster/pistonchat/storage/file/FileStorage.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.google.gson.Gson;
44
import com.google.gson.GsonBuilder;
55
import com.google.gson.reflect.TypeToken;
6+
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
67
import net.md_5.bungee.api.ChatColor;
78
import net.pistonmaster.pistonchat.storage.PCStorage;
89

@@ -32,7 +33,7 @@ public class FileStorage implements PCStorage {
3233
private final Map<UUID, Boolean> whisperSettings = new ConcurrentHashMap<>();
3334
private final Map<UUID, List<UUID>> ignoreList = new ConcurrentHashMap<>();
3435

35-
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Logger is a shared resource by design")
36+
@SuppressFBWarnings(value = "EI_EXPOSE_REP2", justification = "Logger is a shared resource by design")
3637
public FileStorage(Logger log, Path dataFolder) {
3738
this.log = log;
3839

PistonChat/src/main/java/net/pistonmaster/pistonchat/storage/mysql/MySQLStorage.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,24 @@ public static MySQLStorage create(Logger log, ConfigManager configManager) {
3030
try {
3131
dataSource.setUser(config.getString("mysql.username"));
3232
dataSource.setPassword(config.getString("mysql.password"));
33-
dataSource.setUrl("jdbc:mariadb://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port") +
34-
"/" + config.getString("mysql.database")
33+
dataSource.setUrl("jdbc:mariadb://" + config.getString("mysql.host") + ":" + config.getInt("mysql.port")
34+
+ "/" + config.getString("mysql.database")
3535
+ "?sslMode=disable&serverTimezone=UTC&maxPoolSize=10"
3636
);
3737

3838
try (Connection connection = dataSource.getConnection();
3939
var stmt1 = connection.createStatement();
4040
var stmt2 = connection.createStatement();
4141
var stmt3 = connection.createStatement()) {
42-
stmt1.execute("CREATE TABLE IF NOT EXISTS `pistonchat_settings_chat` (`uuid` VARCHAR(36) NOT NULL," +
43-
"`chat_enabled` tinyint(1) NOT NULL," +
44-
"PRIMARY KEY (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
45-
stmt2.execute("CREATE TABLE IF NOT EXISTS `pistonchat_settings_whisper` (`uuid` VARCHAR(36) NOT NULL," +
46-
"`whisper_enabled` tinyint(1) NOT NULL," +
47-
"PRIMARY KEY (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
48-
stmt3.execute("CREATE TABLE IF NOT EXISTS `pistonchat_hard_ignores` (`uuid` VARCHAR(36) NOT NULL," +
49-
"`ignored_uuid` VARCHAR(36) NOT NULL," +
50-
"PRIMARY KEY (`uuid`, `ignored_uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
42+
stmt1.execute("CREATE TABLE IF NOT EXISTS `pistonchat_settings_chat` (`uuid` VARCHAR(36) NOT NULL,"
43+
+ "`chat_enabled` tinyint(1) NOT NULL,"
44+
+ "PRIMARY KEY (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
45+
stmt2.execute("CREATE TABLE IF NOT EXISTS `pistonchat_settings_whisper` (`uuid` VARCHAR(36) NOT NULL,"
46+
+ "`whisper_enabled` tinyint(1) NOT NULL,"
47+
+ "PRIMARY KEY (`uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
48+
stmt3.execute("CREATE TABLE IF NOT EXISTS `pistonchat_hard_ignores` (`uuid` VARCHAR(36) NOT NULL,"
49+
+ "`ignored_uuid` VARCHAR(36) NOT NULL,"
50+
+ "PRIMARY KEY (`uuid`, `ignored_uuid`)) ENGINE=InnoDB DEFAULT CHARSET=utf8;");
5151
}
5252
} catch (SQLException e) {
5353
log.log(Level.SEVERE, "Failed to initialize database connection", e);

PistonChat/src/main/java/net/pistonmaster/pistonchat/tools/CacheTool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ private void indexConsole(CommandSender sender) {
9696

9797
@RequiredArgsConstructor
9898
private static class MessageData {
99-
UUID sentTo = null;
100-
UUID messagedOf = null;
99+
UUID sentTo;
100+
UUID messagedOf;
101101
}
102102
}

PistonChat/src/main/java/net/pistonmaster/pistonchat/tools/CommonTool.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ public Optional<TextColor> getChatColorFor(String message, Player player) {
145145
for (String str : config.getConfigurationSection("prefixes").getKeys(false)) {
146146
ConfigurationSection section = config.getConfigurationSection("prefixes." + str);
147147
String prefix = section.getString("prefix");
148-
if (!prefix.equalsIgnoreCase("/")
148+
if (!"/".equalsIgnoreCase(prefix)
149149
&& message.toLowerCase(Locale.ROOT).startsWith(prefix)
150150
&& player.hasPermission("pistonchat.prefix." + str.toLowerCase(Locale.ROOT))) {
151151
return Optional.of(NamedTextColor.NAMES.valueOrThrow(section.getString("color").toLowerCase(Locale.ROOT)));
@@ -171,7 +171,7 @@ public void sendChatMessage(Player chatter, String message, Player receiver, @Nu
171171
String hoverText = plugin.getConfig().getString("hover-text");
172172

173173
formatComponent = formatComponent
174-
.clickEvent(ClickEvent.suggestCommand(String.format("/w %s ", chatter.getName())))
174+
.clickEvent(ClickEvent.suggestCommand("/w %s ".formatted(chatter.getName())))
175175
.hoverEvent(HoverEvent.showText(MiniMessage.miniMessage().deserialize(hoverText, new RelationalAudience<>(chatterAudience, receiverAudience), TagResolver.resolver(
176176
miniPlaceholderResolver,
177177
getStrippedNameResolver(chatter)

0 commit comments

Comments
 (0)