Skip to content

Commit

Permalink
1.2.3 Release
Browse files Browse the repository at this point in the history
1.2.3 Released
  • Loading branch information
BlueTree242 authored Oct 27, 2021
2 parents a7c6df5 + 32792ad commit 32b2406
Show file tree
Hide file tree
Showing 40 changed files with 1,530 additions and 188 deletions.
13 changes: 12 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,15 @@
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
hs_err_pid*




# Custom files
build/
.idea/
gradle/
.gradle/
gradlew
gradlew.bat
23 changes: 19 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
* END
*/

import org.apache.tools.ant.filters.ReplaceTokens

plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'java'
Expand All @@ -38,6 +40,7 @@ shadowJar {
relocate 'com.squareup.okhttp3', "tk.bluetree242.discordsrvutils.dependencies.okhttp"
relocate 'org.flywaydb', "tk.bluetree242.discordsrvutils.dependencies.flywaydb"
relocate 'org.bstats', "tk.bluetree242.discordsrvutils.dependencies.bstats"
relocate 'com.github.ben-manes.caffeine', 'tk.bluetree242.discordsrvutils.dependencies.caffeine'
}
build.finalizedBy shadowJar
repositories {
Expand Down Expand Up @@ -78,13 +81,17 @@ repositories {
url = uri('https://hub.spigotmc.org/nexus/content/repositories/snapshots/')
}


maven {
url = uri('https://repo.maven.apache.org/maven2/')
}
maven {
name 'm2-dv8tion'
url 'https://m2.dv8tion.net/releases'
}
maven { url "https://mvn-repo.arim.space/affero-gpl3" }
maven { url "https://mvn-repo.arim.space/gpl3" }
maven { url "https://mvn-repo.arim.space/lesser-gpl3" }
}

dependencies {
Expand All @@ -100,21 +107,29 @@ dependencies {
compileOnly 'com.github.DevLeoko:AdvancedBan:b4bbb6a'
compileOnly 'com.discordsrv:discordsrv:1.24.0'
compileOnly 'me.clip:placeholderapi:2.9.2'
compileOnly 'com.gitlab.ruany:LiteBansAPI:0.3.4'
implementation "org.flywaydb:flyway-core:7.5.3"
implementation group: 'org.json', name: 'json', version: '20210307'

implementation 'com.github.ben-manes.caffeine:caffeine:3.0.4'
compileOnly 'space.arim.libertybans:bans-api:0.8.0'
}

group = 'me.bluetree.discordsrvutils'
version = '1.2.2'
version = '1.2.3'
description = 'DiscordSRVUtils'
compileJava.options.encoding 'UTF-8'
java.sourceCompatibility = JavaVersion.VERSION_1_8
java.sourceCompatibility = JavaVersion.VERSION_11

publishing {
publications {
maven(MavenPublication) {
from(components.java)
}
}
}
}

processResources {
from(sourceSets.main.resources.srcDirs) {
filter ReplaceTokens, tokens: [version: version]
}
}
244 changes: 198 additions & 46 deletions src/main/java/tk/bluetree242/discordsrvutils/DiscordSRVUtils.java

Large diffs are not rendered by default.

68 changes: 68 additions & 0 deletions src/main/java/tk/bluetree242/discordsrvutils/PAPIExpansion.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* LICENSE
* DiscordSRVUtils
* -------------
* Copyright (C) 2020 - 2021 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* END
*/

package tk.bluetree242.discordsrvutils;

import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.entity.Player;
import tk.bluetree242.discordsrvutils.leveling.LevelingManager;

import java.util.regex.Pattern;

