diff --git a/.vscode/settings.json b/.vscode/settings.json
new file mode 100644
index 0000000..c5f3f6b
--- /dev/null
+++ b/.vscode/settings.json
@@ -0,0 +1,3 @@
+{
+ "java.configuration.updateBuildConfiguration": "interactive"
+}
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index bc3166f..06e007b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,36 +1,50 @@
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
eus.aichan
BotBlocker
- 1.0-SNAPSHOT
+ 1.2-SNAPSHOT
jar
UTF-8
- 1.8
- 1.8
+ 18
+ 18
+
spigot-repo
https://hub.spigotmc.org/nexus/content/repositories/snapshots/
-
+
+
- org.spigotmc
- spigot-api
- 1.17.1-R0.1-SNAPSHOT
- provided
+ org.spigotmc
+ spigot-api
+ 1.20.1-R0.1-SNAPSHOT
+ provided
+
+
+
+ ${basedir}/src/main/resources
+ true
+
+ players.yml
+ plugin.yml
+ config.yml
+
+
+
clean package
@@ -54,4 +68,4 @@
-
+
\ No newline at end of file
diff --git a/src/main/java/eus/aichan/Blocker/BotBlocker.java b/src/main/java/eus/aichan/Blocker/BotBlocker.java
index 4b16321..3927730 100644
--- a/src/main/java/eus/aichan/Blocker/BotBlocker.java
+++ b/src/main/java/eus/aichan/Blocker/BotBlocker.java
@@ -13,6 +13,7 @@
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
+import java.io.IOException;
import java.util.HashMap;
import java.util.UUID;
@@ -22,6 +23,7 @@ public class BotBlocker extends JavaPlugin implements Listener {
private int timeLimit; // In seconds
private HashMap joinTimes = new HashMap<>();
private FileConfiguration playersCfg;
+ private File playersFile;
@Override
public void onEnable() {
@@ -29,7 +31,7 @@ public void onEnable() {
timeLimit = getConfig().getInt("time-limit", 60); // Default to 60 seconds
Bukkit.getPluginManager().registerEvents(this, this);
- File playersFile = new File(getDataFolder(), "players.yml");
+ playersFile = new File(getDataFolder(), "players.yml");
if (!playersFile.exists()) {
saveResource("players.yml", false);
}
@@ -93,8 +95,21 @@ public void onPlayerQuit(PlayerQuitEvent event) {
String playerName = event.getPlayer().getName();
Bukkit.getBanList(Type.NAME).addBan(playerName, "Bot detected. If you are a legitimate user, please contact the admin.", null, "Sistema anti-bot");
getLogger().info("Player '" + playerName + "' was banned for disconnecting within " + timeLimit + " seconds of joining for the first time - suspected bot.");
+ } else {
+ // Add the player to players.yml if it is not banned
+ playersCfg.set(playerId.toString(), true);
+ savePlayers();
}
joinTimes.remove(playerId);
}
}
+
+ private void savePlayers() {
+ try {
+ playersCfg.save(playersFile);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
}
diff --git a/src/main/resources/players.yml b/src/main/resources/players.yml
new file mode 100644
index 0000000..e69de29
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 34df6c0..ddb57a1 100755
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,6 +1,8 @@
name: BotBlocker
-main: eus.aichan.BotBlocker
-version: 1.0
+main: eus.aichan.Blocker.BotBlocker
+version: 1.2
+api-version: '1.20'
+author: aichan
description: A plugin to ban users who connect for the first time and disconnect within a certain time limit.
commands:
botblocker:
diff --git a/target/BotBlocker-1.2-SNAPSHOT.jar b/target/BotBlocker-1.2-SNAPSHOT.jar
new file mode 100644
index 0000000..38ccc6d
Binary files /dev/null and b/target/BotBlocker-1.2-SNAPSHOT.jar differ
diff --git a/target/classes/config.yml b/target/classes/config.yml
old mode 100755
new mode 100644
diff --git a/target/classes/eus/aichan/Blocker/BotBlocker.class b/target/classes/eus/aichan/Blocker/BotBlocker.class
index 1feca01..59db1c2 100644
Binary files a/target/classes/eus/aichan/Blocker/BotBlocker.class and b/target/classes/eus/aichan/Blocker/BotBlocker.class differ
diff --git a/target/classes/players.yml b/target/classes/players.yml
new file mode 100644
index 0000000..e69de29
diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml
old mode 100755
new mode 100644
index 34df6c0..ddb57a1
--- a/target/classes/plugin.yml
+++ b/target/classes/plugin.yml
@@ -1,6 +1,8 @@
name: BotBlocker
-main: eus.aichan.BotBlocker
-version: 1.0
+main: eus.aichan.Blocker.BotBlocker
+version: 1.2
+api-version: '1.20'
+author: aichan
description: A plugin to ban users who connect for the first time and disconnect within a certain time limit.
commands:
botblocker:
diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties
new file mode 100644
index 0000000..b96c4c5
--- /dev/null
+++ b/target/maven-archiver/pom.properties
@@ -0,0 +1,3 @@
+artifactId=BotBlocker
+groupId=eus.aichan
+version=1.2-SNAPSHOT
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 0000000..6329265
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+eus/aichan/Blocker/BotBlocker.class
diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 0000000..6366c0d
--- /dev/null
+++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/home/aichan/Documentos/GitHub/BotBlocker/src/main/java/eus/aichan/Blocker/BotBlocker.java