Skip to content

Commit

Permalink
Merge pull request #12 from NightMirror21/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
NightMirror21 authored Jul 7, 2023
2 parents daa3d6e + 51bb42d commit 0cde51b
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public class WLDatabase implements PlayerAccessor, CachedDatabase, PlayerListene
final Mapper<WLPlayerTable, WLPlayer> mapper;

JdbcPooledConnectionSource connection;
LoadingCache<String, WLPlayer> cache;

final LoadingCache<String, WLPlayer> cache;

final List<PlayerListener> listeners = new ArrayList<>();

public WLDatabase(DatabaseSettings settings) throws SQLException {
Expand Down
2 changes: 1 addition & 1 deletion paper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group = 'ru.nightmirror'
version = '6.1'
version = '6.2'
description = 'WhitelistByTime-Paper'

compileJava.options.encoding = "UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,12 +166,12 @@ public void add(CommandSender sender, String[] strings) {
long finalUntil = until;
playerAccessor.createOrUpdate(new WLPlayer(addNickname, until)).thenRun(() -> {
if (finalUntil == -1L) {
sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.successfully-added", "<green>%player% added to whitelist for %time%"))
sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.successfully-added", "<green>%player% <white>added to whitelist forever"))
.replaceText(builder -> builder.match("%player%").replacement(addNickname)));
} else {
sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.successfully-added-for-time", "<green>%player% will be in whitelist still %time%"))
sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.successfully-added-for-time", "<green>%player% <white>added to whitelist for <green>%time%"))
.replaceText(builder -> builder.match("%player%").replacement(addNickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(finalUntil - System.currentTimeMillis() + 1000L))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(finalUntil - System.currentTimeMillis() + 1000L))));
}
});
}));
Expand All @@ -194,39 +194,39 @@ public void time(CommandSender sender, String[] strings) {
player.setUntil(until);
playerAccessor.createOrUpdate(player).thenRun(() -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.set-time", "Now <green>%player% &fwill be in whitelist for <green>%time%"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
}, () -> {
WLPlayer player = new WLPlayer(nickname, until);
player.setUntil(until);
playerAccessor.createOrUpdate(player).thenRun(() -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.successfully-added-for-time", "<green>%player% added to whitelist for %time%"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
});
case "add" -> playerOptional.ifPresentOrElse(player -> {
player.setUntil(player.getUntil() + (until - System.currentTimeMillis()));
playerAccessor.createOrUpdate(player).thenRun(() -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.add-time", "Added <green>%time% &fto <green>%player%"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
}, () -> {
WLPlayer player = new WLPlayer(nickname, until);
playerAccessor.createOrUpdate(player).thenRun(() -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.successfully-added-for-time", "<green>%player% added to whitelist for %time%"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
});
case "remove" -> playerOptional.ifPresentOrElse(player -> {
if ((player.getUntil() - (until - System.currentTimeMillis())) > System.currentTimeMillis()) {
player.setUntil(player.getUntil() - (until - System.currentTimeMillis()));
playerAccessor.createOrUpdate(player).thenRun(() -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.remove-time", "Removed <green>%time% &ffrom <green>%player%"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
} else {
playerAccessor.delete(player).thenRun(() -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.player-removed-from-whitelist", "<yellow>%player% successfully removed from whitelist"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
}
}, () -> sender.sendMessage(ColorsConvertor.convert(config.getString("minecraft-commands.player-not-in-whitelist", "<yellow>%player% not in whitelist"))
.replaceText(builder -> builder.match("%player%").replacement(nickname))
.replaceText(builder -> builder.match("%time%").replacement(String.valueOf(until - System.currentTimeMillis() + 1000L)))));
.replaceText(builder -> builder.match("%time%").replacement(timeConvertor.getTimeLine(until - System.currentTimeMillis() + 1000L)))));
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,7 @@ private void onPlayerWhitelistCommand(PlayerCommandPreprocessEvent event) {

final Player sender = event.getPlayer();
final String[] strings = event.getMessage()
.replaceAll("/whitelist", " ")
.replaceAll("/wl", " ")
.replaceAll("whitelist", " ")
.replaceAll("wl", " ")
.replaceFirst(cmd, " ")
.trim()
.split(" ");

Expand All @@ -51,10 +48,7 @@ private void onConsoleWhitelistCommand(ServerCommandEvent event) {

final CommandSender sender = event.getSender();
final String[] strings = event.getCommand()
.replaceAll("/whitelist", " ")
.replaceAll("/wl", " ")
.replaceAll("whitelist", " ")
.replaceAll("wl", " ")
.replaceFirst(cmd, " ")
.trim()
.split(" ");

Expand Down
2 changes: 1 addition & 1 deletion paper/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: WhitelistByTime
main: ru.nightmirror.wlbytime.WhitelistByTime
version: 6.1
version: 6.2
author: NightMirror
description: Adding a player to the whitelist for a time
api-version: 1.16
Expand Down
2 changes: 1 addition & 1 deletion spigot/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ sourceCompatibility = javaVersion;
targetCompatibility = javaVersion;

group = 'ru.nightmirror'
version = '6.1'
version = '6.2'
description = 'WhitelistByTime-Spigot'

compileJava.options.encoding = "UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ private void onPlayerWhitelistCommand(PlayerCommandPreprocessEvent event) {

final Player sender = event.getPlayer();
final String[] strings = event.getMessage()
.replaceAll("/whitelist", " ")
.replaceAll("/wl", " ")
.replaceAll("whitelist", " ")
.replaceAll("wl", " ")
.replaceFirst(cmd, " ")
.trim()
.split(" ");

Expand All @@ -50,10 +47,7 @@ private void onConsoleWhitelistCommand(ServerCommandEvent event) {

final CommandSender sender = event.getSender();
final String[] strings = event.getCommand()
.replaceAll("/whitelist", " ")
.replaceAll("/wl", " ")
.replaceAll("whitelist", " ")
.replaceAll("wl", " ")
.replaceFirst(cmd, " ")
.trim()
.split(" ");

Expand Down
2 changes: 1 addition & 1 deletion spigot/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: WhitelistByTime
main: ru.nightmirror.wlbytime.WhitelistByTime
version: 6.1
version: 6.2
author: NightMirror
description: Adding a player to the whitelist for a time
api-version: 1.16
Expand Down

0 comments on commit 0cde51b

Please sign in to comment.