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>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.velocitypowered</groupId>
|
||||
|
|
@ -42,17 +43,6 @@
|
|||
<version>5.3</version>
|
||||
<scope>provided</scope>
|
||||
</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>
|
||||
|
||||
</project>
|
||||
|
|
@ -7,7 +7,9 @@ import java.util.UUID;
|
|||
|
||||
public interface ChatAPI {
|
||||
|
||||
ChatAPI get();
|
||||
static ChatAPI get() {
|
||||
return ChatImplementation.get();
|
||||
}
|
||||
|
||||
LuckPerms getLuckPerms();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,11 @@
|
|||
package com.alttd.chat;
|
||||
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.config.RegexConfig;
|
||||
import com.alttd.chat.database.DatabaseConnection;
|
||||
import net.luckperms.api.LuckPerms;
|
||||
import net.luckperms.api.LuckPermsProvider;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import net.luckperms.api.model.user.User;
|
||||
import ninja.leaping.configurate.ConfigurationNode;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
|
|
@ -15,7 +13,7 @@ import java.util.UUID;
|
|||
|
||||
public class ChatImplementation implements ChatAPI{
|
||||
|
||||
private ChatAPI instance;
|
||||
private static ChatAPI instance;
|
||||
|
||||
private LuckPerms luckPerms;
|
||||
private DatabaseConnection databaseConnection;
|
||||
|
|
@ -25,11 +23,10 @@ public class ChatImplementation implements ChatAPI{
|
|||
Config.init();
|
||||
|
||||
luckPerms = getLuckPerms();
|
||||
//databaseConnection = getDataBase(); // TODO fix database on proxy, shade sql, add defaults to config
|
||||
databaseConnection = getDataBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatAPI get() {
|
||||
public static ChatAPI get() {
|
||||
if(instance == null)
|
||||
instance = new ChatImplementation();
|
||||
return instance;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class Queries {
|
|||
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 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 {
|
||||
Connection connection = DatabaseConnection.getConnection();
|
||||
|
|
@ -38,7 +38,7 @@ public class Queries {
|
|||
//Nicknames
|
||||
|
||||
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 = ?";
|
||||
|
||||
try {
|
||||
|
|
@ -263,6 +263,7 @@ public class Queries {
|
|||
int partyId = resultSet.getInt("party_id");
|
||||
boolean toggled_chat = resultSet.getInt("toggled_chat") == 1;
|
||||
boolean force_tp = resultSet.getInt("force_tp") == 1;
|
||||
boolean toggle_Gc = resultSet.getInt("toggled_gc") == 1;
|
||||
|
||||
if (partyId == 0) {
|
||||
continue;
|
||||
|
|
@ -276,7 +277,7 @@ public class Queries {
|
|||
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) {
|
||||
|
|
@ -285,7 +286,7 @@ public class Queries {
|
|||
}
|
||||
|
||||
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 {
|
||||
Connection connection = DatabaseConnection.getConnection();
|
||||
|
|
@ -295,6 +296,7 @@ public class Queries {
|
|||
statement.setInt(2, user.getPartyId());
|
||||
statement.setInt(3, user.toggledChat() ? 1 : 0);
|
||||
statement.setInt(4, user.ForceTp() ? 1 : 0);
|
||||
statement.setInt(5, user.isGcOn() ? 1 : 0);
|
||||
|
||||
statement.execute();
|
||||
} catch (SQLException e) {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class ChatUser {
|
|||
private String prefixAll;
|
||||
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.partyId = partyId;
|
||||
this.toggledChat = toggled_chat;
|
||||
|
|
@ -31,8 +31,8 @@ public class ChatUser {
|
|||
staffPrefix = Utility.getStaffPrefix(uuid);
|
||||
|
||||
prefixAll = prefix + staffPrefix; //TODO test what this does cus I barely understand lp api
|
||||
|
||||
toggleGc = Utility.checkPermission(uuid, "chat.gc"); //TODO put the actual permission here, I don't know what it is...
|
||||
// a boolean is lighter then a permission check, it's what I'd suggest doing here
|
||||
toggleGc = toggle_Gc;//Utility.checkPermission(uuid, "chat.gc"); //TODO put the actual permission here, I don't know what it is...
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
|
|
@ -95,7 +95,6 @@ public class ChatUser {
|
|||
|
||||
public void 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() {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
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.velocitypowered.api.proxy.Player;
|
||||
import com.velocitypowered.api.proxy.ProxyServer;
|
||||
|
|
@ -18,7 +19,7 @@ public class Utility {
|
|||
|
||||
public static String getPrefix(UUID uuid, boolean highest) {
|
||||
StringBuilder prefix = new StringBuilder();
|
||||
LuckPerms luckPerms = ChatPlugin.getPlugin().API().getLuckPerms();
|
||||
LuckPerms luckPerms = ChatAPI.get().getLuckPerms();
|
||||
User user = luckPerms.getUserManager().getUser(uuid);
|
||||
if(user == null) return "";
|
||||
if(!highest) {
|
||||
|
|
@ -37,9 +38,10 @@ public class Utility {
|
|||
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) {
|
||||
StringBuilder prefix = new StringBuilder();
|
||||
LuckPerms luckPerms = ChatPlugin.getPlugin().API().getLuckPerms();
|
||||
LuckPerms luckPerms = ChatAPI.get().getLuckPerms();
|
||||
User user = luckPerms.getUserManager().getUser(uuid);
|
||||
if(user == null) return "";
|
||||
if(!Config.STAFFGROUPS.contains(user.getPrimaryGroup())) return "";
|
||||
|
|
@ -48,25 +50,13 @@ public class Utility {
|
|||
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) {
|
||||
ProxyServer proxy = ChatPlugin.getPlugin().getProxy();
|
||||
// todo add a <T> PlayerWrapper<T> @Destro
|
||||
/*ProxyServer proxy = ChatPlugin.getPlugin().getProxy();
|
||||
if (proxy.getPlayer(uuid).isEmpty()) return "";
|
||||
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>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
|
|
|||
|
|
@ -87,5 +87,11 @@
|
|||
<artifactId>configurate-yaml</artifactId>
|
||||
<version>3.7.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
@ -5,14 +5,10 @@ import com.alttd.chat.config.Config;
|
|||
import com.alttd.chat.handler.ChatHandler;
|
||||
import com.alttd.chat.listeners.PlayerListener;
|
||||
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.event.Listener;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class ChatPlugin extends JavaPlugin {
|
||||
|
||||
private static ChatPlugin instance;
|
||||
|
|
|
|||
|
|
@ -71,6 +71,12 @@
|
|||
<version>4.1.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
|
|
|
|||
|
|
@ -98,6 +98,12 @@
|
|||
<version>5.1.49</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>net.kyori</groupId>
|
||||
<artifactId>adventure-text-minimessage</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user