Fix Compile issues
This commit is contained in:
parent
19bb94fa74
commit
904fc3faad
12
api/pom.xml
12
api/pom.xml
|
|
@ -29,6 +29,7 @@
|
||||||
<groupId>net.kyori</groupId>
|
<groupId>net.kyori</groupId>
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
<version>4.1.0-SNAPSHOT</version>
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.velocitypowered</groupId>
|
<groupId>com.velocitypowered</groupId>
|
||||||
|
|
@ -42,17 +43,6 @@
|
||||||
<version>5.3</version>
|
<version>5.3</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.alttd.chat</groupId>
|
|
||||||
<artifactId>velocity-chat</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.kyori</groupId>
|
|
||||||
<artifactId>adventure-text-minimessage</artifactId>
|
|
||||||
<version>4.1.0-SNAPSHOT</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -7,7 +7,9 @@ import java.util.UUID;
|
||||||
|
|
||||||
public interface ChatAPI {
|
public interface ChatAPI {
|
||||||
|
|
||||||
ChatAPI get();
|
static ChatAPI get() {
|
||||||
|
return ChatImplementation.get();
|
||||||
|
}
|
||||||
|
|
||||||
LuckPerms getLuckPerms();
|
LuckPerms getLuckPerms();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,11 @@
|
||||||
package com.alttd.chat;
|
package com.alttd.chat;
|
||||||
|
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.config.RegexConfig;
|
|
||||||
import com.alttd.chat.database.DatabaseConnection;
|
import com.alttd.chat.database.DatabaseConnection;
|
||||||
import net.luckperms.api.LuckPerms;
|
import net.luckperms.api.LuckPerms;
|
||||||
import net.luckperms.api.LuckPermsProvider;
|
import net.luckperms.api.LuckPermsProvider;
|
||||||
import net.luckperms.api.model.group.Group;
|
import net.luckperms.api.model.group.Group;
|
||||||
import net.luckperms.api.model.user.User;
|
import net.luckperms.api.model.user.User;
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
|
|
@ -15,7 +13,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
public class ChatImplementation implements ChatAPI{
|
public class ChatImplementation implements ChatAPI{
|
||||||
|
|
||||||
private ChatAPI instance;
|
private static ChatAPI instance;
|
||||||
|
|
||||||
private LuckPerms luckPerms;
|
private LuckPerms luckPerms;
|
||||||
private DatabaseConnection databaseConnection;
|
private DatabaseConnection databaseConnection;
|
||||||
|
|
@ -25,11 +23,10 @@ public class ChatImplementation implements ChatAPI{
|
||||||
Config.init();
|
Config.init();
|
||||||
|
|
||||||
luckPerms = getLuckPerms();
|
luckPerms = getLuckPerms();
|
||||||
//databaseConnection = getDataBase(); // TODO fix database on proxy, shade sql, add defaults to config
|
databaseConnection = getDataBase();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public static ChatAPI get() {
|
||||||
public ChatAPI get() {
|
|
||||||
if(instance == null)
|
if(instance == null)
|
||||||
instance = new ChatImplementation();
|
instance = new ChatImplementation();
|
||||||
return instance;
|
return instance;
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ public class Queries {
|
||||||
List<String> tables = new ArrayList<>();
|
List<String> tables = new ArrayList<>();
|
||||||
tables.add("CREATE TABLE IF NOT EXISTS ignored_users (`uuid` VARCHAR(36) NOT NULL, `ignored_uuid` VARCHAR(36) NOT NULL, PRIMARY KEY (`uuid`, `ignored_uuid`))");
|
tables.add("CREATE TABLE IF NOT EXISTS ignored_users (`uuid` VARCHAR(36) NOT NULL, `ignored_uuid` VARCHAR(36) NOT NULL, PRIMARY KEY (`uuid`, `ignored_uuid`))");
|
||||||
tables.add("CREATE TABLE IF NOT EXISTS parties (`id` INT NOT NULL AUTO_INCREMENT, `owner_uuid` VARCHAR(36) NOT NULL, `party_name` VARCHAR(36) NOT NULL, `password` VARCHAR(36), PRIMARY KEY (`id`))");
|
tables.add("CREATE TABLE IF NOT EXISTS parties (`id` INT NOT NULL AUTO_INCREMENT, `owner_uuid` VARCHAR(36) NOT NULL, `party_name` VARCHAR(36) NOT NULL, `password` VARCHAR(36), PRIMARY KEY (`id`))");
|
||||||
tables.add("CREATE TABLE IF NOT EXISTS party_users (`uuid` VARCHAR(36) NOT NULL, `party_id` INT NOT NULL, `toggled_chat` BIT(1) DEFAULT b'0', `force_tp` BIT(1) DEFAULT b'1', PRIMARY KEY (`uuid`), FOREIGN KEY (party_id) REFERENCES parties(id) ON DELETE CASCADE)");
|
tables.add("CREATE TABLE IF NOT EXISTS chat_users (`uuid` VARCHAR(36) NOT NULL, `party_id` INT NOT NULL, `toggled_chat` BIT(1) DEFAULT b'0', `force_tp` BIT(1) DEFAULT b'1', `toggled_gc` BIT(1) DEFAULT b'0', PRIMARY KEY (`uuid`), FOREIGN KEY (party_id) REFERENCES parties(id) ON DELETE CASCADE)");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Connection connection = DatabaseConnection.getConnection();
|
Connection connection = DatabaseConnection.getConnection();
|
||||||
|
|
@ -38,7 +38,7 @@ public class Queries {
|
||||||
//Nicknames
|
//Nicknames
|
||||||
|
|
||||||
public static String getNickname(UUID uuid) {
|
public static String getNickname(UUID uuid) {
|
||||||
//TODO use separate connection so it actually uses the nickname db...
|
// View has been created.
|
||||||
String query = "SELECT nickname FROM nicknames WHERE uuid = ?";
|
String query = "SELECT nickname FROM nicknames WHERE uuid = ?";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
@ -263,6 +263,7 @@ public class Queries {
|
||||||
int partyId = resultSet.getInt("party_id");
|
int partyId = resultSet.getInt("party_id");
|
||||||
boolean toggled_chat = resultSet.getInt("toggled_chat") == 1;
|
boolean toggled_chat = resultSet.getInt("toggled_chat") == 1;
|
||||||
boolean force_tp = resultSet.getInt("force_tp") == 1;
|
boolean force_tp = resultSet.getInt("force_tp") == 1;
|
||||||
|
boolean toggle_Gc = resultSet.getInt("toggled_gc") == 1;
|
||||||
|
|
||||||
if (partyId == 0) {
|
if (partyId == 0) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -276,7 +277,7 @@ public class Queries {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
party.addUser(new ChatUser(uuid, partyId, toggled_chat, force_tp));
|
party.addUser(new ChatUser(uuid, partyId, toggled_chat, force_tp, toggle_Gc));
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
@ -285,7 +286,7 @@ public class Queries {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void addUser(ChatUser user) {
|
public static void addUser(ChatUser user) {
|
||||||
String query = "INSERT INTO party_users (uuid, party_id, toggled_chat, force_tp) VALUES (?, ?, ?, ?)";
|
String query = "INSERT INTO party_users (uuid, party_id, toggled_chat, force_tp, toggled_gc) VALUES (?, ?, ?, ?, ?)";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Connection connection = DatabaseConnection.getConnection();
|
Connection connection = DatabaseConnection.getConnection();
|
||||||
|
|
@ -295,6 +296,7 @@ public class Queries {
|
||||||
statement.setInt(2, user.getPartyId());
|
statement.setInt(2, user.getPartyId());
|
||||||
statement.setInt(3, user.toggledChat() ? 1 : 0);
|
statement.setInt(3, user.toggledChat() ? 1 : 0);
|
||||||
statement.setInt(4, user.ForceTp() ? 1 : 0);
|
statement.setInt(4, user.ForceTp() ? 1 : 0);
|
||||||
|
statement.setInt(5, user.isGcOn() ? 1 : 0);
|
||||||
|
|
||||||
statement.execute();
|
statement.execute();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ public class ChatUser {
|
||||||
private String prefixAll;
|
private String prefixAll;
|
||||||
private boolean toggleGc;
|
private boolean toggleGc;
|
||||||
|
|
||||||
public ChatUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp) {
|
public ChatUser(UUID uuid, int partyId, boolean toggled_chat, boolean force_tp, boolean toggle_Gc) {
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
this.partyId = partyId;
|
this.partyId = partyId;
|
||||||
this.toggledChat = toggled_chat;
|
this.toggledChat = toggled_chat;
|
||||||
|
|
@ -31,8 +31,8 @@ public class ChatUser {
|
||||||
staffPrefix = Utility.getStaffPrefix(uuid);
|
staffPrefix = Utility.getStaffPrefix(uuid);
|
||||||
|
|
||||||
prefixAll = prefix + staffPrefix; //TODO test what this does cus I barely understand lp api
|
prefixAll = prefix + staffPrefix; //TODO test what this does cus I barely understand lp api
|
||||||
|
// a boolean is lighter then a permission check, it's what I'd suggest doing here
|
||||||
toggleGc = Utility.checkPermission(uuid, "chat.gc"); //TODO put the actual permission here, I don't know what it is...
|
toggleGc = toggle_Gc;//Utility.checkPermission(uuid, "chat.gc"); //TODO put the actual permission here, I don't know what it is...
|
||||||
}
|
}
|
||||||
|
|
||||||
public UUID getUuid() {
|
public UUID getUuid() {
|
||||||
|
|
@ -95,7 +95,6 @@ public class ChatUser {
|
||||||
|
|
||||||
public void toggleGc() {
|
public void toggleGc() {
|
||||||
toggleGc = !toggleGc;
|
toggleGc = !toggleGc;
|
||||||
Utility.setPermission(uuid, "chat.gc", toggleGc); //TODO put the actual permission here, I don't know what it is...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGcOn() {
|
public boolean isGcOn() {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.alttd.chat.util;
|
package com.alttd.chat.util;
|
||||||
|
|
||||||
import com.alttd.chat.ChatPlugin;
|
import com.alttd.chat.ChatAPI;
|
||||||
|
import com.alttd.chat.ChatImplementation;
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import com.velocitypowered.api.proxy.Player;
|
import com.velocitypowered.api.proxy.Player;
|
||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
|
|
@ -18,7 +19,7 @@ public class Utility {
|
||||||
|
|
||||||
public static String getPrefix(UUID uuid, boolean highest) {
|
public static String getPrefix(UUID uuid, boolean highest) {
|
||||||
StringBuilder prefix = new StringBuilder();
|
StringBuilder prefix = new StringBuilder();
|
||||||
LuckPerms luckPerms = ChatPlugin.getPlugin().API().getLuckPerms();
|
LuckPerms luckPerms = ChatAPI.get().getLuckPerms();
|
||||||
User user = luckPerms.getUserManager().getUser(uuid);
|
User user = luckPerms.getUserManager().getUser(uuid);
|
||||||
if(user == null) return "";
|
if(user == null) return "";
|
||||||
if(!highest) {
|
if(!highest) {
|
||||||
|
|
@ -37,9 +38,10 @@ public class Utility {
|
||||||
return prefix.toString();
|
return prefix.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @teri you don't reference the plugin instance from the API instance, this creates a circular reference and breaks on compile and will never run
|
||||||
public static String getStaffPrefix(UUID uuid) {
|
public static String getStaffPrefix(UUID uuid) {
|
||||||
StringBuilder prefix = new StringBuilder();
|
StringBuilder prefix = new StringBuilder();
|
||||||
LuckPerms luckPerms = ChatPlugin.getPlugin().API().getLuckPerms();
|
LuckPerms luckPerms = ChatAPI.get().getLuckPerms();
|
||||||
User user = luckPerms.getUserManager().getUser(uuid);
|
User user = luckPerms.getUserManager().getUser(uuid);
|
||||||
if(user == null) return "";
|
if(user == null) return "";
|
||||||
if(!Config.STAFFGROUPS.contains(user.getPrimaryGroup())) return "";
|
if(!Config.STAFFGROUPS.contains(user.getPrimaryGroup())) return "";
|
||||||
|
|
@ -48,25 +50,13 @@ public class Utility {
|
||||||
return prefix.toString();
|
return prefix.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean checkPermission(UUID uuid, String permission) {
|
|
||||||
ProxyServer proxy = ChatPlugin.getPlugin().getProxy();
|
|
||||||
if (proxy.getPlayer(uuid).isEmpty()) return false;
|
|
||||||
Player player = proxy.getPlayer(uuid).get();
|
|
||||||
|
|
||||||
return player.hasPermission(permission);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String getDisplayName(UUID uuid) {
|
public static String getDisplayName(UUID uuid) {
|
||||||
ProxyServer proxy = ChatPlugin.getPlugin().getProxy();
|
// todo add a <T> PlayerWrapper<T> @Destro
|
||||||
|
/*ProxyServer proxy = ChatPlugin.getPlugin().getProxy();
|
||||||
if (proxy.getPlayer(uuid).isEmpty()) return "";
|
if (proxy.getPlayer(uuid).isEmpty()) return "";
|
||||||
Player player = proxy.getPlayer(uuid).get();
|
Player player = proxy.getPlayer(uuid).get();
|
||||||
return player.getUsername();
|
return player.getUsername();*/
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setPermission(UUID uuid, String permission, boolean toggleGc) {
|
|
||||||
LuckPerms luckPerms = ChatPlugin.getPlugin().API().getLuckPerms();
|
|
||||||
luckPerms.getUserManager().modifyUser(uuid, user -> {
|
|
||||||
user.data().add(Node.builder(permission).value(toggleGc).build());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,12 @@
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
<version>1.16.5-R0.1-SNAPSHOT</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
|
|
||||||
|
|
@ -87,5 +87,11 @@
|
||||||
<artifactId>configurate-yaml</artifactId>
|
<artifactId>configurate-yaml</artifactId>
|
||||||
<version>3.7.1</version>
|
<version>3.7.1</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
@ -5,14 +5,10 @@ import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.handler.ChatHandler;
|
import com.alttd.chat.handler.ChatHandler;
|
||||||
import com.alttd.chat.listeners.PlayerListener;
|
import com.alttd.chat.listeners.PlayerListener;
|
||||||
import com.alttd.chat.listeners.PluginMessage;
|
import com.alttd.chat.listeners.PluginMessage;
|
||||||
import ninja.leaping.configurate.ConfigurationNode;
|
|
||||||
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
|
|
||||||
import org.bukkit.command.CommandExecutor;
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ChatPlugin extends JavaPlugin {
|
public class ChatPlugin extends JavaPlugin {
|
||||||
|
|
||||||
private static ChatPlugin instance;
|
private static ChatPlugin instance;
|
||||||
|
|
|
||||||
|
|
@ -71,6 +71,12 @@
|
||||||
<version>4.1.0</version>
|
<version>4.1.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
<properties>
|
<properties>
|
||||||
<maven.compiler.target>11</maven.compiler.target>
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,12 @@
|
||||||
<version>5.1.49</version>
|
<version>5.1.49</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.kyori</groupId>
|
||||||
|
<artifactId>adventure-text-minimessage</artifactId>
|
||||||
|
<version>4.1.0-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user