Skip to content

Commit

Permalink
-Added /revive command to revive a player with specified amount of er…
Browse files Browse the repository at this point in the history
…m idk whatever
  • Loading branch information
ashyan committed Nov 14, 2022
1 parent 8c3faed commit eb5ed8d
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 30 deletions.
8 changes: 7 additions & 1 deletion Spigot Ban Plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ashyan</groupId>
<artifactId>auto-ban</artifactId>
<version>1.0-SNAPSHOT</version>
<version>1.2-SNAPSHOT</version>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand Down Expand Up @@ -42,6 +42,12 @@
<artifactId>JDA</artifactId>
<version>5.0.0-alpha.22</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>plugin-annotations</artifactId>
<version>1.2.3-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand Down
3 changes: 2 additions & 1 deletion Spigot Ban Plugin/src/AutoBanConfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ bot-token: BOT_TOKEN
server-id: SERVER_ID
chat-name: CHAT_NAME
time-type: second
time-length: 5
time-length: 5
diamond-removal-amount: 16
23 changes: 6 additions & 17 deletions Spigot Ban Plugin/src/main/java/ashyan/AutoBan.java
Original file line number Diff line number Diff line change
@@ -1,27 +1,14 @@
package ashyan;

import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.requests.GatewayIntent;

import org.bukkit.BanEntry;
import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginLoadOrder;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.BanList;
import org.w3c.dom.Text;
import org.bukkit.plugin.java.annotation.command.Command;
import org.bukkit.plugin.java.annotation.command.Commands;
import org.bukkit.plugin.java.annotation.plugin.Plugin;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.temporal.ChronoUnit;
import java.util.Date;
import java.util.EnumSet;
import java.util.logging.Logger;

import static java.lang.Integer.parseInt;
import static org.bukkit.BanList.Type.NAME;

public class AutoBan extends JavaPlugin {
JDA jda;
DataManager data;
Expand All @@ -38,6 +25,8 @@ public void onEnable() {

MyListener serverListener = new MyListener(discordBot, banManager);
getServer().getPluginManager().registerEvents(serverListener, this);

this.getCommand("revive").setExecutor(new CommandRevive(banManager, data, discordBot));
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, new Runnable() {
@Override
public void run() {
Expand Down
16 changes: 16 additions & 0 deletions Spigot Ban Plugin/src/main/java/ashyan/BanManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,11 @@ public void updateBanList(DiscordBot discordBot) {
}
}

public void unBan(String playerName) {
BanList banned = Bukkit.getBanList(NAME);
banned.pardon(playerName);
}

public String checkUnban(String username)
{
BanList banned = Bukkit.getBanList(NAME);
Expand All @@ -100,6 +105,17 @@ public String checkUnban(String username)
return "Could not find " + username + " in ban list";
}

public boolean isBanned(String username) {
BanList banned = Bukkit.getBanList(NAME);
for (BanEntry player : banned.getBanEntries()) {
if(player.getTarget().equals(username)) {
return true;
}
}

return false;
}

public void onDeath(PlayerDeathEvent event) {
Logger logger = Bukkit.getLogger();
BanList banned = Bukkit.getBanList(NAME);
Expand Down
2 changes: 1 addition & 1 deletion Spigot Ban Plugin/src/main/java/ashyan/MyListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public void onDeath(PlayerDeathEvent event) {

String death = event.getDeathMessage();

String message = death + " They will be unbanned at " + unbanStr;
String message = death + ". They will be unbanned at " + unbanStr;
this.discordBot.sendMesageToChannel(message);
}

Expand Down
8 changes: 6 additions & 2 deletions Spigot Ban Plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
name: AutoBan
version: 1.0
version: 1.2
main: ashyan.AutoBan
api-version: 1.17
api-version: 1.17
commands:
revive:
description: Unbans the inputted playername for the configured amount of diamonds
usage: /<command> <playerName>
4 changes: 0 additions & 4 deletions Spigot Ban Plugin/target/classes/plugin.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Spigot Ban Plugin/target/maven-archiver/pom.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#Generated by Maven
#Sat Nov 05 01:26:06 PDT 2022
#Sun Nov 13 18:49:42 PST 2022
groupId=ashyan
artifactId=auto-ban
version=1.0-SNAPSHOT
version=1.2-SNAPSHOT
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ ashyan\MyListener.class
ashyan\BanManager.class
ashyan\AutoBan$1.class
ashyan\DataManager.class
ashyan\CommandRevive.class
ashyan\AutoBan.class
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ E:\Code Stuff\IntelliJ\SpigotAutoBan\Spigot Ban Plugin\src\main\java\ashyan\Auto
E:\Code Stuff\IntelliJ\SpigotAutoBan\Spigot Ban Plugin\src\main\java\ashyan\MyListener.java
E:\Code Stuff\IntelliJ\SpigotAutoBan\Spigot Ban Plugin\src\main\java\ashyan\BanManager.java
E:\Code Stuff\IntelliJ\SpigotAutoBan\Spigot Ban Plugin\src\main\java\ashyan\DiscordBot.java
E:\Code Stuff\IntelliJ\SpigotAutoBan\Spigot Ban Plugin\src\main\java\ashyan\CommandRevive.java
E:\Code Stuff\IntelliJ\SpigotAutoBan\Spigot Ban Plugin\src\main\java\ashyan\DataManager.java
5 changes: 3 additions & 2 deletions Spigot Ban Plugin/target/packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@
if "AutoBan" in os.listdir("E:/Code Stuff/mc server/plugins/"):
shutil.rmtree("E:/Code Stuff/mc server/plugins/AutoBan")

shutil.copyfile("auto-ban-1.0-SNAPSHOT-All.jar", "E:/Code Stuff/mc server/plugins/AutoBan.jar")
shutil.copyfile(os.getcwd() + "/../src/AutoBanConfig.yml", "E:/Code Stuff/mc server/plugins/AutoBanConfig.yml")
shutil.copyfile("auto-ban-1.2-SNAPSHOT-All.jar", "E:/Code Stuff/mc server/plugins/AutoBan.jar")
shutil.copyfile(os.getcwd() + "/../src/AutoBanConfig.yml", "E:/Code Stuff/mc server/plugins/AutoBanConfig.yml")
#shutil.copyfile(os.getcwd() + "/../src/main/resources/plugin.yml", "E:/Code Stuff/mc server/plugin.yml")

0 comments on commit eb5ed8d

Please sign in to comment.