Merge pull request #1 from awesomemoder316/feature/command-whitelist&blacklist
Update to Version 2.2
This commit is contained in:
commit
896e659e93
@ -5,7 +5,7 @@ boot-error = Error occured while starting WebSocket Server.
|
|||||||
connection-resumed-message = Connected. Already logged in, welcome back!
|
connection-resumed-message = Connected. Already logged in, welcome back!
|
||||||
connection-resumed-console = [WebConsole] Connected and resumed session from {0}
|
connection-resumed-console = [WebConsole] Connected and resumed session from {0}
|
||||||
connection-login-message = Connection started, waiting login
|
connection-login-message = Connection started, waiting login
|
||||||
connection-login-console = [WebConsole] Connected and waiting login from {0}
|
connection-login-console = [WebConsole] Connected and waiting login from {0}
|
||||||
unknown-command-message = Unknown command
|
unknown-command-message = Unknown command
|
||||||
unknown-command-console = [WebConsole] Signal "{0}" was not processed since is not valid. Is your plugin/web interface up to date?
|
unknown-command-console = [WebConsole] Signal "{0}" was not processed since is not valid. Is your plugin/web interface up to date?
|
||||||
forbidden-message = Forbidden
|
forbidden-message = Forbidden
|
||||||
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Attempted to send a message to a discon
|
|||||||
cpu-usage-message = Usage is {0}%
|
cpu-usage-message = Usage is {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} tried to run {1} without permission.
|
no-send-permission-console = [WebConsole] {0} tried to run {1} without permission.
|
||||||
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Pokus o odeslání zprávy odpojenému
|
|||||||
cpu-usage-message = Využití je {0}%
|
cpu-usage-message = Využití je {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} se pokusil spustit {1} bez povolení.
|
no-send-permission-console = [WebConsole] {0} se pokusil spustit {1} bez povolení.
|
||||||
cmd-executed-console = [WebConsole] {0} spustil "{1}".
|
cmd-executed-console = [WebConsole] {0} spustil "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Es wurde versucht, eine Nachricht an ei
|
|||||||
cpu-usage-message = Die CPU Auslastung liegt bei {0}%.
|
cpu-usage-message = Die CPU Auslastung liegt bei {0}%.
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} hat versucht, {1} ohne Erlaubnis auszuführen.
|
no-send-permission-console = [WebConsole] {0} hat versucht, {1} ohne Erlaubnis auszuführen.
|
||||||
cmd-executed-console = [WebConsole] {0} hat "{1}" ausgeführt.
|
cmd-executed-console = [WebConsole] {0} hat "{1}" ausgeführt.
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
@ -37,7 +37,7 @@ ram-usage-message = {0} frei, {1} benutzt, {2} maximal
|
|||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = Die WebConsole Version ist {0}.
|
webconsole-version = Die WebConsole Version ist {0}.
|
||||||
webconsole-no-connections = Aktuell ist niemand mit der WebConsole verbunden
|
webconsole-no-connections = Aktuell ist niemand mit der WebConsole verbunden
|
||||||
webconsole-active-connections = Aktive Verbindugen von:
|
webconsole-active-connections = Aktive Verbindugen von:
|
||||||
|
|
||||||
# ReadLogFileCommand.java
|
# ReadLogFileCommand.java
|
||||||
log-read-error = Fehler beim lesen der 'latest.log'-Logdatei
|
log-read-error = Fehler beim lesen der 'latest.log'-Logdatei
|
||||||
|
@ -5,7 +5,7 @@ boot-error = Error occured while starting WebSocket Server.
|
|||||||
connection-resumed-message = Connected. Already logged in, welcome back!
|
connection-resumed-message = Connected. Already logged in, welcome back!
|
||||||
connection-resumed-console = [WebConsole] Connected and resumed session from {0}
|
connection-resumed-console = [WebConsole] Connected and resumed session from {0}
|
||||||
connection-login-message = Connection started, waiting login
|
connection-login-message = Connection started, waiting login
|
||||||
connection-login-console = [WebConsole] Connected and waiting login from {0}
|
connection-login-console = [WebConsole] Connected and waiting login from {0}
|
||||||
unknown-command-message = Unknown command
|
unknown-command-message = Unknown command
|
||||||
unknown-command-console = [WebConsole] Signal "{0}" was not processed since is not valid. Is your plugin/web interface up to date?
|
unknown-command-console = [WebConsole] Signal "{0}" was not processed since is not valid. Is your plugin/web interface up to date?
|
||||||
forbidden-message = Forbidden
|
forbidden-message = Forbidden
|
||||||
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Attempted to send a message to a discon
|
|||||||
cpu-usage-message = Usage is {0}%
|
cpu-usage-message = Usage is {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} tried to run {1} without permission.
|
no-send-permission-console = [WebConsole] {0} tried to run {1} without permission.
|
||||||
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
cmd-executed-console = [WebConsole] {0} executed "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Se intentó enviar un mensaje a un clie
|
|||||||
cpu-usage-message = En uso {0}%
|
cpu-usage-message = En uso {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} intentó ejecutar {1} sin permiso.
|
no-send-permission-console = [WebConsole] {0} intentó ejecutar {1} sin permiso.
|
||||||
cmd-executed-console = [WebConsole] {0} ejecutó "{1}".
|
cmd-executed-console = [WebConsole] {0} ejecutó "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Vous avez tenté d'envoyer un message
|
|||||||
cpu-usage-message = L'utilisation est {0}%
|
cpu-usage-message = L'utilisation est {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} a tenté d'exécuter {1} sans autorisation.
|
no-send-permission-console = [WebConsole] {0} a tenté d'exécuter {1} sans autorisation.
|
||||||
cmd-executed-console = [WebConsole] {0} a exécuté "{1}".
|
cmd-executed-console = [WebConsole] {0} a exécuté "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -5,7 +5,7 @@ boot-error = C''è stato un errore mentre avviavo WebConsole server.
|
|||||||
connection-resumed-message = Connesso. Login già fatto, Bentornato!
|
connection-resumed-message = Connesso. Login già fatto, Bentornato!
|
||||||
connection-resumed-console = [WebConsole] Connesso e sessione ripresa da {0}
|
connection-resumed-console = [WebConsole] Connesso e sessione ripresa da {0}
|
||||||
connection-login-message = Connessione stabilita, attendo il login
|
connection-login-message = Connessione stabilita, attendo il login
|
||||||
connection-login-console = [WebConsole] Connesso e attendo login da {0}
|
connection-login-console = [WebConsole] Connesso e attendo login da {0}
|
||||||
unknown-command-message = Comando sconosciuto
|
unknown-command-message = Comando sconosciuto
|
||||||
unknown-command-console = [WebConsole] Il segnale "{0}" non è stato processato siccome non è valido. Il tuo plugin/web interface è aggiornato?
|
unknown-command-console = [WebConsole] Il segnale "{0}" non è stato processato siccome non è valido. Il tuo plugin/web interface è aggiornato?
|
||||||
forbidden-message = Proibito
|
forbidden-message = Proibito
|
||||||
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Tentativo di inviare un messaggio a un
|
|||||||
cpu-usage-message = L''uso è {0}%
|
cpu-usage-message = L''uso è {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} ha provato a eseguire {1} senza autorizzazione.
|
no-send-permission-console = [WebConsole] {0} ha provato a eseguire {1} senza autorizzazione.
|
||||||
cmd-executed-console = [WebConsole] {0} eseguito "{1}".
|
cmd-executed-console = [WebConsole] {0} eseguito "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -5,7 +5,7 @@ boot-error = WebSocket 서버를 시작하는 도중 오류가 발생하였습
|
|||||||
connection-resumed-message = 연결되었습니다. 이미 로그인되어 있습니다. 안녕하세요!
|
connection-resumed-message = 연결되었습니다. 이미 로그인되어 있습니다. 안녕하세요!
|
||||||
connection-resumed-console = [WebConsole] 연결되었으며 {0}로부터 온 세션을 이어서 시작하였습니다.
|
connection-resumed-console = [WebConsole] 연결되었으며 {0}로부터 온 세션을 이어서 시작하였습니다.
|
||||||
connection-login-message = 연결이 시작되었고, 로그인을 기다리는 중입니다
|
connection-login-message = 연결이 시작되었고, 로그인을 기다리는 중입니다
|
||||||
connection-login-console = [WebConsole] 연결되었으며 {0}로부터 로그인을 기다리는 중입니다
|
connection-login-console = [WebConsole] 연결되었으며 {0}로부터 로그인을 기다리는 중입니다
|
||||||
unknown-command-message = 알 수 없는 명령어입니다
|
unknown-command-message = 알 수 없는 명령어입니다
|
||||||
unknown-command-console = [WebConsole] "{0}" 신호는 알맞지 않기 때문에 처리되지 않았습니다. 플러그인 또는 웹 UI가 최신입니까?
|
unknown-command-console = [WebConsole] "{0}" 신호는 알맞지 않기 때문에 처리되지 않았습니다. 플러그인 또는 웹 UI가 최신입니까?
|
||||||
forbidden-message = 제한되었습니다
|
forbidden-message = 제한되었습니다
|
||||||
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] 연결이 끊긴 WebSocket 클라이언
|
|||||||
cpu-usage-message = 사용량은 {0}%입니다
|
cpu-usage-message = 사용량은 {0}%입니다
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0}이(가) {1}을(를) 권한 없이 실행하려고 했습니다.
|
no-send-permission-console = [WebConsole] {0}이(가) {1}을(를) 권한 없이 실행하려고 했습니다.
|
||||||
cmd-executed-console = [WebConsole] {0}이(가) "{1}"을(를) 실행하였습니다.
|
cmd-executed-console = [WebConsole] {0}이(가) "{1}"을(를) 실행하였습니다.
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Poging om een bericht te sturen naar ee
|
|||||||
cpu-usage-message = Verbruik is {0}%
|
cpu-usage-message = Verbruik is {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} heeft geprobeerd {1} uit te voeren zonder toestemming.
|
no-send-permission-console = [WebConsole] {0} heeft geprobeerd {1} uit te voeren zonder toestemming.
|
||||||
cmd-executed-console = [WebConsole] {0} voerde "{1}" uit.
|
cmd-executed-console = [WebConsole] {0} voerde "{1}" uit.
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Tentativa de enviar uma mensagem para u
|
|||||||
cpu-usage-message = Consumindo {0}%
|
cpu-usage-message = Consumindo {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} tentou executar o {1} sem permissão.
|
no-send-permission-console = [WebConsole] {0} tentou executar o {1} sem permissão.
|
||||||
cmd-executed-console = [WebConsole] {0} executou "{1}".
|
cmd-executed-console = [WebConsole] {0} executou "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Попытка отправить со
|
|||||||
cpu-usage-message = Использование {0}%
|
cpu-usage-message = Использование {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0} попытался запустить {1} без разрешения.
|
no-send-permission-console = [WebConsole] {0} попытался запустить {1} без разрешения.
|
||||||
cmd-executed-console = [WebConsole] {0} выполнил "{1}".
|
cmd-executed-console = [WebConsole] {0} выполнил "{1}".
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -5,7 +5,7 @@ boot-error = WebSocket sunucusunu başlatırken hata oluştu.
|
|||||||
connection-resumed-message = Bağlandı. Zaten giriş yaptın, tekrar hoş geldin!
|
connection-resumed-message = Bağlandı. Zaten giriş yaptın, tekrar hoş geldin!
|
||||||
connection-resumed-console = [WebConsole] Bağlandı ve {0} konumundan gelen oturum devam ettirildi
|
connection-resumed-console = [WebConsole] Bağlandı ve {0} konumundan gelen oturum devam ettirildi
|
||||||
connection-login-message = Bağlantı başladı, giriş bekleniyor
|
connection-login-message = Bağlantı başladı, giriş bekleniyor
|
||||||
connection-login-console = [WebConsole] Bağlandı ve {0} konumundan giriş bekleniyor
|
connection-login-console = [WebConsole] Bağlandı ve {0} konumundan giriş bekleniyor
|
||||||
unknown-command-message = Bilinmeyen komut
|
unknown-command-message = Bilinmeyen komut
|
||||||
unknown-command-console = [WebConsole] "{0}" sinyali geçerli olmadığından işlenilemedi. Eklentin/web arayüzün güncellenmiş mi?
|
unknown-command-console = [WebConsole] "{0}" sinyali geçerli olmadığından işlenilemedi. Eklentin/web arayüzün güncellenmiş mi?
|
||||||
forbidden-message = Forbidden
|
forbidden-message = Forbidden
|
||||||
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] Bağlantısı kesilmiş bir WebSocket'a
|
|||||||
cpu-usage-message = Şuanki kullanım %{0}
|
cpu-usage-message = Şuanki kullanım %{0}
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0}, {1}'ı yetkisiz olarak çalıştırmayı denedi.
|
no-send-permission-console = [WebConsole] {0}, {1}'ı yetkisiz olarak çalıştırmayı denedi.
|
||||||
cmd-executed-console = [WebConsole] {0}, "{1}" çalıştırdı.
|
cmd-executed-console = [WebConsole] {0}, "{1}" çalıştırdı.
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
|
@ -19,7 +19,7 @@ error-disconnected-client = [WebConsole] 尝试向断开连接的WebSocket客户
|
|||||||
cpu-usage-message = 已使用 {0}%
|
cpu-usage-message = 已使用 {0}%
|
||||||
|
|
||||||
# ExecCommand.java
|
# ExecCommand.java
|
||||||
viewer-error-console = [WebConsole] {0}试图未经许可而运行{1}。
|
no-send-permission-console = [WebConsole] {0}试图未经许可而运行{1}。
|
||||||
cmd-executed-console = [網站控制台] {0} 執行 '{1}'.
|
cmd-executed-console = [網站控制台] {0} 執行 '{1}'.
|
||||||
|
|
||||||
# LogInCommand.java
|
# LogInCommand.java
|
||||||
@ -32,7 +32,7 @@ login-failed-console = [網站控制台] 登錄時密碼不正確 {0}
|
|||||||
players-message = {0}玩家連接,最多{1}
|
players-message = {0}玩家連接,最多{1}
|
||||||
|
|
||||||
# RamUsageCommand.java
|
# RamUsageCommand.java
|
||||||
ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
ram-usage-message = 空閒{0} , 已使用{1} , 最大內存{2}
|
||||||
|
|
||||||
# WebConsoleCommand.java
|
# WebConsoleCommand.java
|
||||||
webconsole-version = 網站控制台版本 {0}.
|
webconsole-version = 網站控制台版本 {0}.
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
name: WebConsole
|
name: WebConsole
|
||||||
main: es.mesacarlos.webconsole.WebConsole
|
main: es.mesacarlos.webconsole.WebConsole
|
||||||
api-version: 1.13
|
api-version: 1.13
|
||||||
version: 2.1
|
version: 2.2
|
||||||
description: WebSocket-based web console
|
description: WebSocket-based web console
|
||||||
author: Carlos Mesa
|
author: Carlos Mesa
|
||||||
commands:
|
commands:
|
||||||
|
2
pom.xml
2
pom.xml
@ -4,7 +4,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>WebConsole</groupId>
|
<groupId>WebConsole</groupId>
|
||||||
<artifactId>WebConsole</artifactId>
|
<artifactId>WebConsole</artifactId>
|
||||||
<version>2.1</version>
|
<version>2.2</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src</sourceDirectory>
|
<sourceDirectory>src</sourceDirectory>
|
||||||
<plugins>
|
<plugins>
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package es.mesacarlos.webconsole.config;
|
package es.mesacarlos.webconsole.config;
|
||||||
|
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
@ -47,7 +45,12 @@ public class ConfigManager {
|
|||||||
if(config.getConfigurationSection("passwords") == null) {
|
if(config.getConfigurationSection("passwords") == null) {
|
||||||
ConfigurationSection passwordsSection = config.createSection("passwords");
|
ConfigurationSection passwordsSection = config.createSection("passwords");
|
||||||
ConfigurationSection adminPasswordSection = passwordsSection.createSection("admin");
|
ConfigurationSection adminPasswordSection = passwordsSection.createSection("admin");
|
||||||
adminPasswordSection.addDefault("user1", "mySecurePassword");
|
ConfigurationSection individualAdminPasswordSection = adminPasswordSection.createSection("user1");
|
||||||
|
individualAdminPasswordSection.addDefault("password", "mySecurePassword");
|
||||||
|
ConfigurationSection commandWhitelist = individualAdminPasswordSection.createSection("commandWhitelist");
|
||||||
|
commandWhitelist.addDefault("enabled", false);
|
||||||
|
commandWhitelist.addDefault("commandWhitelistActsAsBlacklist", false);
|
||||||
|
commandWhitelist.addDefault("whitelist", Arrays.asList("whisper", "gamemode survival"));
|
||||||
passwordsSection.createSection("viewer");
|
passwordsSection.createSection("viewer");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,11 +99,19 @@ public class ConfigManager {
|
|||||||
* @return list of admin users
|
* @return list of admin users
|
||||||
*/
|
*/
|
||||||
private List<UserData> getAdmins() {
|
private List<UserData> getAdmins() {
|
||||||
Map<String, Object> passwords = plugin.getConfig().getConfigurationSection("passwords").getConfigurationSection("admin").getValues(false);
|
Set<String> adminConfig = plugin.getConfig().getConfigurationSection("passwords").getConfigurationSection("admin").getKeys(false);
|
||||||
List<UserData> adminUsers = new ArrayList<UserData>();
|
|
||||||
|
List<UserData> adminUsers = new ArrayList<>();
|
||||||
|
|
||||||
for(Map.Entry<String, Object> entry : passwords.entrySet())
|
for(String username : adminConfig) {
|
||||||
adminUsers.add(new UserData(entry.getKey(), entry.getValue().toString(), UserType.ADMIN));
|
adminUsers.add(new UserData(
|
||||||
|
username,
|
||||||
|
plugin.getConfig().getString("passwords.admin." + username + ".password"),
|
||||||
|
UserType.ADMIN,
|
||||||
|
plugin.getConfig().getBoolean("passwords.admin." + username + ".commandWhitelist.enabled"),
|
||||||
|
plugin.getConfig().getBoolean("passwords.admin." + username + ".commandWhitelist.commandWhitelistActsAsBlacklist"),
|
||||||
|
plugin.getConfig().getStringList("passwords.admin." + username + ".commandWhitelist.whitelist")));
|
||||||
|
}
|
||||||
|
|
||||||
return adminUsers;
|
return adminUsers;
|
||||||
}
|
}
|
||||||
@ -111,10 +122,10 @@ public class ConfigManager {
|
|||||||
*/
|
*/
|
||||||
private List<UserData> getViewers() {
|
private List<UserData> getViewers() {
|
||||||
Map<String, Object> passwords = plugin.getConfig().getConfigurationSection("passwords").getConfigurationSection("viewer").getValues(false);
|
Map<String, Object> passwords = plugin.getConfig().getConfigurationSection("passwords").getConfigurationSection("viewer").getValues(false);
|
||||||
List<UserData> viewerUsers = new ArrayList<UserData>();
|
List<UserData> viewerUsers = new ArrayList<>();
|
||||||
|
|
||||||
for(Map.Entry<String, Object> entry : passwords.entrySet())
|
for(Map.Entry<String, Object> entry : passwords.entrySet())
|
||||||
viewerUsers.add(new UserData(entry.getKey(), entry.getValue().toString(), UserType.VIEWER));
|
viewerUsers.add(new UserData(entry.getKey(), entry.getValue().toString(), UserType.VIEWER, false, false, new ArrayList<>()));
|
||||||
|
|
||||||
return viewerUsers;
|
return viewerUsers;
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,25 @@
|
|||||||
package es.mesacarlos.webconsole.config;
|
package es.mesacarlos.webconsole.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class UserData {
|
public class UserData {
|
||||||
private String username;
|
private String username;
|
||||||
private String password;
|
private String password;
|
||||||
private UserType userType;
|
private UserType userType;
|
||||||
|
private boolean isWhitelistEnabled;
|
||||||
|
private boolean isWhitelistActsAsBlacklist;
|
||||||
|
private List<String> whitelistedCommands;
|
||||||
|
|
||||||
public UserData(String username, String password, UserType userType) {
|
public UserData(String username, String password, UserType userType,
|
||||||
|
boolean isWhitelistEnabled, boolean isWhitelistActsAsBlacklist, List<String> whitelistedCommands) {
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
this.userType = userType;
|
this.userType = userType;
|
||||||
|
this.isWhitelistEnabled = isWhitelistEnabled;
|
||||||
|
this.isWhitelistActsAsBlacklist = isWhitelistActsAsBlacklist;
|
||||||
|
this.whitelistedCommands = whitelistedCommands;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUsername() {
|
public String getUsername() {
|
||||||
return username;
|
return username;
|
||||||
}
|
}
|
||||||
@ -22,4 +31,16 @@ public class UserData {
|
|||||||
public UserType getUserType() {
|
public UserType getUserType() {
|
||||||
return userType;
|
return userType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelistEnabled() {
|
||||||
|
return isWhitelistEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWhitelistActsAsBlacklist() {
|
||||||
|
return isWhitelistActsAsBlacklist;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getWhitelistedCommands() {
|
||||||
|
return whitelistedCommands;
|
||||||
|
}
|
||||||
}
|
}
|
@ -2,6 +2,8 @@ package es.mesacarlos.webconsole.websocket.command;
|
|||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import es.mesacarlos.webconsole.config.ConfigManager;
|
||||||
|
import es.mesacarlos.webconsole.config.UserData;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
import org.java_websocket.WebSocket;
|
import org.java_websocket.WebSocket;
|
||||||
@ -14,13 +16,56 @@ import es.mesacarlos.webconsole.util.Internationalization;
|
|||||||
import es.mesacarlos.webconsole.websocket.WSServer;
|
import es.mesacarlos.webconsole.websocket.WSServer;
|
||||||
|
|
||||||
public class ExecCommand implements WSCommand {
|
public class ExecCommand implements WSCommand {
|
||||||
|
LoginManager loginManager = LoginManager.getInstance();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(WSServer wsServer, WebSocket conn, String command) {
|
public void execute(WSServer wsServer, WebSocket conn, String command) {
|
||||||
ConnectedUser u = LoginManager.getInstance().getUser(conn.getRemoteSocketAddress());
|
ConnectedUser u = LoginManager.getInstance().getUser(conn.getRemoteSocketAddress());
|
||||||
if(u == null || u.getUserType() != UserType.ADMIN) {
|
if(u == null || u.getUserType() != UserType.ADMIN) {
|
||||||
if(u != null)
|
if(u != null)
|
||||||
Bukkit.getLogger().warning(Internationalization.getPhrase("viewer-error-console", u, command));
|
Bukkit.getLogger().warning(Internationalization.getPhrase("no-send-permission-console", u, command));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean allowCommand = false;
|
||||||
|
|
||||||
|
for(UserData ud : ConfigManager.getInstance().getAllUsers()) {
|
||||||
|
if (ud.getUsername().equals(loginManager.getUser(conn.getRemoteSocketAddress()).getUsername())) {
|
||||||
|
|
||||||
|
if (!ud.isWhitelistEnabled()) { //Skip whitelist check.
|
||||||
|
allowCommand = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] splitCommand = command.split(" ");
|
||||||
|
|
||||||
|
for (String whitelistedCommand : ud.getWhitelistedCommands()) {
|
||||||
|
String[] splitWhitelistedCommand = whitelistedCommand.split(" ");
|
||||||
|
|
||||||
|
for (int x = 0; x < splitWhitelistedCommand.length; x ++) {
|
||||||
|
|
||||||
|
if (!ud.isWhitelistActsAsBlacklist()) {
|
||||||
|
|
||||||
|
if (splitCommand[x].equalsIgnoreCase(splitWhitelistedCommand[x])) { //cmd is whitelisted.
|
||||||
|
allowCommand = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
allowCommand = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowCommand //Check if was detected by whitelist
|
||||||
|
&& ud.isWhitelistActsAsBlacklist()) allowCommand = true; //cmd is not blacklisted.
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!allowCommand) {
|
||||||
|
Bukkit.getLogger().warning(Internationalization.getPhrase("no-send-permission-console", u, command));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user