public class PAPIExpansion extends PlaceholderExpansion {
private DiscordSRVUtils core = DiscordSRVUtils.get();
@Override
public String getIdentifier() {
return "DiscordSRVUtils";
}

@Override
public boolean canRegister() {
return DiscordSRVUtils.get().isEnabled();
}

@Override
public String getAuthor() {
return String.join( ", ", core.getDescription().getAuthors());
}

@Override
public String getVersion() {
return core.getDescription().getVersion();
}

@Override
public String onPlaceholderRequest(Player p, String identifier) {
identifier = identifier.toLowerCase();
if (identifier.equalsIgnoreCase("level")) {
if (p == null) return "Unknown";
return LevelingManager.get().getCachedStats(p.getUniqueId()).getLevel() + "";
} else if (identifier.equalsIgnoreCase("xp")) {
if (p == null) return "Unknown";
return LevelingManager.get().getCachedStats(p.getUniqueId()).getXp() + "";
} else if (identifier.equalsIgnoreCase("rank")) {
if (p == null) return "Unknown";
return LevelingManager.get().getCachedStats(p.getUniqueId()).getRank() + "";
}
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,13 @@ public CompletableFuture handleCF(CompletableFuture cf, boolean shouldDM, String
}).handleAsync((e, x) -> {
Exception ex = (Exception) ((Throwable) x).getCause();
while (ex instanceof ExecutionException) ex = (Exception) ex.getCause();
ex.printStackTrace();
MessageChannel channel = shouldDM ? getAuthor().openPrivateChannel().complete() : getChannel();
if (ex instanceof UnCheckedRateLimitedException) {
channel.sendMessage(Embed.error(failure, "Rate limited. Try again in: " + Utils.getDuration(((RateLimitedException) ((UnCheckedRateLimitedException) ex).getCause()).getRetryAfter()))).queue();
} else
if (!(ex instanceof InsufficientPermissionException)) {
channel.sendMessage(Embed.error(failure)).queue();
DiscordSRVUtils.get().defaultHandle(ex);
} else {
InsufficientPermissionException exc = (InsufficientPermissionException) ex;
GuildChannel chnl = DiscordSRVUtils.get().getJDA().getShardManager().getGuildChannelById(exc.getChannelId());
Expand All @@ -163,13 +163,13 @@ public <H> CompletableFuture<H> handleCF(CompletableFuture<H> cf, boolean should
cf.handleAsync((e, x) -> {
Exception ex = (Exception) ((Throwable) x).getCause();
while (ex instanceof ExecutionException) ex = (Exception) ex.getCause();
ex.printStackTrace();
MessageChannel channel = shouldDM ? getAuthor().openPrivateChannel().complete() : getChannel();
if (ex instanceof UnCheckedRateLimitedException) {
channel.sendMessage(Embed.error(failure, "Rate limited. Try again in: " + Utils.getDuration(((RateLimitedException) ((UnCheckedRateLimitedException) ex).getCause()).getRetryAfter()))).queue();
} else
if (!(ex instanceof InsufficientPermissionException)) {
channel.sendMessage(Embed.error(failure)).queue();
DiscordSRVUtils.get().defaultHandle(ex);
} else {
InsufficientPermissionException exc = (InsufficientPermissionException) ex;
GuildChannel chnl = DiscordSRVUtils.get().getJDA().getGuildChannelById(exc.getChannelId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

package tk.bluetree242.discordsrvutils.commandmanagement;

import github.scarsz.discordsrv.DiscordSRV;
import github.scarsz.discordsrv.dependencies.jda.api.Permission;
import github.scarsz.discordsrv.dependencies.jda.api.entities.PrivateChannel;
import github.scarsz.discordsrv.dependencies.jda.api.entities.TextChannel;
Expand All @@ -31,6 +32,7 @@
import github.scarsz.discordsrv.dependencies.jda.api.hooks.ListenerAdapter;
import tk.bluetree242.discordsrvutils.DiscordSRVUtils;
import tk.bluetree242.discordsrvutils.embeds.Embed;
import tk.bluetree242.discordsrvutils.events.CommandExecuteEvent;

import java.util.regex.Pattern;

Expand Down Expand Up @@ -83,7 +85,7 @@ public void onMessageReceived(MessageReceivedEvent e) {
}
if (executor.isAdminOnly()) {
if (!core.isAdmin(e.getAuthor().getIdLong())) {
e.getMessage().reply(Embed.error("Only Admins can use this command.")).queue();
e.getMessage().reply(Embed.error("Only Admins can use this command.", "Your id must be in admin list on the config.yml")).queue();
return;
}
}
Expand All @@ -98,6 +100,11 @@ public void onMessageReceived(MessageReceivedEvent e) {
}
}
core.getLogger().info(e.getAuthor().getAsTag() + " Used " + core.getCommandPrefix() + cmd + " Command");
try {
DiscordSRV.api.callEvent(new CommandExecuteEvent(executor, e.getChannel(), e.getAuthor(), e));
} catch (Exception ex) {

}
executor.run(new CommandEvent(e.getMember(), e.getMessage(), e.getAuthor(), e.getChannel(), e.getJDA()));
} catch (InsufficientPermissionException ex) {
ex.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ public void run(CommandEvent e) throws Exception {
return;
}

if (e.getMember().getRoles().contains(core.getGuild().getRoleById(core.getSuggestionsConfig().suggestion_muted_role()))) {
e.replyErr("You are suggestion muted").queue();
return;
}

Long val = antispamMap.get(e.getAuthor().getIdLong());
if (val == null) {
} else {
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/tk/bluetree242/discordsrvutils/config/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,16 @@ public interface Config {

@AnnotationBasedSorter.Order(31)
@ConfKey("remove-discordsrv-link-listener")
@ConfComments("#Should we remove DiscordSRV's account link listener?? bot won't respond to dm link codes")
@ConfComments("#Should we remove DiscordSRV's account link listener?? bot won't respond to dm link codes\n#NOTE: Plugin uses reflection to do this. Which is like hacking into DiscordSRV")
@ConfDefault.DefaultBoolean(false)
boolean remove_discordsrv_link_listener();

@AnnotationBasedSorter.Order(32)
@ConfKey("linkaccount-channel")
@ConfComments("#Custom LinkAccount Channel. ")
@ConfDefault.DefaultLong(0)
long linkaccount_channel();

@AnnotationBasedSorter.Order(40)
@ConfKey("welcomer.enabled")
@ConfComments("#Should we do Welcomer?")
Expand Down Expand Up @@ -132,4 +138,10 @@ public interface Config {
@ConfDefault.DefaultBoolean(false)
Boolean bungee_mode();

@AnnotationBasedSorter.Order(160)
@ConfKey("minimize-errors")
@ConfComments("# Replace errors with small error note. Please note that this is a bad practise. If your console is spammed with errors (by this plugin) Please report at https://discordsrvutils.xyz/support")
@ConfDefault.DefaultBoolean(false)
Boolean minimize_errors();

}
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,6 @@ public interface SuggestionsConfig {
@ConfDefault.DefaultBoolean(false)
Boolean allow_submitter_vote();

@AnnotationBasedSorter.Order(50)
@ConfComments("# Should users be able to vote both yes and no?")
@ConfDefault.DefaultBoolean(false)
Boolean allow_both_vote();


@AnnotationBasedSorter.Order(60)
Expand Down Expand Up @@ -104,4 +100,14 @@ public interface SuggestionsConfig {
@ConfDefault.DefaultBoolean(false)
Boolean dm_submitter_when_approved();
*/

@AnnotationBasedSorter.Order(120)
@ConfComments("# Role that if user have they can't make suggestions")
@ConfDefault.DefaultLong(0)
Long suggestion_muted_role();

@AnnotationBasedSorter.Order(130)
@ConfComments("# Mode of the suggestions. Set to BUTTONS to make it use buttons instead of reactions/n# Note that changing this is not affected until server restart./n#Another note is that your votes will be reset by changing this")
@ConfDefault.DefaultString("REACTIONS")
String suggestions_vote_mode();
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ public interface TicketsConfig {
@ConfDefault.DefaultString("message:ticket-reopen")
@ConfComments("#Message to send in ticket when its reopened")
String ticket_reopen_message();

@AnnotationBasedSorter.Order(40)
@ConfKey("ticket-banned-role")
@ConfComments("# If user have this role they can't open a ticket")
@ConfDefault.DefaultLong(0)
Long ticket_banned_role();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* LICENSE
* DiscordSRVUtils
* -------------
* Copyright (C) 2020 - 2021 BlueTree242
* -------------
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program. If not, see
* <http://www.gnu.org/licenses/gpl-3.0.html>.
* END
*/

package tk.bluetree242.discordsrvutils.events;

import github.scarsz.discordsrv.api.events.Event;
import github.scarsz.discordsrv.dependencies.jda.api.entities.MessageChannel;
import github.scarsz.discordsrv.dependencies.jda.api.entities.User;
import github.scarsz.discordsrv.dependencies.jda.api.events.message.MessageReceivedEvent;
import tk.bluetree242.discordsrvutils.commandmanagement.Command;

public class CommandExecuteEvent extends Event {


private final Command command;
private final MessageChannel channel;
private final User user;
private final MessageReceivedEvent event;

public CommandExecuteEvent(Command command, MessageChannel channel, User user, MessageReceivedEvent event) {
this.command = command;
this.channel = channel;
this.user = user;
this.event = event;
}

public Command getCommand() {
return command;
}

public MessageChannel getChannel() {
return channel;
}

public User getUser() {
return user;
}

public MessageReceivedEvent getEvent() {
return event;
}
}
Loading

0 comments on commit 32b2406

Please sign in to comment.