forked from SteamWar/SteamWar
PR Stuff
This commit is contained in:
@@ -85,14 +85,12 @@ public interface Chatter {
|
||||
else
|
||||
return withPlayer.apply(player);
|
||||
}
|
||||
default boolean withPlayerOrOffline(Consumer<Player> withPlayer, Runnable withOffline) {
|
||||
default void withPlayerOrOffline(Consumer<Player> withPlayer, Runnable withOffline) {
|
||||
Player player = getPlayer();
|
||||
if(player == null) {
|
||||
withOffline.run();
|
||||
return false;
|
||||
} else {
|
||||
withPlayer.accept(player);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
default void withPlayer(Consumer<Player> function) {
|
||||
|
||||
@@ -41,7 +41,7 @@ import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.function.BooleanSupplier;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class CheckCommand extends SWCommand {
|
||||
@@ -240,26 +240,26 @@ public class CheckCommand extends SWCommand {
|
||||
private void accept(){
|
||||
concludeCheckSession("freigegeben", fightTypes.get(schematic.getSchemtype()), () -> {
|
||||
Chatter owner = Chatter.of(SteamwarUser.get(schematic.getOwner()).getUUID());
|
||||
boolean isOnline = owner.withPlayerOrOffline(
|
||||
owner.withPlayerOrOffline(
|
||||
player -> owner.system("CHECK_ACCEPTED", schematic.getSchemtype().name(), schematic.getName()),
|
||||
() -> DiscordAlert.send(owner, Color.GREEN, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_ACCEPT", schematic.getName()), true)
|
||||
);
|
||||
notifyTeam(new Message("CHECK_ACCEPTED_TEAM", schematic.getName(), owner.user().getUserName()));
|
||||
|
||||
return isOnline;
|
||||
return owner.getPlayer() != null;
|
||||
});
|
||||
}
|
||||
|
||||
private void decline(String reason){
|
||||
concludeCheckSession(reason, SchematicType.Normal, () -> {
|
||||
Chatter owner = Chatter.of(SteamwarUser.get(schematic.getOwner()).getUUID());
|
||||
boolean isOnline = owner.withPlayerOrOffline(
|
||||
owner.withPlayerOrOffline(
|
||||
player -> owner.system("CHECK_DECLINED", schematic.getSchemtype().name(), schematic.getName(), reason),
|
||||
() -> DiscordAlert.send(owner, Color.RED, new Message("DC_TITLE_SCHEMINFO"), new Message("DC_SCHEM_DECLINE", schematic.getName(), reason), false)
|
||||
);
|
||||
notifyTeam(new Message("CHECK_DECLINED_TEAM", schematic.getName(), owner.user().getUserName(), reason));
|
||||
|
||||
return isOnline;
|
||||
return owner.getPlayer() != null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -272,9 +272,9 @@ public class CheckCommand extends SWCommand {
|
||||
concludeCheckSession("Prüfvorgang abgebrochen", null, () -> true);
|
||||
}
|
||||
|
||||
private void concludeCheckSession(String reason, SchematicType type, Supplier<Boolean> sendMessageIsOnline) {
|
||||
private void concludeCheckSession(String reason, SchematicType type, BooleanSupplier sendMessageIsOnline) {
|
||||
if(SchematicNode.getSchematicNode(schematic.getId()) != null) {
|
||||
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.get());
|
||||
CheckedSchematic.create(schematic, checker.user().getId(), startTime, Timestamp.from(Instant.now()), reason, sendMessageIsOnline.getAsBoolean());
|
||||
if(type != null)
|
||||
schematic.setSchemtype(type);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user