Update development #5

Merge aplicado
Awakened-Redstone mesclou 27 commits from temp into development 2022-02-18 19:01:36 +00:00
21 arquivos alterados com 49 adições e 139 exclusões
Mostrando apenas as alterações do commit b92922ace3 - Mostrar todos os commits
Awakened-Redstone 2021-08-21 20:47:20 -03:00

Ver arquivo

@ -1,19 +1,22 @@
plugins {
id "fabric-loom" version "0.6-SNAPSHOT"
id "fabric-loom" version "0.8-SNAPSHOT"
}
repositories {
mavenCentral()
jcenter()
maven { url 'https://jitpack.io' }
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
}
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = 16
targetCompatibility = 16
dependencies {
minecraft "com.mojang:minecraft:${project.minecraft_version}"
@ -29,15 +32,15 @@ dependencies {
implementation include("com.jagrosh:jda-utilities-menu:3.0.5")
implementation include("com.jagrosh:jda-utilities-examples:3.0.5")
implementation include("com.jagrosh:jda-utilities-doc:3.0.5")
implementation include('net.dv8tion:JDA:4.2.0_231') {
implementation include('net.dv8tion:JDA:4.3.0_310') {
exclude module: 'opus-java'
}
implementation include('org.apache.logging.log4j:log4j-slf4j-impl:2.8.1')
//implementation include('org.apache.logging.log4j:log4j-slf4j-impl:2.14.1')
include "net.sf.trove4j:trove4j:3.0.3"
include 'org.slf4j:slf4j-api:1.7.25'
//include 'org.slf4j:slf4j-api:1.7.25'
include 'org.apache.commons:commons-collections4:4.1'
include 'com.neovisionaries:nv-websocket-client:2.10'
include 'com.neovisionaries:nv-websocket-client:2.14'
include 'com.squareup.okhttp3:okhttp:3.13.0'
include 'com.squareup.okio:okio:1.17.2'
include 'com.fasterxml.jackson.core:jackson-databind:2.10.1'
@ -54,14 +57,9 @@ compileJava {
processResources {
inputs.property "version", project.version
from(sourceSets.main.resources.srcDirs) {
include "fabric.mod.json"
filesMatching("fabric.mod.json") {
expand "version": project.version
}
from(sourceSets.main.resources.srcDirs) {
exclude "fabric.mod.json"
}
}
// ensure that the encoding is set to UTF-8, no matter what the system default is

Ver arquivo

@ -1,9 +1,9 @@
org.gradle.jvmargs=-Xmx1G
minecraft_version=21w10a
yarn_mappings=21w10a+build.10
loader_version=0.11.3
mod_version=0.2.3
minecraft_version=1.17.1
yarn_mappings=1.17.1+build.10
loader_version=0.11.6
mod_version=0.2.4
maven_group=com.awakenedredstone
archives_base_name=autowhitelist
fabric_version=0.32.2+1.17
fabric_version=0.36.1+1.17

Arquivo binário não exibido.

Ver arquivo

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

21
gradlew.bat externo
Ver arquivo

@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@ -64,21 +64,6 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

Ver arquivo

@ -35,8 +35,6 @@ import static com.awakenedredstone.autowhitelist.lang.JigsawLanguage.translation
public class AutoWhitelist implements ModInitializer {
public static Thread scheduledUpdateThread;
public static MinecraftServer server;
public static final Config config = new Config();
@ -62,7 +60,7 @@ public class AutoWhitelist implements ModInitializer {
}).collect(Collectors.toList());
for (GameProfile profile : profiles) {
GameProfile profile1 = server.getUserCache().getByUuid(profile.getId());
GameProfile profile1 = server.getUserCache().getByUuid(profile.getId()).orElse(null);
try {
if (profile1 == null) {
removePlayer((ExtendedGameProfile) profile);

Ver arquivo

@ -12,7 +12,7 @@ import static com.awakenedredstone.autowhitelist.util.Debugger.analyzeTimings;
public class AutoWhitelistCommand {
public static void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(CommandManager.literal("auto-whitelist").requires((source) -> {
dispatcher.register(CommandManager.literal("autowhitelist").requires((source) -> {
return source.hasPermissionLevel(4);
}).then((CommandManager.literal("reload").executes((source) -> {
executeReload(source.getSource());

Ver arquivo

@ -10,13 +10,14 @@ import net.minecraft.text.LiteralText;
import java.io.*;
import java.nio.file.Files;
import java.util.Arrays;
import java.util.stream.Collectors;
public class Config {
private ConfigData configData;
private final File configFile = new File(getConfigDirectory(), "AutoWhitelist.json");
private final int configVersion = 2;
private final float configVersion = 2.1f;
public File getConfigDirectory() {
return new File(".", "config");
@ -29,19 +30,11 @@ public class Config {
StringReader stringReader = new StringReader(json);
JsonObject jsonObject = new JsonParser().parse(json).getAsJsonObject();
if (jsonObject.get("version") == null || jsonObject.get("version").getAsInt() != configVersion) {
Files.copy(configFile.toPath(), new File(getConfigDirectory(), "AutoWhitelist_old.json").toPath());
JsonObject newJson = new JsonObject();
if (jsonObject.get("version") == null || jsonObject.get("version").getAsFloat() != configVersion) {
newJson.add("version", new JsonPrimitive(configVersion));
newJson.add("whitelistScheduledVerificationSeconds", jsonObject.get("whitelist-auto-update-delay-seconds"));
newJson.add("prefix", jsonObject.get("prefix"));
newJson.add("token", jsonObject.get("token"));
newJson.add("clientId", jsonObject.get("application-id"));
newJson.add("discordServerId", jsonObject.get("discord-server-id"));
newJson.add("whitelist", jsonObject.get("whitelist"));
jsonObject.add("owners", new JsonArray());
JsonHelper.writeJsonToFile(newJson, configFile);
JsonHelper.writeJsonToFile(jsonObject, configFile);
}
configData = AutoWhitelist.GSON.fromJson(stringReader, ConfigData.class);
@ -74,6 +67,7 @@ public class Config {
JsonObject json = new JsonObject();
json.add("version", new JsonPrimitive(configVersion));
json.add("whitelistScheduledVerificationSeconds", new JsonPrimitive(60L));
json.add("owners", new JsonArray());
json.add("prefix", new JsonPrimitive("np!"));
json.add("token", new JsonPrimitive("bot-token"));
json.add("clientId", new JsonPrimitive("client-id"));

Ver arquivo

@ -5,7 +5,8 @@ import java.util.Map;
public class ConfigData {
public long whitelistScheduledVerificationSeconds;
public short whitelistScheduledVerificationSeconds;
public String[] owners;
public String prefix;
public String token;
public String clientId;

Ver arquivo

@ -1,58 +0,0 @@
package com.awakenedredstone.autowhitelist.database;
import com.awakenedredstone.autowhitelist.AutoWhitelist;
import com.awakenedredstone.autowhitelist.util.ExtendedGameProfile;
import com.awakenedredstone.autowhitelist.whitelist.ExtendedWhitelistEntry;
import net.minecraft.server.MinecraftServer;
import java.io.File;
import java.sql.*;
import java.util.ArrayList;
import java.util.UUID;
public class SQLite {
private static Connection connection;
public void connect() {
File dir = new File("./config/AutoWhitelist");
if(!dir.exists() || !dir.isDirectory()) {
//AutoWhitelist.LOGGER.info("Could not find database. A new one will be created.");
return;
}
File file = new File("./config/AutoWhitelist/users.db");
if (!file.exists()) return;
try {
String url = "jdbc:sqlite:config/AutoWhitelist/users.db";
connection = DriverManager.getConnection(url);
} catch (SQLException e) {
AutoWhitelist.LOGGER.error("Failed to load old database", e);
return;
}
databaseChange();
}
private void databaseChange() {
if (connection == null) {
AutoWhitelist.LOGGER.error("Connection to database not existent. Unable to query data.");
return;
}
try {
PreparedStatement statement = connection.prepareStatement("SELECT * FROM `data`");
ResultSet results = statement.executeQuery();
ArrayList<ExtendedGameProfile> players = new ArrayList<>();
while (results.next()) {
players.add(new ExtendedGameProfile(UUID.fromString(results.getString("UUID")), results.getString("USERNAME"), results.getString("TEAM"), results.getString("ID")));
}
AutoWhitelist.server.getPlayerManager().getWhitelist().values().clear();
players.forEach(v -> AutoWhitelist.server.getPlayerManager().getWhitelist().add(new ExtendedWhitelistEntry(v)));
connection.close();
new File("./config/AutoWhitelist/users.db").delete();
new File("./config/AutoWhitelist").delete();
} catch (SQLException e) {
AutoWhitelist.LOGGER.error("Failed to get the data from the old database", e);
}
}
}

Ver arquivo

@ -87,6 +87,8 @@ public class Bot implements Runnable {
instance = this;
} catch (LoginException e) {
AutoWhitelist.LOGGER.error("Failed to start bot, please verify the token.");
} catch (Exception e) {
AutoWhitelist.LOGGER.error(e);
}
}
}

Ver arquivo

@ -47,6 +47,7 @@ public class BotEventListener extends ListenerAdapter {
CommandClientBuilder builder = new CommandClientBuilder();
builder.setPrefix(prefix);
builder.setOwnerId("387745099204919297");
builder.setCoOwnerIds(AutoWhitelist.getConfigData().owners);
builder.setHelpConsumer(generateHelpConsumer());
builder.addCommands(
new RegisterCommand(),

Ver arquivo

@ -20,10 +20,7 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.text.LiteralText;
import com.awakenedredstone.autowhitelist.lang.TranslatableText;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
import static com.awakenedredstone.autowhitelist.discord.Bot.whitelistDataMap;
@ -105,7 +102,7 @@ public class RegisterCommand extends Command {
{
}
GameProfile profile = server.getUserCache().findByName(arg);
GameProfile profile = server.getUserCache().findByName(arg).orElse(null);
if (profile == null) {
BotHelper.sendFeedbackMessage(channel, new TranslatableText("command.fail.title"), new TranslatableText("command.register.fail.account_data", arg), BotHelper.MessageType.ERROR);
return;

Ver arquivo

@ -18,7 +18,6 @@ public class BotStatusCommand extends DeveloperCommand {
@Override
protected void execute(CommandEvent event) {
if (event.getChannelType() != ChannelType.PRIVATE) return;
analyzeTimings("BotStatusCommand#execute", () -> {
EmbedBuilder embedBuilder = new EmbedBuilder();
@ -31,7 +30,7 @@ public class BotStatusCommand extends DeveloperCommand {
"\n" + "**Rest ping:** " + restPing + " ms";
embedBuilder.addField("Discord timings", output, false);
event.getChannel().sendMessage(embedBuilder.build()).queue();
event.getChannel().sendMessageEmbeds(embedBuilder.build()).queue();
});
});
}

Ver arquivo

@ -23,13 +23,11 @@ public class ServerStatusCommand extends DeveloperCommand {
@Override
protected void execute(CommandEvent event) {
if (event.getChannelType() != ChannelType.PRIVATE) return;
analyzeTimings("ServerStatusCommand#execute", () -> {
MinecraftServer server = AutoWhitelist.server;
PlayerManager playerManager = server.getPlayerManager();
long l = Util.getMeasuringTimeMs() - server.getServerStartTime();
long l = Util.getMeasuringTimeMs() - server.getTimeReference();
double MSPT = MathHelper.average(server.lastTickLengths) * 1.0E-6D;
double TPS = 1000.0D / Math.max(50, MSPT);
double MAX_POSSIBLE_TPS = 1000.0D / MSPT;

Ver arquivo

@ -5,8 +5,6 @@ import com.jagrosh.jdautilities.command.CommandEvent;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.ChannelType;
import net.minecraft.util.math.MathHelper;
import oshi.SystemInfo;
import oshi.hardware.Processor;
import java.util.Arrays;
import java.util.Map;
@ -24,7 +22,6 @@ public class StatusCommand extends DeveloperCommand {
@Override
protected void execute(CommandEvent event) {
if (event.getChannelType() != ChannelType.PRIVATE) return;
analyzeTimings("StatusCommand#execute", () -> {
Runtime runtime = Runtime.getRuntime();

Ver arquivo

@ -2,7 +2,6 @@ package com.awakenedredstone.autowhitelist.server;
import com.awakenedredstone.autowhitelist.AutoWhitelist;
import com.awakenedredstone.autowhitelist.commands.AutoWhitelistCommand;
import com.awakenedredstone.autowhitelist.database.SQLite;
import com.awakenedredstone.autowhitelist.discord.Bot;
import com.awakenedredstone.autowhitelist.lang.JigsawLanguage;
import net.fabricmc.api.DedicatedServerModInitializer;
@ -29,8 +28,6 @@ public class AutoWhitelistServer implements DedicatedServerModInitializer {
ServerLifecycleEvents.SERVER_STOPPING.register((server -> Bot.stopBot()));
ServerLifecycleEvents.SERVER_STARTED.register((server -> {
AutoWhitelist.server = server;
new SQLite().connect();
try {
{
InputStream inputStream = AutoWhitelistServer.class.getResource("/messages.json").openStream();

Ver arquivo

@ -20,6 +20,7 @@ public class ExtendedWhitelist extends Whitelist {
super(file);
}
@SuppressWarnings("ConstantConditions")
protected ServerConfigEntry<GameProfile> fromJson(JsonObject json) {
ExtendedWhitelistEntry entry = new ExtendedWhitelistEntry(json);
try {

Ver arquivo

@ -36,14 +36,14 @@ public class ExtendedWhitelistEntry extends WhitelistEntry {
if (json.has("uuid") && json.has("name") && json.has("discordId") && json.has("team")) {
String string = json.get("uuid").getAsString();
UUID uUID2;
UUID uuid;
try {
uUID2 = UUID.fromString(string);
uuid = UUID.fromString(string);
} catch (Throwable var4) {
return null;
}
return new ExtendedGameProfile(uUID2, json.get("name").getAsString(), json.get("team").getAsString(), json.get("discordId").getAsString());
return new ExtendedGameProfile(uuid, json.get("name").getAsString(), json.get("team").getAsString(), json.get("discordId").getAsString());
} else {
return null;
}

Ver arquivo

@ -1,6 +1,6 @@
{
"command.register.success.title": "Welcome to the group!",
"command.register.success.message": "Your Minecraft account has been added to the whitelist.\nPlease remember that snapshots are buggy and unstable, so **please** verify before reporting them.\n\n_Please don't mess with what PhoenixSC is working on, you can get your entry removed._",
"command.register.success.message": "Your Minecraft account has been added to the whitelist.\nPlease verify before reporting bugs, it probably isn't caused by the mod.\n\n_Please remember that you can always get your entry removed if you break any rule._",
"command.register.last_steps.title": "Finishing some last things.",
"command.register.last_steps.message": "You request has been accepted.\nPlease wait while I add you to the server whitelist.\nI'll let you know when everything is done.",
"command.register.username_already_registered.title": "This username is already registered.",
@ -23,7 +23,7 @@
"command.few_args.title": "Not enough arguments.",
"command.few_args.message": "You didn't put the minimum amount of arguments required.\nCheck the help command to see the command usage.",
"command.too_many_args.title": "Too many arguments.",
"command.too_many_args.message": "You put too many arguments on the command.\nCheck the help command to see the command usage.",
"command.too_many_args.message": "You have put too many arguments on the command.\nCheck the help command to see the command usage.",
"command.feedback.received.title": "Command feedback.",
"command.feedback.received.message": "Your request has been received and is being processed, if you don't get another feedback message in the next minute than please contact a moderator.",