-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
163 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
spigot/src/main/java/ru/brikster/chatty/command/handler/SpyCommandHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package ru.brikster.chatty.command.handler; | ||
|
||
import cloud.commandframework.context.CommandContext; | ||
import cloud.commandframework.execution.CommandExecutionHandler; | ||
import lombok.RequiredArgsConstructor; | ||
import net.kyori.adventure.platform.bukkit.BukkitAudiences; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.Player; | ||
import org.checkerframework.checker.nullness.qual.NonNull; | ||
import ru.brikster.chatty.config.file.MessagesConfig; | ||
import ru.brikster.chatty.repository.player.PlayerDataRepository; | ||
|
||
import javax.inject.Inject; | ||
import javax.inject.Singleton; | ||
|
||
@Singleton | ||
@RequiredArgsConstructor(onConstructor_ = {@Inject}) | ||
public final class SpyCommandHandler implements CommandExecutionHandler<CommandSender> { | ||
|
||
private final PlayerDataRepository playerDataRepository; | ||
private final MessagesConfig messagesConfig; | ||
private final BukkitAudiences audiences; | ||
|
||
@Override | ||
public void execute(@NonNull CommandContext<CommandSender> commandContext) { | ||
boolean state = commandContext.get("state"); | ||
playerDataRepository.setEnableSpy(((Player) commandContext.getSender()).getUniqueId(), state); | ||
if (state) { | ||
audiences.sender(commandContext.getSender()) | ||
.sendMessage(messagesConfig.getSpyCommandSpyIsNowEnabled()); | ||
} else { | ||
audiences.sender(commandContext.getSender()) | ||
.sendMessage(messagesConfig.getSpyCommandSpyIsNowDisabled()); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 2 additions & 0 deletions
2
spigot/src/main/resources/db/migration/mysql/V2__add_spy_mode_column.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE chatty_users | ||
ADD COLUMN spy BOOLEAN NOT NULL DEFAULT TRUE; |
2 changes: 2 additions & 0 deletions
2
spigot/src/main/resources/db/migration/postgres/V2__add_spy_mode_column.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE chatty_users | ||
ADD COLUMN spy BOOLEAN NOT NULL DEFAULT TRUE; |
2 changes: 2 additions & 0 deletions
2
spigot/src/main/resources/db/migration/sqlite/V2__add_spy_mode_column.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
ALTER TABLE users | ||
ADD COLUMN spy BOOLEAN NOT NULL DEFAULT TRUE; |