Added the old global bot
This commit is contained in:
parent
221cf5db37
commit
dd94bf8159
22
SheepstarGlobal/.github/workflows/maven.yml
vendored
Normal file
22
SheepstarGlobal/.github/workflows/maven.yml
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
# This workflow will build a Java project with Maven
|
||||
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven
|
||||
|
||||
name: Java CI with Maven
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up JDK 1.8
|
||||
uses: actions/setup-java@v1
|
||||
with:
|
||||
java-version: 1.8
|
||||
- name: Build with Maven
|
||||
run: mvn -B package --file pom.xml
|
2
SheepstarGlobal/.gitignore
vendored
Executable file
2
SheepstarGlobal/.gitignore
vendored
Executable file
@ -0,0 +1,2 @@
|
||||
# Project exclude paths.
|
||||
/target/
|
3
SheepstarGlobal/.idea/.gitignore
generated
vendored
Executable file
3
SheepstarGlobal/.idea/.gitignore
generated
vendored
Executable file
@ -0,0 +1,3 @@
|
||||
# Default ignored files
|
||||
/shelf/
|
||||
/workspace.xml
|
26
SheepstarGlobal/.idea/artifacts/sheepstar.xml
generated
Executable file
26
SheepstarGlobal/.idea/artifacts/sheepstar.xml
generated
Executable file
@ -0,0 +1,26 @@
|
||||
<component name="ArtifactManager">
|
||||
<artifact type="jar" name="sheepstar">
|
||||
<output-path>$PROJECT_DIR$/out/</output-path>
|
||||
<root id="archive" name="Sheepstar Global.jar">
|
||||
<element id="module-output" name="Sheepstar Global" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/dv8tion/JDA/4.2.0_222/JDA-4.2.0_222.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/apache/commons/commons-collections4/4.1/commons-collections4-4.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/squareup/okio/okio/1.17.2/okio-1.17.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/club/minnced/opus-java-api/1.0.4/opus-java-api-1.0.4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.25/slf4j-api-1.7.25.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-core/2.10.1/jackson-core-2.10.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/neovisionaries/nv-websocket-client/2.10/nv-websocket-client-2.10.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/org/jetbrains/annotations/16.0.1/annotations-16.0.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/squareup/okhttp3/okhttp/3.13.0/okhttp-3.13.0.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-databind/2.10.1/jackson-databind-2.10.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/fasterxml/jackson/core/jackson-annotations/2.10.1/jackson-annotations-2.10.1.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/club/minnced/opus-java-natives/1.0.4/opus-java-natives-1.0.4.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/com/google/code/findbugs/jsr305/3.0.2/jsr305-3.0.2.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$PROJECT_DIR$/../../Desktop/mysql_trash.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$MAVEN_REPOSITORY$/net/dv8tion/JDA/4.2.0_214/JDA-4.2.0_214.jar" path-in-jar="/" />
|
||||
<element id="extracted-dir" path="$USER_HOME$/Desktop/SqlToolkit/mysql-connector-java-8.0.22.jar" path-in-jar="/" />
|
||||
</root>
|
||||
</artifact>
|
||||
</component>
|
13
SheepstarGlobal/.idea/compiler.xml
generated
Executable file
13
SheepstarGlobal/.idea/compiler.xml
generated
Executable file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<annotationProcessing>
|
||||
<profile name="Maven default annotation processors profile" enabled="true">
|
||||
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||
<outputRelativeToContentRoot value="true" />
|
||||
<module name="Sheepstar Global" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
</project>
|
6
SheepstarGlobal/.idea/discord.xml
generated
Executable file
6
SheepstarGlobal/.idea/discord.xml
generated
Executable file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="DiscordProjectSettings">
|
||||
<option name="show" value="PROJECT_FILES" />
|
||||
</component>
|
||||
</project>
|
40
SheepstarGlobal/.idea/jarRepositories.xml
generated
Executable file
40
SheepstarGlobal/.idea/jarRepositories.xml
generated
Executable file
@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="RemoteRepositoriesConfiguration">
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Central Repository" />
|
||||
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jcenter" />
|
||||
<option name="name" value="jcenter-bintray" />
|
||||
<option name="url" value="https://jcenter.bintray.com" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jitpack.io" />
|
||||
<option name="name" value="jitpack.io" />
|
||||
<option name="url" value="https://jitpack.io" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="Maven Central repository" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="qshort" />
|
||||
<option name="name" value="qshort" />
|
||||
<option name="url" value="https://maven.nsnetwork.de/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="central" />
|
||||
<option name="name" value="central" />
|
||||
<option name="url" value="https://repo1.maven.org/maven2/" />
|
||||
</remote-repository>
|
||||
<remote-repository>
|
||||
<option name="id" value="jboss.community" />
|
||||
<option name="name" value="JBoss Community repository" />
|
||||
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||
</remote-repository>
|
||||
</component>
|
||||
</project>
|
9
SheepstarGlobal/.idea/libraries/mysql_connector_java_8_0_22.xml
generated
Normal file
9
SheepstarGlobal/.idea/libraries/mysql_connector_java_8_0_22.xml
generated
Normal file
@ -0,0 +1,9 @@
|
||||
<component name="libraryTable">
|
||||
<library name="mysql-connector-java-8.0.22">
|
||||
<CLASSES>
|
||||
<root url="jar://$USER_HOME$/Desktop/SqlToolkit/mysql-connector-java-8.0.22.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES />
|
||||
</library>
|
||||
</component>
|
14
SheepstarGlobal/.idea/misc.xml
generated
Executable file
14
SheepstarGlobal/.idea/misc.xml
generated
Executable file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||
<component name="MavenProjectsManager">
|
||||
<option name="originalFiles">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/pom.xml" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
</project>
|
124
SheepstarGlobal/.idea/uiDesigner.xml
generated
Executable file
124
SheepstarGlobal/.idea/uiDesigner.xml
generated
Executable file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
6
SheepstarGlobal/.idea/vcs.xml
generated
Executable file
6
SheepstarGlobal/.idea/vcs.xml
generated
Executable file
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||
</component>
|
||||
</project>
|
2
SheepstarGlobal/README.md
Normal file
2
SheepstarGlobal/README.md
Normal file
@ -0,0 +1,2 @@
|
||||
# Sheepstar Old Global Bot
|
||||
Dies ist der alte Sheepstar Global Bot. Er wird in der Zukunft entfernt, sobald der richtige Sheepstar Bot vollständig programmiert wurde. :)
|
56
SheepstarGlobal/pom.xml
Executable file
56
SheepstarGlobal/pom.xml
Executable file
@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
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">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>de.sheepstar</groupId>
|
||||
<artifactId>global</artifactId>
|
||||
<version>1.0</version>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>8</maven.compiler.source>
|
||||
<maven.compiler.target>8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<configuration>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>de.sheepstar.globalWrapper.core.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
<descriptorRefs>
|
||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||
</descriptorRefs>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>jcenter</id>
|
||||
<name>jcenter-bintray</name>
|
||||
<url>https://jcenter.bintray.com</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>net.dv8tion</groupId>
|
||||
<artifactId>JDA</artifactId>
|
||||
<version>4.2.0_222</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>mysql</groupId>
|
||||
<artifactId>mysql-connector-java</artifactId>
|
||||
<version>8.0.25</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
223
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/GlobalManager.java
Executable file
223
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/GlobalManager.java
Executable file
@ -0,0 +1,223 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class GlobalManager {
|
||||
|
||||
public boolean isRegistered(Guild guild, TextChannel channel) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM guilds WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isDescRegistered(Guild guild, TextChannel channel) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM server_autoupdate WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void register(Guild guild, TextChannel channel) {
|
||||
if (isRegistered(guild, channel)) return;
|
||||
MySQL.update("INSERT INTO guilds (guildID, channelID, languageCode, roomID) VALUES (?, ?, 'EN', '1')", guild.getId(), channel.getId());
|
||||
}
|
||||
|
||||
public void unregister(Guild guild, TextChannel channel) {
|
||||
if (!isRegistered(guild, channel)) return;
|
||||
MySQL.update("DELETE FROM guilds WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
}
|
||||
|
||||
public boolean isValidRoom(String str) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM rooms WHERE code=?", str);
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPremium(Guild guild) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM premium WHERE guildID=?", guild.getId());
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValidLanguage(String str) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM languages WHERE code=?", str.toUpperCase());
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void changeLanguageCode(Guild guild, TextChannel channel, String newLanguage) {
|
||||
if (!isValidLanguage(newLanguage)) return;
|
||||
MySQL.update("UPDATE guilds SET languageCode=? WHERE guildID=? AND channelID=?", newLanguage.toUpperCase(), guild.getId(), channel.getId());
|
||||
}
|
||||
|
||||
public void changeRoomID(Guild guild, TextChannel channel, String newRoom) {
|
||||
if (!isValidRoom(newRoom)) return;
|
||||
MySQL.update("UPDATE guilds SET roomID=? WHERE guildID=? AND channelID=?", newRoom, guild.getId(), channel.getId());
|
||||
}
|
||||
|
||||
public void setPremium(Guild guild) {
|
||||
if (!hasPremium(guild)) {
|
||||
MySQL.update("INSERT INTO premium (guildID) VALUES (?)", guild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public String getDesign(Guild guild) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM designs WHERE guildID=?", guild.getId());
|
||||
try {
|
||||
while (rs.next()) {
|
||||
return rs.getString("designID");
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
return "1";
|
||||
}
|
||||
|
||||
public boolean isDesignRegistered(Guild guild) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM designs WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) { return true; } } catch (Exception ignore) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isValidDesign(String designID) {
|
||||
return new ArrayList<>(Arrays.asList("1", "2", "3", "4", "5")).contains(designID);
|
||||
}
|
||||
|
||||
public void registerDesign(Guild guild, String design) {
|
||||
if (!isDesignRegistered(guild) && isValidDesign(design)) {
|
||||
MySQL.update("INSERT INTO designs (guildID, designID) VALUES (?, ?)", guild.getId(), design);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateDesign(Guild guild, String design) {
|
||||
if (!isDesignRegistered(guild)) registerDesign(guild, design);
|
||||
if (isDesignRegistered(guild) && isValidDesign(design)) {
|
||||
MySQL.update("UPDATE designs SET designID=? WHERE guildID=?", design, guild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isBanned(Guild guild) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM server_bans WHERE guildID=?", guild.getId());
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void banServer(Guild guild) {
|
||||
if (!isBanned(guild)) {
|
||||
MySQL.update("INSERT INTO server_bans (guildID) VALUES (?)", guild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public void unbanServer(Guild guild) {
|
||||
if (isBanned(guild)) {
|
||||
MySQL.update("DELETE FROM server_bans WHERE guildID=? ", guild.getId());
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isGlobalUserBanned(String userID) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM user_bans WHERE clientID=?", userID);
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void banUserGlobal(String userID) {
|
||||
if (!isGlobalUserBanned(userID)) {
|
||||
MySQL.update("INSERT INTO user_bans (clientID) VALUES (?)", userID);
|
||||
}
|
||||
}
|
||||
|
||||
public void unbanUserGlobal(String userID) {
|
||||
if (isGlobalUserBanned(userID)) {
|
||||
MySQL.update("DELETE FROM user_bans WHERE clientID=? ", userID);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isGuildUserBanned(Guild guild, String userID) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM suser_bans WHERE guildID=? AND clientID=?", guild.getId(), userID);
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void banUserGuild(Guild guild, String userID) {
|
||||
if (!isGuildUserBanned(guild, userID)) {
|
||||
MySQL.update("INSERT INTO suser_bans (guildID, clientID) VALUES (?, ?)", guild.getId(), userID);
|
||||
}
|
||||
}
|
||||
|
||||
public void unbanUserGuild(Guild guild, String userID) {
|
||||
if (isGuildUserBanned(guild, userID)) {
|
||||
MySQL.update("DELETE FROM suser_bans WHERE guildID=? AND clientID=? ", guild.getId(), userID);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getCount(String language, String room) {
|
||||
int count = 0;
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM guilds WHERE languageCode=? AND roomID=?", language, room);
|
||||
try { while (rs.next()) {count++;} } catch (Exception err) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
int count = 0;
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM guilds");
|
||||
try { while (rs.next()) {count++;} } catch (Exception err) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getCount(Guild guild) {
|
||||
int count = 0;
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM guilds WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) {count++;} } catch (Exception err) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
public boolean alreadyServerBlacklisted(Guild guild, String word) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM sword_blacklist WHERE guildID=? AND word=?", guild.getId(), word);
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean alreadyGlobalBlacklisted(String word) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM word_blacklist WHERE word=?", word);
|
||||
try {
|
||||
while (rs.next()) return true;
|
||||
} catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public void insertLog(String guildID, String senderID, String message, String language, String roomID) {
|
||||
if (message.isEmpty()) message = "empty";
|
||||
MySQL.update("INSERT INTO log (guildID, senderID, message, language, roomID) VALUES (?, ?, ?, ?, ?)",
|
||||
guildID, senderID, message , language, roomID);
|
||||
}
|
||||
|
||||
}
|
119
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/LevelManager.java
Executable file
119
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/LevelManager.java
Executable file
@ -0,0 +1,119 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageBuilder;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageType;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class LevelManager {
|
||||
|
||||
private Guild guild;
|
||||
|
||||
public LevelManager(Guild guild) {
|
||||
this.guild = guild;
|
||||
}
|
||||
|
||||
|
||||
public void updateXP(String newXP) {
|
||||
if (!isRegistered()) register();
|
||||
MySQL.update("UPDATE levels SET xp=? WHERE guildID=?", newXP, guild.getId());
|
||||
}
|
||||
|
||||
public void increaseXP(String addXP) {
|
||||
if (!isRegistered()) register();
|
||||
MySQL.update("UPDATE levels SET xp=xp+? WHERE guildID=?", addXP, guild.getId());
|
||||
}
|
||||
|
||||
public void updateLevel(String newLevel) {
|
||||
if (!isRegistered()) register();
|
||||
MySQL.update("UPDATE levels SET level=? WHERE guildID=?", newLevel, guild.getId());
|
||||
}
|
||||
|
||||
public void removeLevel(String removeLevel) {
|
||||
if (!isRegistered()) register();
|
||||
MySQL.update("UPDATE levels SET level=level-? WHERE guildID=?", removeLevel, guild.getId());
|
||||
}
|
||||
|
||||
public void increaseLevel(String addLevel) {
|
||||
if (!isRegistered()) register();
|
||||
MySQL.update("UPDATE levels SET level=level+? WHERE guildID=?", addLevel, guild.getId());
|
||||
}
|
||||
|
||||
public void increase(TextChannel channel, String addXP) {
|
||||
increaseXP(addXP);
|
||||
int currentXP = Integer.parseInt(getXP());
|
||||
int neededXP = getNeededXP();
|
||||
if (currentXP >= neededXP) {
|
||||
levelUp(channel);
|
||||
if (currentXP != 0) updateXP(String.valueOf(currentXP - neededXP));
|
||||
}
|
||||
}
|
||||
|
||||
public int getNeededXP() {
|
||||
return Integer.parseInt(getLevel())*50+5;
|
||||
}
|
||||
|
||||
private boolean isRegistered() {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM levels WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) { return true; } } catch (Exception ignored) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
private void register() {
|
||||
if (isRegistered()) return;
|
||||
MySQL.update("INSERT INTO levels (guildID, xp, level) VALUES (?, '0', '0')", guild.getId());
|
||||
}
|
||||
|
||||
public void levelUp(TextChannel channel) {
|
||||
if (!isRegistered()) register();
|
||||
MySQL.update("UPDATE levels SET level=level+1 WHERE guildID=?", guild.getId());
|
||||
MySQL.update("UPDATE levels SET xp=0 WHERE guildID=?", guild.getId());
|
||||
new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("Level up!")
|
||||
.setDescription("You reached level " + getLevel())
|
||||
.send(channel);
|
||||
}
|
||||
|
||||
public String getXP() {
|
||||
if (!isRegistered()) register();
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM levels WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) { return rs.getString("xp"); } } catch (Exception ignored) {}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public String getLevel() {
|
||||
if (!isRegistered()) register();
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM levels WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) { return rs.getString("level"); } } catch (Exception ignored) {}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public String getLevel(Guild guild) {
|
||||
if (!isRegistered()) register();
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM levels WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) { return rs.getString("level"); } } catch (Exception ignored) {}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public ArrayList<Guild> getTopList(int limit) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM levels ORDER BY `level` DESC LIMIT " + limit);
|
||||
ArrayList<Guild> topList = new ArrayList<>();
|
||||
try { while (rs.next()) { try { topList.add(Main.getInstance().getGuildById(rs.getString("guildID"))); } catch (Exception ignored) { } } } catch (Exception ignored) { }
|
||||
return topList;
|
||||
}
|
||||
|
||||
public Guild getGuild() {
|
||||
return guild;
|
||||
}
|
||||
}
|
42
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/LogManager.java
Executable file
42
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/LogManager.java
Executable file
@ -0,0 +1,42 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.User;
|
||||
|
||||
import java.sql.Array;
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 13.12.20
|
||||
********************************/
|
||||
|
||||
public class LogManager {
|
||||
|
||||
public ArrayList<String> getServerMessages(String guildID, int limit) {
|
||||
String limitLine = (limit > 1 ? " LIMIT " + limit : "");
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM log WHERE guildID=?" + limitLine, guildID);
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
arrayList.add(rs.getString("message"));
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
public ArrayList<String> getUserMessages(String userID, int limit) {
|
||||
String limitLine = (limit > 1 ? " LIMIT " + limit : "");
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM log WHERE senderID=?" + limitLine, userID);
|
||||
ArrayList<String> arrayList = new ArrayList<>();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
arrayList.add(rs.getString("message"));
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
return arrayList;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.sql.SqlParam;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Role;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class SheepManager {
|
||||
|
||||
public static boolean BETA_INSTANCE = false;
|
||||
|
||||
public ArrayList<String> botOwners = new ArrayList<>();
|
||||
|
||||
public Role supporterRole;
|
||||
|
||||
private HashMap<SqlParam, String> sqlParams = new HashMap<>();
|
||||
|
||||
public String getSQLParam(SqlParam param) {
|
||||
return sqlParams.getOrDefault(param, "null");
|
||||
}
|
||||
|
||||
private void registerSQLParam(SqlParam param, String value) {
|
||||
if (!sqlParams.containsKey(param))
|
||||
sqlParams.put(param, value);
|
||||
}
|
||||
|
||||
public String getBetaToken() {
|
||||
return "protected";
|
||||
}
|
||||
|
||||
public String getDefaultToken() {
|
||||
return "protected";
|
||||
}
|
||||
|
||||
public String getToken() {
|
||||
if (BETA_INSTANCE) {
|
||||
return getBetaToken();
|
||||
} else {
|
||||
return getDefaultToken();
|
||||
}
|
||||
}
|
||||
|
||||
public static String getPrefix() {
|
||||
return "» Sheepstar | ";
|
||||
}
|
||||
|
||||
public SheepManager register() {
|
||||
registerSQLParam(SqlParam.HOSTNAME, "protected");
|
||||
registerSQLParam(SqlParam.USERNAME, "protected");
|
||||
registerSQLParam(SqlParam.PASSWORD, "protected");
|
||||
registerSQLParam(SqlParam.DATABASE, "protected");
|
||||
botOwners.add("357214370188492802");
|
||||
botOwners.add("386242172632170496");
|
||||
return this;
|
||||
}
|
||||
|
||||
public static void sendConsoleMessage(String message) {
|
||||
System.out.println(getPrefix() + message);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
public enum SheepPermission {
|
||||
|
||||
ADMINISTRATOR,
|
||||
SUPPORTER,
|
||||
BOT_OWNER,
|
||||
UNKNOWN;
|
||||
|
||||
}
|
@ -0,0 +1,120 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageBuilder;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageType;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public abstract class SheepstarGuildCommand extends ListenerAdapter {
|
||||
|
||||
public String replaceUserMention(String content) {
|
||||
return content
|
||||
.replace("<@!", "")
|
||||
.replace("<@", "")
|
||||
.replace("<!", "")
|
||||
.replace(">", "");
|
||||
}
|
||||
|
||||
public String getPrefix() {
|
||||
if (SheepManager.BETA_INSTANCE) {
|
||||
return "st!";
|
||||
} else {
|
||||
return "s!";
|
||||
}
|
||||
}
|
||||
|
||||
public StrangerManager getStrangerManager() {
|
||||
return Main.getStrangerManager();
|
||||
}
|
||||
|
||||
public GlobalManager getGlobalManager() {
|
||||
return Main.getGlobalManager();
|
||||
}
|
||||
|
||||
public MessageBuilder sendErrorMessage() {
|
||||
return new MessageBuilder(MessageType.RED_MESSAGE);
|
||||
}
|
||||
|
||||
public MessageBuilder sendMessage() {
|
||||
return new MessageBuilder(MessageType.GREEN_MESSAGE);
|
||||
}
|
||||
|
||||
public JDA getJDA() { return Main.getInstance(); }
|
||||
|
||||
public abstract List<String> getAlias();
|
||||
|
||||
public abstract SheepPermission getPermission();
|
||||
|
||||
public abstract void executeCommand(String[] args, GuildMessageReceivedEvent e);
|
||||
|
||||
@Override
|
||||
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
|
||||
if (e.getAuthor() == null || e.getChannel() == null) return;
|
||||
if (e.getAuthor().isBot()) return;
|
||||
if (!isValidCommand(e.getGuild(), e.getMessage())) return;
|
||||
|
||||
if (!getPermission().equals(null)) {
|
||||
|
||||
if (getPermission() == SheepPermission.ADMINISTRATOR) {
|
||||
if (!e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You dont have the permission to do this.")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
} else if (getPermission() == SheepPermission.BOT_OWNER) {
|
||||
if (!Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Only Bot Owners have Permission for this Command")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
} else if (getPermission() == SheepPermission.SUPPORTER) {
|
||||
if (!(e.getMember().getRoles().contains(Main.getSheepManager().supporterRole) || Main.getSheepManager().botOwners.contains(e.getAuthor().getId()))) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You dont have the permission to do this.")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String[] args = commandArgs(e.getGuild(), e.getMessage());
|
||||
executeCommand(args, e);
|
||||
}
|
||||
|
||||
private boolean isValidCommand(Guild guild, Message msg) {
|
||||
String prefix = getPrefix();
|
||||
if (!msg.getContentRaw().startsWith(prefix)) return false;
|
||||
String cmdName = msg.getContentRaw().substring(prefix.length()).toLowerCase();
|
||||
if (cmdName.contains(" ")) {
|
||||
cmdName = cmdName.substring(0, cmdName.indexOf(" "));
|
||||
}
|
||||
if (cmdName.contains("\n")) {
|
||||
cmdName = cmdName.substring(0, cmdName.indexOf("\n"));
|
||||
}
|
||||
return getAlias().contains(cmdName);
|
||||
}
|
||||
|
||||
private String[] commandArgs(Guild guild, Message msg) {
|
||||
String prefix = getPrefix();
|
||||
String noPrefix = msg.getContentRaw().substring(prefix.length());
|
||||
if (!noPrefix.contains(" ")) {
|
||||
return new String[]{};
|
||||
}
|
||||
return noPrefix.substring(noPrefix.indexOf(" ") + 1).split("\\s+");
|
||||
}
|
||||
|
||||
}
|
53
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/ShopItem.java
Executable file
53
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/ShopItem.java
Executable file
@ -0,0 +1,53 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class ShopItem {
|
||||
|
||||
private String price;
|
||||
private String premiumPrice;
|
||||
private String description;
|
||||
private boolean multiple_buyable;
|
||||
|
||||
public ShopItem(String price, String premiumPrice, String description, boolean multiple_buyable) {
|
||||
this.price = price;
|
||||
this.premiumPrice = premiumPrice;
|
||||
this.description = description;
|
||||
this.multiple_buyable = multiple_buyable;
|
||||
}
|
||||
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
public String getPremiumPrice() {
|
||||
return premiumPrice;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public boolean isMultiple_buyable() {
|
||||
return multiple_buyable;
|
||||
}
|
||||
|
||||
public void setPrice(String price) {
|
||||
this.price = price;
|
||||
}
|
||||
|
||||
public void setPremiumPrice(String premiumPrice) {
|
||||
this.premiumPrice = premiumPrice;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setMultiple_buyable(boolean multiple_buyable) {
|
||||
this.multiple_buyable = multiple_buyable;
|
||||
}
|
||||
}
|
29
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/ShopItems.java
Executable file
29
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/ShopItems.java
Executable file
@ -0,0 +1,29 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class ShopItems {
|
||||
|
||||
public static HashMap<String, ShopItem> shopItems = new HashMap<>();
|
||||
|
||||
public static void register() {
|
||||
add("premium", new ShopItem("250", "250", "A nice item", false));
|
||||
add("design_2", new ShopItem("150", "120", "2nd Design", false));
|
||||
add("design_3", new ShopItem("175", "135", "3rd Design", false));
|
||||
add("design_4", new ShopItem("150", "120", "4rd Design", false));
|
||||
add("channel", new ShopItem("150", "120", "Another Global Chat Channel", true));
|
||||
add("booster", new ShopItem("200", "170", "Boosts your xp", true));
|
||||
}
|
||||
|
||||
public static void add(String name, ShopItem item) {
|
||||
shopItems.put(name, item);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class ShopManager {
|
||||
|
||||
LevelManager levelManager;
|
||||
Guild guild;
|
||||
|
||||
public ShopManager(LevelManager lm) {
|
||||
this.levelManager = lm;
|
||||
this.guild = lm.getGuild();
|
||||
}
|
||||
|
||||
public void buyItem(String price, String item, boolean checkItemOwnership) {
|
||||
if (checkItemOwnership && hasItem(item)) return;
|
||||
if (Integer.parseInt(levelManager.getLevel()) >= Integer.parseInt(price)) {
|
||||
if (item.equals("premium")) {
|
||||
Main.getGlobalManager().setPremium(guild);
|
||||
return;
|
||||
}
|
||||
MySQL.update("INSERT INTO items_buyed (guildID, item) VALUES (?, ?)", guild.getId(), item);
|
||||
levelManager.removeLevel(price);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasItem(String item) {
|
||||
if (item.equals("premium")) {
|
||||
return Main.getGlobalManager().hasPremium(guild);
|
||||
}
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM items_buyed WHERE guildID=? AND item=?", guild.getId(), item);
|
||||
try {
|
||||
while (rs.next()) {
|
||||
return true;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getItemCount(String item) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM items_buyed WHERE guildID=? AND item=?", guild.getId(), item);
|
||||
int count=0;
|
||||
try {
|
||||
while (rs.next()) {
|
||||
count++;
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,129 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageBuilder;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageType;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Objects;
|
||||
import java.util.Random;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 14.12.20
|
||||
********************************/
|
||||
|
||||
public class StrangerManager {
|
||||
|
||||
public boolean isRegistered(Guild guild, TextChannel channel) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
try { while (rs.next()) { return true; } } catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void register(Guild guild, TextChannel channel, String languageCode) {
|
||||
if (isRegistered(guild, channel)) return;
|
||||
MySQL.update("INSERT INTO strangers (guildID, channelID, language) VALUES (?, ?, ?)", guild.getId(), channel.getId(), languageCode);
|
||||
}
|
||||
|
||||
public void unregister(Guild guild, TextChannel channel) {
|
||||
if (!isRegistered(guild, channel)) return;
|
||||
MySQL.update("DELETE FROM strangers WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
int count = 0;
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers");
|
||||
try { while (rs.next()) {count++;} } catch (Exception err) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
public int getCount(Guild guild) {
|
||||
int count = 0;
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE guildID=?", guild.getId());
|
||||
try { while (rs.next()) {count++;} } catch (Exception err) {}
|
||||
return count;
|
||||
}
|
||||
|
||||
public void disconnect(TextChannel textChannel, String connectID) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE connectID=?", connectID);
|
||||
try {
|
||||
while (rs.next()) {
|
||||
new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("**Good bye!**")
|
||||
.setDescription("Connection closed.")
|
||||
.send(Objects.requireNonNull(Main.getInstance().getTextChannelById(rs.getString("channelID"))));
|
||||
if (!textChannel.getId().equals(rs.getString("channelID"))) {
|
||||
// auto reconnect
|
||||
new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("Reconnecting...")
|
||||
.setDescription("Waiting until an other server is connecting to yours")
|
||||
.send(Objects.requireNonNull(Main.getInstance().getTextChannelById(rs.getString("channelID"))));
|
||||
connect(
|
||||
Main.getInstance().getGuildById(rs.getString("guildID")),
|
||||
Main.getInstance().getTextChannelById(rs.getString("channelID")),
|
||||
rs.getString("language")
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
MySQL.update("UPDATE strangers SET connectID='' WHERE connectID=?", connectID);
|
||||
}
|
||||
|
||||
public String getConnectID(Guild guild, TextChannel channel) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
try {
|
||||
while (rs.next()) { return rs.getString("connectID"); }
|
||||
} catch (Exception err) {}
|
||||
return "null";
|
||||
}
|
||||
|
||||
public String getLanguage(Guild guild, TextChannel channel) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
try {
|
||||
while (rs.next()) {
|
||||
return rs.getString("language");
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
return "EN";
|
||||
}
|
||||
|
||||
public void connect(Guild guild, TextChannel channel, String languageCode) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE connectID='' AND language=? ORDER BY RAND() LIMIT 2", languageCode);
|
||||
boolean connected = false;
|
||||
String connectID = String.valueOf(new Random().nextInt(999999999));
|
||||
try {
|
||||
while (rs.next()) {
|
||||
String currentGuildID = rs.getString("guildID");
|
||||
String channelID = rs.getString("channelID");
|
||||
int id=rs.getInt("id");
|
||||
if (!connected) {
|
||||
if (!(currentGuildID.equals(guild.getId()) && channelID.equals(channel.getId()))) {
|
||||
MySQL.update("UPDATE strangers SET connectID=? WHERE id=?", connectID, String.valueOf(id));
|
||||
MySQL.update("UPDATE strangers SET connectID=? WHERE guildID=? AND channelID=?", connectID, guild.getId(), channel.getId());
|
||||
new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("Connected!")
|
||||
.setDescription("You are connected with `"+Main.getInstance().getGuildById(currentGuildID).getName()+"`")
|
||||
.send(channel);
|
||||
new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("Connected!")
|
||||
.setDescription("You are connected with `"+guild.getName()+"`")
|
||||
.send(Objects.requireNonNull(Main.getInstance().getTextChannelById(channelID)));
|
||||
connected = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
if (!connected) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setTitle("Currently all servers are connected")
|
||||
.setDescription("You are now in the queue, please wait until another server connects with yours")
|
||||
.send(channel);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,101 @@
|
||||
package de.sheepstar.globalWrapper.api;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageBuilder;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageType;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 17.12.20
|
||||
********************************/
|
||||
|
||||
public class ValidationCheck {
|
||||
|
||||
public boolean validate(GuildMessageReceivedEvent e) {
|
||||
GlobalManager gm = Main.getGlobalManager();
|
||||
if (e.getAuthor().isBot()) return false;
|
||||
|
||||
if (SheepManager.BETA_INSTANCE) {
|
||||
if (e.getMessage().getContentRaw().toLowerCase().startsWith("st!")) return false;
|
||||
} else {
|
||||
if (e.getMessage().getContentRaw().toLowerCase().startsWith("s!")) return false;
|
||||
}
|
||||
|
||||
if (e.getMessage().getContentRaw().startsWith("=")) {
|
||||
e.getMessage().addReaction(Main.getInstance().getEmotesByName("Sstar_cross", false).get(0)).queue();
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
e.getMessage().delete().queue();
|
||||
} catch (Exception err) { return false; }
|
||||
|
||||
if (!(e.getChannel().getSlowmode() > 4)) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setDescription("This channel requires a slow mode of at least 5 seconds for writing")
|
||||
.send(e.getChannel());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gm.isBanned(e.getGuild())) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setDescription("This server is banned from Global Chat. You can write an Unban request under [this Link](https://discord.gg/jbne9JTJtU).")
|
||||
.send(e.getChannel());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gm.isGuildUserBanned(e.getGuild(), e.getAuthor().getId())) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setDescription(e.getAuthor().getAsMention() + ", you are banned from the global chat on this Server. Please contact the server owner if you think, this is an error.")
|
||||
.send(e.getChannel());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (gm.isGlobalUserBanned(e.getAuthor().getId())) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setDescription(e.getAuthor().getAsMention() + ", you are banned from Global Chat. You can write an Unban request under [this Link](https://discord.gg/jbne9JTJtU).")
|
||||
.send(e.getChannel());
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check if Message Contains Ads
|
||||
String msg = e.getMessage().getContentRaw().toLowerCase();
|
||||
if ((msg.contains("http://") ||
|
||||
msg.contains("https://") ||
|
||||
msg.contains("www.")) && !e.getAuthor().getId().equals("357214370188492802")) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setTitle("Stop it!")
|
||||
.setDescription(e.getAuthor().getAsMention() + ", you are not allowed to send Links here.")
|
||||
.send(e.getChannel());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isBlocked(e.getMessage().getContentRaw()) || isServerBlocked(e.getGuild().getId(), e.getMessage().getContentRaw())) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setTitle("Stop it!")
|
||||
.setDescription(e.getAuthor().getAsMention() + ", you are not allowed to offend here.")
|
||||
.send(e.getChannel());
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isServerBlocked(String guildID, String msgContent) {
|
||||
msgContent = msgContent.replace(" ", "");
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM sword_blacklist WHERE guildID=? AND ? LIKE concat('%', word, '%');", guildID, msgContent);
|
||||
try { while (rs.next()) {return true;} } catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isBlocked(String msgContent) {
|
||||
msgContent = msgContent.replace(" ", "");
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM word_blacklist WHERE ? LIKE concat('%', word, '%');", msgContent);
|
||||
try { while (rs.next()) {return true;} } catch (Exception err) {}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,80 @@
|
||||
package de.sheepstar.globalWrapper.api.messagebuilder;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepManager;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import java.awt.*;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class MessageBuilder {
|
||||
|
||||
EmbedBuilder eb;
|
||||
|
||||
public MessageBuilder(MessageType type) {
|
||||
eb = new EmbedBuilder();
|
||||
setThumbnail("https://global.sheepstar.xyz/Sstar_Global_Rund.png");
|
||||
if (type == MessageType.GREEN_MESSAGE) {
|
||||
eb.setColor(new Color(0x2ecc71));
|
||||
} else if (type == MessageType.RED_MESSAGE) {
|
||||
eb.setColor(new Color(0xde1f1f));
|
||||
eb.setTitle("Oh no!");
|
||||
}
|
||||
}
|
||||
|
||||
public MessageBuilder addField(String name, String value, boolean inline) {
|
||||
eb.addField(name, value, inline);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder setTitle(String title) {
|
||||
eb.setTitle(title);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder setDescription(String description) {
|
||||
description = (SheepManager.BETA_INSTANCE) ? description.replace("s!", "st!") : description;
|
||||
eb.setDescription(description);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder setAuthor(String author) {
|
||||
eb.setAuthor(author);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder setThumbnail(String url) {
|
||||
eb.setThumbnail(url);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder setFooter(String footer) {
|
||||
footer = (SheepManager.BETA_INSTANCE) ? footer.replace("s!", "st!") : footer;
|
||||
eb.setFooter(footer);
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageBuilder enableTimeStamp() {
|
||||
eb.setTimestamp(OffsetDateTime.now().atZoneSameInstant(ZoneId.of("Europe/Berlin")));
|
||||
return this;
|
||||
}
|
||||
|
||||
public MessageEmbed get() {
|
||||
return eb.build();
|
||||
}
|
||||
|
||||
public MessageBuilder send(TextChannel channel) {
|
||||
channel.sendMessage(eb.build()).queue();
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,5 @@
|
||||
package de.sheepstar.globalWrapper.api.messagebuilder;
|
||||
|
||||
public enum MessageType {
|
||||
RED_MESSAGE, GREEN_MESSAGE;
|
||||
}
|
74
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/sql/MySQL.java
Executable file
74
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/api/sql/MySQL.java
Executable file
@ -0,0 +1,74 @@
|
||||
package de.sheepstar.globalWrapper.api.sql;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepManager;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
|
||||
import java.sql.*;
|
||||
|
||||
public class MySQL {
|
||||
|
||||
public static String host = Main.getSheepManager().getSQLParam(SqlParam.HOSTNAME);
|
||||
public static String database = Main.getSheepManager().getSQLParam(SqlParam.DATABASE);
|
||||
public static String username = Main.getSheepManager().getSQLParam(SqlParam.USERNAME);
|
||||
public static String password = Main.getSheepManager().getSQLParam(SqlParam.PASSWORD);
|
||||
public static Connection con;
|
||||
|
||||
public static void connect() {
|
||||
if (!isConnected()) {
|
||||
try {
|
||||
SheepManager.sendConsoleMessage("Connecting to " + host + " with user " + username + " to database " + database);
|
||||
con = DriverManager.getConnection("jdbc:mysql://" + host + "/" + database + "?useSSL=false&autoReconnect=true&useUnicode=yes&characterEncoding=UTF-8&allowPublicKeyRetrieval=true", username, password);
|
||||
SheepManager.sendConsoleMessage("MySQL Connection established");
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void disconnect() {
|
||||
if (isConnected()) {
|
||||
try {
|
||||
con.close();
|
||||
con = null;
|
||||
SheepManager.sendConsoleMessage("MySQL Connection closed");
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isConnected() {
|
||||
return (con != null);
|
||||
}
|
||||
|
||||
public static void update(String qry, String... param) {
|
||||
try {
|
||||
PreparedStatement ps = con.prepareStatement(qry);
|
||||
int number = 1;
|
||||
for (String current : param) {
|
||||
ps.setString(number, current);
|
||||
number++;
|
||||
}
|
||||
ps.executeUpdate();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static ResultSet getResult(String qry, String... param) {
|
||||
try {
|
||||
PreparedStatement ps = con.prepareStatement(qry);
|
||||
int number = 1;
|
||||
for (String current : param) {
|
||||
ps.setString(number, current);
|
||||
number++;
|
||||
}
|
||||
|
||||
return ps.executeQuery();
|
||||
} catch (SQLException throwables) {
|
||||
throwables.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package de.sheepstar.globalWrapper.api.sql;
|
||||
|
||||
public enum SqlParam {
|
||||
|
||||
HOSTNAME,
|
||||
USERNAME,
|
||||
PASSWORD,
|
||||
DATABASE;
|
||||
|
||||
}
|
@ -0,0 +1,146 @@
|
||||
package de.sheepstar.globalWrapper.api.sql;
|
||||
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class TableGenerator {
|
||||
public static void run() {
|
||||
// Generiere Server-Bantabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS log" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`senderID` VARCHAR(255) NOT NULL , " +
|
||||
"`date` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), " +
|
||||
"`message` VARCHAR(255) NOT NULL , " +
|
||||
"`language` VARCHAR(255) NOT NULL , " +
|
||||
"`roomID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Designtabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS designs" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`designID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere gekaufte-itemstabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS items_buyed" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`item` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Leveltabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS levels" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`xp` VARCHAR(255) NOT NULL , " +
|
||||
"`level` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Premiumtabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS premium" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Server-Bantabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS server_bans" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Nutzer-Bantabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS user_bans" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`clientID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Servertabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS guilds" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`channelID` VARCHAR(255) NOT NULL , " +
|
||||
"`languageCode` VARCHAR(255) NOT NULL , " +
|
||||
"`roomID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Servertabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS strangers" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`channelID` VARCHAR(255) NOT NULL , " +
|
||||
"`language` VARCHAR(255) NOT NULL DEFAULT 'EN', " +
|
||||
"`connectID` VARCHAR(255) NOT NULL DEFAULT '', " +
|
||||
"`time` TIMESTAMP(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6), " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Sprachentabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS languages" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`code` VARCHAR(255) NOT NULL , " +
|
||||
"`name` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Räumetabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS rooms" +
|
||||
" ( " +
|
||||
"`code` INT(255) NOT NULL AUTO_INCREMENT, " +
|
||||
"`name` VARCHAR(255) NOT NULL , " +
|
||||
"`categorie` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`code`))");
|
||||
|
||||
// Generiere Räumetabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS room_categories" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT, " +
|
||||
"`name` VARCHAR(255) NOT NULL , " +
|
||||
"`reaction` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Wortblacklisttabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS word_blacklist" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`word` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Serverspezifische Wortblacklisttabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS sword_blacklist" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`word` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Autoupdatetabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS server_autoupdate" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`channelID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
|
||||
// Generiere Serverspezifische Wortblacklisttabelle
|
||||
MySQL.update("CREATE TABLE IF NOT EXISTS suser_bans" +
|
||||
" ( " +
|
||||
"`id` INT(255) NOT NULL AUTO_INCREMENT , " +
|
||||
"`guildID` VARCHAR(255) NOT NULL , " +
|
||||
"`clientID` VARCHAR(255) NOT NULL , " +
|
||||
"PRIMARY KEY (`id`))");
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.LevelManager;
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.ShopManager;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class AddGlobalCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("addglobal", "newglobal", "ag");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (getStrangerManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Wait a minute...")
|
||||
.setDescription("You already added this as Connection on your server. Disconnect with `s!disconnect`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (getGlobalManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Wait a minute... ")
|
||||
.setDescription("You already have this GlobalChat on your server.\n" +
|
||||
"Please note that each server can only have one GlobalChat per room.")
|
||||
.send(e.getChannel());
|
||||
|
||||
} else {
|
||||
ShopManager sm = new ShopManager(new LevelManager(e.getGuild()));
|
||||
boolean isAllowed = false;
|
||||
if (getGlobalManager().hasPremium(e.getGuild())) isAllowed = true;
|
||||
if (getGlobalManager().getCount(e.getGuild()) < sm.getItemCount("channel")) isAllowed = true;
|
||||
if (getGlobalManager().getCount(e.getGuild()) == 0) isAllowed = true;
|
||||
|
||||
if (!isAllowed) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You need Premium or the `channel-item` to add more GlobalChats. You can buy these things under s!shop")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
getGlobalManager().register(e.getGuild(), e.getChannel());
|
||||
|
||||
sendMessage()
|
||||
.setTitle("**__Welcome to the Global Chat of Sheepstar__**")
|
||||
.setDescription("**:warning: Warning**: \n" +
|
||||
"Everything written here will be sent to all servers connected to <@772513556116930580>. " +
|
||||
"For questions and help, contact our team on the [Support Server](https://discord.gg/jbne9JTJtU) \n" +
|
||||
"Furthermore, you and your server team have the duty to make sure that the rules in the Global Chat are followed! \n" +
|
||||
"If this is not the case, your server will be immediately excluded from Global Chat.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class AddOffenseCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("wf", "wordfilter", "blacklistword", "banword", "bw");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (args.length != 1) return;
|
||||
if (Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
if (!getGlobalManager().alreadyGlobalBlacklisted(args[0])) {
|
||||
MySQL.update("INSERT INTO word_blacklist (word) VALUES (?)", args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Word added")
|
||||
.setDescription("Offense added to the general blacklist.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("Word already registered on our server.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else if (e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
if (!getGlobalManager().alreadyServerBlacklisted(e.getGuild(), args[0])) {
|
||||
MySQL.update("INSERT INTO sword_blacklist (guildID, word) VALUES (?, ?)", e.getGuild().getId(), args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Word added")
|
||||
.setDescription("Offense added to your server's list.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("Word already registered on your server's list.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("You dont have the permission to do this.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepManager;
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class AddStrangerCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("connect", "connection", "newconnection");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
String language = "EN";
|
||||
if (args.length == 1) {
|
||||
if (getGlobalManager().isValidLanguage(args[0])) {
|
||||
language = args[0].toUpperCase();
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This is not a valid language. See a list under `s!langs`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
if (getGlobalManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Uhm... Nope")
|
||||
.setDescription("You already added this channel as GlobalChat on your server. Remove with `s!removeGlobal`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
if (getStrangerManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Wait a minute...")
|
||||
.setDescription("You already added this as Connection on your server. Disconnect with `s!disconnect`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
if (getStrangerManager().getCount(e.getGuild()) > 0 && !Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Connection maximum reached")
|
||||
.setDescription("You are not allowed to create more of these channels.")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
getStrangerManager().register(e.getGuild(), e.getChannel(), language);
|
||||
|
||||
sendMessage()
|
||||
.setTitle("**__You are now in the queue, please wait until another server connects with your server.__**")
|
||||
.setDescription("**:warning: Warning**: \n" +
|
||||
"Everything written here will be sent to another server, connected to this function by <@772513556116930580>. " +
|
||||
"For questions and help, contact our team on the [Support Server](https://discord.gg/jbne9JTJtU) \n" +
|
||||
"Also you and your server team have the duty to make sure that the rules in the 'Stranger Area' are followed! \n" +
|
||||
"If this is not the case, your server will be immediately excluded from this Bot. " +
|
||||
"Also if you see other servers not following the rules you have to report them to the team.")
|
||||
.send(e.getChannel());
|
||||
|
||||
|
||||
getStrangerManager().connect(e.getGuild(), e.getChannel(), language);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 17.12.20
|
||||
********************************/
|
||||
|
||||
public class AutoUpdateCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("autodesc", "descupdate", "autodescupdate", "descupdater");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (!getGlobalManager().isDescRegistered(e.getGuild(), e.getChannel())) {
|
||||
MySQL.update("INSERT INTO server_autoupdate (guildID, channelID) VALUES (?, ?)", e.getGuild().getId(), e.getChannel().getId());
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Autodesc")
|
||||
.setDescription("You turned on auto description update. To turn off, use the same command again.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
MySQL.update("DELETE FROM server_autoupdate WHERE guildID=? AND channelID=?", e.getGuild().getId(), e.getChannel().getId());
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Autodesc")
|
||||
.setDescription("You turned off auto description update. To turn on, use the same command again.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class BanServerCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("banserver", "bs", "serverban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.BOT_OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (args.length != 1) return;
|
||||
String serverName;
|
||||
try {
|
||||
serverName = Main.getInstance().getGuildById(args[0]).getName();
|
||||
if (!getGlobalManager().isBanned(Main.getInstance().getGuildById(args[0]))) {
|
||||
getGlobalManager().banServer(Main.getInstance().getGuildById(args[0]));
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Ban")
|
||||
.setDescription("The Server `" + serverName + "` got banned.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("Whoa! This Server is already banned. Unban with `s!unbanserver <guildID>`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} catch (Exception err) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Sheepstar Error")
|
||||
.setDescription("This Server does not exist")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,81 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class BanUserCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("banuser", "bu", "userban");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (args.length != 1) return;
|
||||
args[0] = replaceUserMention(args[0]);
|
||||
int logic=0;
|
||||
if (e.getMember().getRoles().contains(Main.getSheepManager().supporterRole) || Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
logic=1;
|
||||
} else if (e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
logic=2;
|
||||
}
|
||||
|
||||
try {
|
||||
int finalLogic = logic;
|
||||
Main.getInstance().retrieveUserById(args[0]).queue(user -> {
|
||||
String userName = user.getAsTag();
|
||||
|
||||
if (finalLogic == 1) {
|
||||
if (!getGlobalManager().isGlobalUserBanned(args[0])) {
|
||||
getGlobalManager().banUserGlobal(args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Ban")
|
||||
.setDescription("The User `" + userName + "` got banned.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This User is already banned. Unban with `s!unbanuser <clientID/mention>`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else if (finalLogic == 2) {
|
||||
if (!getGlobalManager().isGuildUserBanned(e.getGuild(), args[0])) {
|
||||
getGlobalManager().banUserGuild(e.getGuild(), args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Ban")
|
||||
.setDescription("The User `" + userName + "` got banned from the serverchat.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This User is already banned. Unban with `s!unbanuser <clientID/mention>`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("`You dont have the permission to do this.`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
});
|
||||
} catch (Exception err) {
|
||||
sendErrorMessage()
|
||||
.setDescription("This User does not exist")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,67 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.*;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 19.12.20
|
||||
********************************/
|
||||
|
||||
public class BuyCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("buy", "buyitem", "buyit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
LevelManager lm = new LevelManager(e.getGuild());
|
||||
ShopManager sm = new ShopManager(lm);
|
||||
if (args.length != 1) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Please provide a product. Look at the list under s!shop")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (!ShopItems.shopItems.containsKey(args[0])) {
|
||||
sendErrorMessage()
|
||||
.setDescription("This product does not exist. Look at the list under s!shop")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
ShopItem item = ShopItems.shopItems.get(args[0]);
|
||||
|
||||
int price = getGlobalManager().hasPremium(e.getGuild()) ? Integer.parseInt(item.getPremiumPrice()) : Integer.parseInt(item.getPrice());
|
||||
|
||||
if (!item.isMultiple_buyable() && sm.hasItem(args[0].toLowerCase())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You already bought this Item.")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
if (Integer.parseInt(lm.getLevel()) >= price) {
|
||||
sm.buyItem(String.valueOf(price), args[0].toLowerCase(), !item.isMultiple_buyable());
|
||||
sendMessage()
|
||||
.setTitle("Item bought")
|
||||
.setDescription("The item " + args[0].toLowerCase() + " was bought successfully.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("You dont habe enough levels to buy this item")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,54 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class ChangeLanguageCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("lang", "lan", "language", "setlanguage", "changelanguage", "sl", "cl", "setlang");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (!getGlobalManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Wait! At first you should add this channel! `s!addGlobal`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Please choose a language: s!setLanguage <code>\nYou can find a list under s!languages")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (!getGlobalManager().isValidLanguage(args[0].toUpperCase())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("This language does not exist \nYou can find a list under s!languages")
|
||||
.send(e.getChannel());
|
||||
|
||||
} else {
|
||||
getGlobalManager().changeLanguageCode(e.getGuild(), e.getChannel(), args[0].toLowerCase());
|
||||
sendMessage()
|
||||
.setTitle("Channel language updated")
|
||||
.setDescription("You changed this language to " + args[0].toUpperCase() + "!")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,64 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class ChangeRoomCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("changeroom", "setroom", "sr", "room");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (!getGlobalManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Wait! At first you should add this channel! `s!addGlobal`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (args.length != 1) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Please choose a room: s!room <code> \nYou can find a list under s!rooms")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (!getGlobalManager().isValidRoom(args[0].toLowerCase())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("This room does not exist.. \nYou can find a list under s!rooms")
|
||||
.send(e.getChannel());
|
||||
|
||||
} else {
|
||||
if (args[0].contains("p") && !getGlobalManager().hasPremium(e.getGuild())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You must have Premium to enter this Channel")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
getGlobalManager().changeRoomID(e.getGuild(), e.getChannel(), args[0].toLowerCase());
|
||||
|
||||
sendMessage()
|
||||
.setTitle("Channel room updated")
|
||||
.setDescription("You changed this room to " + args[0].toLowerCase() + "!")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class ClearGlobalCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("clearglobal", "clearlist", "clear", "listclear");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
MySQL.update("DELETE FROM guilds WHERE guildID=?", e.getGuild().getId());
|
||||
sendMessage()
|
||||
.setTitle("Global-Channels got cleared")
|
||||
.setDescription("All Global Channels were deleted.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,62 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.*;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 17.12.20
|
||||
********************************/
|
||||
|
||||
public class DesignCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("design", "changedesign", "cdesign", "setdesign");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
ShopManager sm = new ShopManager(new LevelManager(e.getGuild()));
|
||||
if (args.length != 1) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Usage: s!design <number/reset>")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (args[0].equals("reset")) args[0] = "1";
|
||||
if (args[0].equals("5") && !Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You are not allowed to use this Design. Please choose another")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (getGlobalManager().isValidDesign(args[0])) {
|
||||
if (sm.hasItem("design_"+args[0].toLowerCase()) || args[0].equals("1") || args[0].equals("5")) {
|
||||
getGlobalManager().updateDesign(e.getGuild(), args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar design")
|
||||
.setDescription("Your design has been updated to " + args[0])
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("You dont own this. Please buy this from s!shop")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This is not a valid design. Please choose one from s!designs")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class ExampleCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("example", "test", "beispiel");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
sendMessage()
|
||||
.setTitle("example")
|
||||
.setDescription("example sheepstar message")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class HelpCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("help", "h", "hilfe");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
sendMessage()
|
||||
.setTitle("Help menu")
|
||||
.addField("Global Chat Help", "`s!addGlobal` \n`s!removeGlobal`\n\n[All commands](https://docs.sheepstar.xyz/global)", true)
|
||||
.addField("EMOJI Server", "If you are " +
|
||||
Main.getInstance().getEmotesByName("Sstar_nitro", false).get(0).getAsMention() + "-User, " +
|
||||
"join our [EMOJI Server](https://discord.gg/mmERp6a5mA) to get access to emojis you normally can't use.", true)
|
||||
.addField("Unban request", "Banned from Global Chat? \n Make an Unban application" +
|
||||
" on the [Support Server](https://discord.gg/jbne9JTJtU)!", true)
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.LevelManager;
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class LeaderboardCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("top", "leaderboard", "toplist");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
LevelManager lm = new LevelManager(e.getGuild());
|
||||
String content = "";
|
||||
for (Guild current : lm.getTopList(10)) {
|
||||
content += "`"+current.getName()+" (Level "+ lm.getLevel(current) + ")`\n";
|
||||
}
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar leaderboard")
|
||||
.setDescription(content)
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.LevelManager;
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class LevelCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("xp", "level", "levels");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
LevelManager lm = new LevelManager(e.getGuild());
|
||||
sendMessage()
|
||||
.setTitle("Global Chat Level")
|
||||
.setDescription(e.getAuthor().getAsMention() + ", this server has:\n" +
|
||||
"`"+lm.getXP()+" XP / "+lm.getNeededXP()+" XP`\n" +
|
||||
"`"+lm.getLevel()+"` Level")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepManager;
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 14.12.20
|
||||
********************************/
|
||||
|
||||
public class PingCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("ping", "botping", "pong", "internet");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar's ping")
|
||||
.setDescription("Pong! " + e.getJDA().getGatewayPing() + " ms")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,54 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class RemoveGlobalCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("removeglobal", "deleteglobal", "rg", "dg");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (getStrangerManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Wait a minute...")
|
||||
.setDescription("You added this as an Connection. Disconnect with `s!disconnect`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (!getGlobalManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setDescription("You do not have a GlobalChat on your server yet.\n" +
|
||||
"Add one with `s!addGlobal` in a fresh channel.")
|
||||
.send(e.getChannel());
|
||||
|
||||
} else {
|
||||
getGlobalManager().unregister(e.getGuild(), e.getChannel());
|
||||
sendMessage()
|
||||
.setTitle("**Good bye!**")
|
||||
.setDescription("The GlobalChat was removed. You can add it anytime" +
|
||||
" with `s!addGlobal`.")
|
||||
.send(e.getChannel());
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class RemoveOffenseCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("removewf", "blacklistremoveword", "removebl", "wfr", "brw", "removebadword", "rbw");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (args.length != 1) return;
|
||||
if (Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
if (getGlobalManager().alreadyGlobalBlacklisted(args[0])) {
|
||||
MySQL.update("DELETE FROM word_blacklist WHERE word=?", args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Word removed")
|
||||
.setDescription("Offense removed from the general blacklist.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("Word not registered yet.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else if (e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
if (getGlobalManager().alreadyServerBlacklisted(e.getGuild(), args[0])) {
|
||||
MySQL.update("DELETE FROM sword_blacklist WHERE guildID=? AND word=?", e.getGuild().getId(), args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Word removed")
|
||||
.setDescription("Offense removed from your server's list.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("Word not registered yet.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("You don't have the permission to do this.")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class RemoveStrangerCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("disconnect", "disconnection", "removeconnect");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (!getStrangerManager().isRegistered(e.getGuild(), e.getChannel())) {
|
||||
sendErrorMessage()
|
||||
.setTitle("Wait a minute...")
|
||||
.setDescription("You do not have a Connection on your server yet.\n" +
|
||||
"Add one with `s!connect [language-code]` in a fresh channel.")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
getStrangerManager().disconnect(e.getChannel(), getStrangerManager().getConnectID(e.getGuild(), e.getChannel()));
|
||||
getStrangerManager().unregister(e.getGuild(), e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Leon Fleß
|
||||
* Created 13.12.20
|
||||
********************************/
|
||||
|
||||
public class RulesCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("rules", "regeln", "rule", "r");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
sendMessage()
|
||||
.setTitle("Rules")
|
||||
.setDescription("```§1 - No NSFW\n" +
|
||||
"§2 - No Server invites \n" +
|
||||
"§3 - No ADs\n" +
|
||||
"§4 - No LINKs\n" +
|
||||
"§5 - No SPAM\n" +
|
||||
"§6 - No Bug abusing\n" +
|
||||
"§7 - No abusive language\n" +
|
||||
"§8 - Use the language that you have set```")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,70 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class SetPremiumCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("setPreimum", "makePremium", "premium");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.BOT_OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
Guild guild = e.getGuild();
|
||||
boolean changed = false;
|
||||
if (args.length == 1) {
|
||||
try {
|
||||
guild = Main.getInstance().getGuildById(args[0]);
|
||||
changed = true;
|
||||
} catch (Exception err) {}
|
||||
}
|
||||
if (getGlobalManager().hasPremium(guild)) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Nice! This Server already has Premium.")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
getGlobalManager().setPremium(guild);
|
||||
if (!changed) {
|
||||
e.getGuild().retrieveOwner().queue(owner -> {
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Premium")
|
||||
.setDescription(owner.getAsMention() + ", this Server now has Premium. " +
|
||||
Main.getInstance().getEmotesByName("Sstar_nitro", false).get(0).getAsMention())
|
||||
.send(e.getChannel());
|
||||
});
|
||||
} else {
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Premium")
|
||||
.setDescription("You gave this Server Sheepstar Premium")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
try {
|
||||
Guild finalGuild = guild;
|
||||
guild.retrieveOwner().queue(owner -> {
|
||||
owner.getUser().openPrivateChannel().queue(m -> {
|
||||
m.sendMessage("**You are a Legend!** \nYour Server `"+ finalGuild.getName() +"` has now Sheepstar Global Premium! \nCheck! We lit! " +
|
||||
Main.getInstance().getEmotesByName("MathiasD", false).get(0).getAsMention()).queue();
|
||||
});
|
||||
});
|
||||
} catch (Exception err) {}
|
||||
}
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.*;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 18.12.20
|
||||
********************************/
|
||||
|
||||
public class ShopCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("shop", "shoplist", "buylist");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
Emote owned = Main.getInstance().getEmotesByName("Sstar_tick", false).get(0);
|
||||
LevelManager lm = new LevelManager(e.getGuild());
|
||||
ShopManager sm = new ShopManager(lm);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
ShopItems.shopItems.forEach((name, item) -> {
|
||||
String priceString = "";
|
||||
if (getGlobalManager().hasPremium(e.getGuild())) {
|
||||
priceString =
|
||||
(item.getPrice().equals(item.getPremiumPrice()))
|
||||
? "**"+item.getPrice() + " lvl**"
|
||||
: "~~" + item.getPrice() + "~~ **" + item.getPremiumPrice() + " lvl**";
|
||||
} else {
|
||||
priceString = "**" + item.getPrice() + "**";
|
||||
}
|
||||
|
||||
String ownLine = "";
|
||||
if (item.isMultiple_buyable()) {
|
||||
if (name.equals("channel")) {
|
||||
ownLine = "(" + String.valueOf(getGlobalManager().getCount(e.getGuild())) + "/"+ String.valueOf(sm.getItemCount(name)) + ")";
|
||||
} else if (name.equals("booster")) {
|
||||
ownLine = "(" + String.valueOf(sm.getItemCount(name)+1) + "x)";
|
||||
} else {
|
||||
ownLine = "(" + String.valueOf(sm.getItemCount(name)) + ")";
|
||||
}
|
||||
} else if (sm.hasItem(name)) {
|
||||
ownLine = owned.getAsMention();
|
||||
} else {
|
||||
ownLine = "";
|
||||
}
|
||||
sb
|
||||
.append("`")
|
||||
.append(name)
|
||||
.append("` (")
|
||||
.append(item.getDescription())
|
||||
.append(") ")
|
||||
.append(priceString)
|
||||
.append(" "+ownLine)
|
||||
.append("\n");
|
||||
});
|
||||
sendMessage()
|
||||
.setTitle("Global Shop :shopping_cart:")
|
||||
.setDescription(sb.toString())
|
||||
.setFooter("Buy items with s!buy <name>")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 17.12.20
|
||||
********************************/
|
||||
|
||||
public class ShowDesignsCommand extends SheepstarGuildCommand {
|
||||
|
||||
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("showdesigns", "designs", "listdesigns");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar designs")
|
||||
.setDescription("`1 - Default Embed Message`\n" +
|
||||
"`2 - Embed Message without 'gap'`\n" +
|
||||
"`3 - Embed Message without 'Links & Help'`\n" +
|
||||
"`4 - Simple Message`\n" +
|
||||
"`5 - Admin Embed with IDs`")
|
||||
.setFooter("Change with s!design <id>")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,68 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class ShowLanguagesCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("languages", "langs", "ls");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
ResultSet rsb = MySQL.getResult("SELECT * FROM guilds WHERE guildID=? AND channelID=?", e.getGuild().getId(), e.getChannel().getId());
|
||||
String currentRoom = "";
|
||||
try {
|
||||
while (rsb.next()) {
|
||||
currentRoom = rsb.getString("languageCode");
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM languages");
|
||||
String msgContent = "";
|
||||
try {
|
||||
int count = 0;
|
||||
while (rs.next()) {
|
||||
if (count != 0) msgContent += "\n";
|
||||
ResultSet rst = MySQL.getResult("SELECT * FROM guilds WHERE languageCode=?", rs.getString("code"));
|
||||
int roomCount = 0;
|
||||
try {
|
||||
while (rst.next()) {
|
||||
roomCount++;
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
count++;
|
||||
msgContent += "`[code] - [name] | [mem] Servers`"
|
||||
.replace("[code]", rs.getString("code"))
|
||||
.replace("[name]", rs.getString("name"))
|
||||
.replace("[mem]", String.valueOf(roomCount))
|
||||
+ ((rs.getString("code").toLowerCase().equals(currentRoom.toLowerCase())) ? " " + Main.getInstance().getEmotesByName("Sstar_larrow", true)
|
||||
.get(0).getAsMention(): "");
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar languages")
|
||||
.setDescription(msgContent)
|
||||
.setThumbnail(null)
|
||||
.setFooter("Change with s!lang <code>")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class ShowRoomsCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("rooms", "rs", "showrooms", "listrooms");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM room_categories");
|
||||
String msgContent = "";
|
||||
|
||||
try { int count = 0;
|
||||
while (rs.next()) {
|
||||
if (count != 0) msgContent += "\n"; count++;
|
||||
msgContent += "`"+rs.getString("name")+"` "+Main.getInstance().getEmotesByName(rs.getString("reaction"), false).get(0).getAsMention();
|
||||
} } catch (Exception err) {}
|
||||
|
||||
MessageEmbed msg = sendMessage()
|
||||
.setTitle("Sheepstar rooms")
|
||||
.setDescription(msgContent)
|
||||
.setThumbnail(null)
|
||||
.setFooter("Change with s!room <code>")
|
||||
.get();
|
||||
e.getChannel().sendMessage(msg).queue(message -> {
|
||||
message.addReaction("⬅️").queue();
|
||||
ResultSet rst = MySQL.getResult("SELECT * FROM room_categories");
|
||||
try {
|
||||
while (rst.next()) {
|
||||
message.addReaction(Main.getInstance().getEmotesByName(rst.getString("reaction"), false).get(0)).queue();
|
||||
}
|
||||
} catch (Exception err) { }
|
||||
});
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 19.12.20
|
||||
********************************/
|
||||
|
||||
public class SkipConnectionCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("skip", "skipc");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.ADMINISTRATOR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
String currentLanguage = getStrangerManager().getLanguage(e.getGuild(), e.getChannel());
|
||||
sendMessage()
|
||||
.setTitle("Connection skipped")
|
||||
.setDescription("You will be connected asap.")
|
||||
.send(e.getChannel());
|
||||
getStrangerManager().disconnect(e.getChannel(), getStrangerManager().getConnectID(e.getGuild(), e.getChannel()));
|
||||
getStrangerManager().connect(e.getGuild(), e.getChannel(), currentLanguage);
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 13.12.20
|
||||
********************************/
|
||||
|
||||
public class StatsCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("stats");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.BOT_OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class UnbanServerCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("unbanserver", "unbs", "ubs", "unbans");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.BOT_OWNER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (args.length != 1) return;
|
||||
String serverName;
|
||||
try {
|
||||
serverName = Main.getInstance().getGuildById(args[0]).getName();
|
||||
if (getGlobalManager().isBanned(Main.getInstance().getGuildById(args[0]))) {
|
||||
getGlobalManager().unbanServer(Main.getInstance().getGuildById(args[0]));
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Unban")
|
||||
.setDescription("The Server `" + serverName + "` got unbanned.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This Server is not banned. Ban with `s!banserver <guildID>`")
|
||||
.send(e.getChannel());
|
||||
|
||||
}
|
||||
} catch (Exception err) {
|
||||
sendErrorMessage()
|
||||
.setDescription("This server does not exist")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class UnbanUserCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("unbanuser", "unbu", "ubu", "unbanu");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.UNKNOWN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (args.length != 1) return;
|
||||
args[0] = replaceUserMention(args[0]);
|
||||
int logic=0;
|
||||
if (e.getMember().getRoles().contains(Main.getSheepManager().supporterRole) || Main.getSheepManager().botOwners.contains(e.getAuthor().getId())) {
|
||||
logic=1;
|
||||
} else if (e.getMember().hasPermission(Permission.ADMINISTRATOR)) {
|
||||
logic=2;
|
||||
}
|
||||
try {
|
||||
int finalLogic = logic;
|
||||
Main.getInstance().retrieveUserById(args[0]).queue(user -> {
|
||||
String userName = user.getAsTag();
|
||||
if (finalLogic == 1) {
|
||||
if (getGlobalManager().isGlobalUserBanned(args[0])) {
|
||||
getGlobalManager().unbanUserGlobal(args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Ban")
|
||||
.setDescription("The User `" + userName + "` got unbanned.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This User is not banned. Ban with `s!banuser <clientID/mention>`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else if (finalLogic == 2) {
|
||||
if (getGlobalManager().isGuildUserBanned(e.getGuild(), args[0])) {
|
||||
getGlobalManager().unbanUserGuild(e.getGuild(), args[0]);
|
||||
sendMessage()
|
||||
.setTitle("Sheepstar Ban")
|
||||
.setDescription("The User `" + userName + "` got unbanned from the serverchat.")
|
||||
.send(e.getChannel());
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("This User is not banned. Ban with `s!banuser <clientID/mention>`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
} else {
|
||||
sendErrorMessage()
|
||||
.setDescription("`You dont have the permission to do this.`")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
});
|
||||
} catch (Exception err) {
|
||||
sendErrorMessage()
|
||||
.setDescription("This user does not exist")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package de.sheepstar.globalWrapper.commands;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepPermission;
|
||||
import de.sheepstar.globalWrapper.api.SheepstarGuildCommand;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.Permission;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 13.12.20
|
||||
********************************/
|
||||
|
||||
public class ViewLogCommand extends SheepstarGuildCommand {
|
||||
@Override
|
||||
public List<String> getAlias() {
|
||||
return Arrays.asList("log", "viewlog", "vl", "l");
|
||||
}
|
||||
|
||||
@Override
|
||||
public SheepPermission getPermission() {
|
||||
return SheepPermission.SUPPORTER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
|
||||
if (!(args.length == 3 ||args.length == 2)) {
|
||||
sendErrorMessage()
|
||||
.setDescription("Use s!log <user/guild/search> <guildID/userID/word> <limit>")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
if (args[0].toLowerCase().equals("user") && args.length == 3) {
|
||||
args[1] = replaceUserMention(args[1]);
|
||||
String content = "";
|
||||
int count = 0;
|
||||
for (String current : Main.getLogManager().getUserMessages(args[1], Integer.parseInt(args[2]))) {
|
||||
if (count != 0) content += "\n";
|
||||
count++;
|
||||
content += "`"+current+"`";
|
||||
}
|
||||
String finalContent = content;
|
||||
Main.getInstance().retrieveUserById(args[1]).queue(user -> {
|
||||
try {
|
||||
sendMessage()
|
||||
.setTitle("Message user-log ["+user.getAsTag()+"]")
|
||||
.setDescription(finalContent)
|
||||
.send(e.getChannel());
|
||||
} catch (Exception err) {
|
||||
sendErrorMessage()
|
||||
.setDescription("User does not exist!")
|
||||
.send(e.getChannel());
|
||||
}
|
||||
|
||||
});
|
||||
} else if (args[0].toLowerCase().equals("guild") && args.length == 3) {
|
||||
String content = "";
|
||||
int count = 0;
|
||||
for (String current : Main.getLogManager().getServerMessages(args[1], Integer.parseInt(args[2]))) {
|
||||
if (count != 0) content += "\n";
|
||||
count++;
|
||||
content += "`"+current+"`";
|
||||
}
|
||||
sendMessage()
|
||||
.setTitle("Message server-log")
|
||||
.setDescription(content)
|
||||
.send(e.getChannel());
|
||||
} else if (args[0].toLowerCase().equals("search")) {
|
||||
String content = "";
|
||||
String limitLine = "";
|
||||
if (args.length != 3) {
|
||||
limitLine = "";
|
||||
} else {
|
||||
limitLine = " LIMIT " + args[2];
|
||||
}
|
||||
ResultSet rs = MySQL.getResult("SELECT * from log WHERE message REGEXP ? ORDER BY id DESC" + limitLine, args[1].replace("_", " "));
|
||||
|
||||
int count = 0;
|
||||
try {
|
||||
while (rs.next()) {
|
||||
if (count != 0) content += "\n\n";
|
||||
count++;
|
||||
content += "`"+rs.getString("message")+"`\n";
|
||||
content += "*Gesendet von " + rs.getString("senderID") + " vom Server " + rs.getString("guildID") + "*";
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
if (content.length() > 2000) {
|
||||
content = content.substring(0, Math.min(content.length(), 2000)) + "`...`";
|
||||
}
|
||||
content = "`" +count + " Results`\n\n" + content + "\n\n`" +count + " Results`";
|
||||
sendMessage()
|
||||
.setTitle("Message search")
|
||||
.setDescription(content)
|
||||
.send(e.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
115
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/core/Main.java
Executable file
115
SheepstarGlobal/src/main/java/de/sheepstar/globalWrapper/core/Main.java
Executable file
@ -0,0 +1,115 @@
|
||||
package de.sheepstar.globalWrapper.core;
|
||||
|
||||
|
||||
import de.sheepstar.globalWrapper.api.*;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.api.sql.TableGenerator;
|
||||
import de.sheepstar.globalWrapper.commands.*;
|
||||
import de.sheepstar.globalWrapper.instance.AutoUpdater;
|
||||
import de.sheepstar.globalWrapper.instance.DescUpdater;
|
||||
import de.sheepstar.globalWrapper.listeners.RoomReactionListener;
|
||||
import de.sheepstar.globalWrapper.listeners.GlobalListener;
|
||||
import de.sheepstar.globalWrapper.listeners.StrangerListener;
|
||||
import net.dv8tion.jda.api.JDA;
|
||||
import net.dv8tion.jda.api.JDABuilder;
|
||||
import net.dv8tion.jda.api.requests.GatewayIntent;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class Main {
|
||||
|
||||
private static JDA jda;
|
||||
private static SheepManager sheepManager;
|
||||
private static GlobalManager globalManager;
|
||||
private static LogManager logManager;
|
||||
private static StrangerManager strangerManager;
|
||||
public static void main(String[] args) throws Exception {
|
||||
sheepManager = new SheepManager().register();
|
||||
if (SheepManager.BETA_INSTANCE) {
|
||||
SheepManager.sendConsoleMessage("Warnung! Beta-Instanz wird verwendet; Der Bot startet in 3 Sekunden. :)");
|
||||
Thread.sleep(3000);
|
||||
}
|
||||
SheepManager.sendConsoleMessage("Bot startet nun...");
|
||||
MySQL.connect();
|
||||
TableGenerator.run();
|
||||
globalManager = new GlobalManager();
|
||||
strangerManager = new StrangerManager();
|
||||
logManager = new LogManager();
|
||||
jda = JDABuilder.createDefault(sheepManager.getToken())
|
||||
.enableIntents(GatewayIntent.GUILD_MEMBERS)
|
||||
.build();
|
||||
ShopItems.register();
|
||||
|
||||
jda.addEventListener(new ExampleCommand());
|
||||
jda.addEventListener(new HelpCommand());
|
||||
jda.addEventListener(new RulesCommand());
|
||||
|
||||
jda.addEventListener(new AddGlobalCommand());
|
||||
jda.addEventListener(new RemoveGlobalCommand());
|
||||
jda.addEventListener(new ClearGlobalCommand());
|
||||
|
||||
jda.addEventListener(new GlobalListener());
|
||||
|
||||
jda.addEventListener(new ShowLanguagesCommand());
|
||||
jda.addEventListener(new ChangeLanguageCommand());
|
||||
|
||||
jda.addEventListener(new ShowRoomsCommand());
|
||||
jda.addEventListener(new ChangeRoomCommand());
|
||||
|
||||
jda.addEventListener(new AddOffenseCommand());
|
||||
jda.addEventListener(new RemoveOffenseCommand());
|
||||
|
||||
jda.addEventListener(new SetPremiumCommand());
|
||||
|
||||
jda.addEventListener(new BanServerCommand());
|
||||
jda.addEventListener(new UnbanServerCommand());
|
||||
jda.addEventListener(new BanUserCommand());
|
||||
jda.addEventListener(new UnbanUserCommand());
|
||||
jda.addEventListener(new ViewLogCommand());
|
||||
jda.addEventListener(new PingCommand());
|
||||
jda.addEventListener(new RoomReactionListener());
|
||||
jda.addEventListener(new AutoUpdateCommand());
|
||||
jda.addEventListener(new AddStrangerCommand());
|
||||
jda.addEventListener(new RemoveStrangerCommand());
|
||||
jda.addEventListener(new SkipConnectionCommand());
|
||||
jda.addEventListener(new StrangerListener());
|
||||
jda.addEventListener(new ShowDesignsCommand());
|
||||
jda.addEventListener(new DesignCommand());
|
||||
jda.addEventListener(new LevelCommand());
|
||||
jda.addEventListener(new LeaderboardCommand());
|
||||
jda.addEventListener(new ShopCommand());
|
||||
jda.addEventListener(new BuyCommand());
|
||||
jda.awaitReady();
|
||||
sheepManager.supporterRole = Main.getInstance().getGuildById("772528034912927756").getRoleById("772528035387539476");
|
||||
Thread autoUpdater = new Thread(new AutoUpdater());
|
||||
autoUpdater.start();
|
||||
Thread descUpdater = new Thread(new DescUpdater());
|
||||
descUpdater.start();
|
||||
SheepManager.sendConsoleMessage("Bot gestartet");
|
||||
}
|
||||
|
||||
public static JDA getInstance() {
|
||||
return jda;
|
||||
}
|
||||
|
||||
public static SheepManager getSheepManager() {
|
||||
return sheepManager;
|
||||
}
|
||||
|
||||
public static GlobalManager getGlobalManager() {
|
||||
return globalManager;
|
||||
}
|
||||
|
||||
public static LogManager getLogManager() {
|
||||
return logManager;
|
||||
}
|
||||
|
||||
public static StrangerManager getStrangerManager() {
|
||||
return strangerManager;
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package de.sheepstar.globalWrapper.instance;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.SheepManager;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Activity;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 11.12.20
|
||||
********************************/
|
||||
|
||||
public class AutoUpdater extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
if (SheepManager.BETA_INSTANCE) {
|
||||
Main.getInstance().getPresence().setActivity(Activity.watching("Beta-Instanz! Möglicherweise instabil."));
|
||||
try {Thread.sleep(5000);} catch (Exception err) {}
|
||||
} else {
|
||||
Main.getInstance().getPresence().setActivity(Activity.watching("discord.gg/jbne9JTJtU"));
|
||||
try {Thread.sleep(5000);} catch (Exception err) {}
|
||||
Main.getInstance().getPresence().setActivity(Activity.listening("s!help | sheepstar.xyz"));
|
||||
try {Thread.sleep(20000);} catch (Exception err) {}
|
||||
run();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package de.sheepstar.globalWrapper.instance;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.GlobalManager;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 17.12.20
|
||||
********************************/
|
||||
|
||||
public class DescUpdater extends Thread {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try { Thread.sleep(600000); } catch (Exception err) {}
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM server_autoupdate");
|
||||
GlobalManager gm = Main.getGlobalManager();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
try {
|
||||
Guild guild = Main.getInstance().getGuildById(rs.getString("guildID"));
|
||||
TextChannel channel = guild.getTextChannelById(rs.getString("channelID"));
|
||||
ResultSet rsb = MySQL.getResult("SELECT * FROM guilds WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
String currentRoom = "";
|
||||
String currentLanguage = "";
|
||||
try {
|
||||
while (rsb.next()) {
|
||||
currentRoom = rsb.getString("roomID");
|
||||
currentLanguage = rsb.getString("languageCode");
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
if (gm.isRegistered(guild, channel)) {
|
||||
// Run Channel Update Logic
|
||||
DateTimeFormatter dtf = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
|
||||
LocalDateTime ldt = LocalDateTime.now();
|
||||
channel
|
||||
.getManager()
|
||||
.setTopic("Globalchat-Channel » " +
|
||||
gm.getCount(currentLanguage, currentRoom) +
|
||||
" servers are registered in this room." +
|
||||
" (Latest update: "+ ldt.format(dtf) +")"
|
||||
)
|
||||
.queue();
|
||||
} else {
|
||||
MySQL.update("DELETE FROM server_autoupdate WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
}
|
||||
} catch (Exception ignore) {}
|
||||
run();
|
||||
}
|
||||
}
|
@ -0,0 +1,131 @@
|
||||
package de.sheepstar.globalWrapper.listeners;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.*;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageBuilder;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageType;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
|
||||
import java.awt.*;
|
||||
import java.sql.ResultSet;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Random;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 12.12.20
|
||||
********************************/
|
||||
|
||||
public class GlobalListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onGuildMessageReceived(GuildMessageReceivedEvent e) {
|
||||
GlobalManager gm = Main.getGlobalManager();
|
||||
LevelManager lm = new LevelManager(e.getGuild());
|
||||
ShopManager sm = new ShopManager(lm);
|
||||
|
||||
// Check if GlobalChat is registered
|
||||
if (!gm.isRegistered(e.getGuild(), e.getChannel())) return;
|
||||
|
||||
// Run validation checks
|
||||
if (!new ValidationCheck().validate(e)) return;
|
||||
|
||||
// Preset LanguageCode & RoomID
|
||||
ResultSet rs1 = MySQL.getResult("SELECT * FROM guilds WHERE guildID=? AND channelID=?", e.getGuild().getId(), e.getChannel().getId());
|
||||
String langcode = "";
|
||||
String roomID = "";
|
||||
try { while (rs1.next()) { langcode = rs1.getString("languageCode");roomID = rs1.getString("roomID"); } } catch (Exception err) {}
|
||||
|
||||
// NSFW Check
|
||||
boolean mustNSFW = roomID.contains("n");
|
||||
if (!e.getChannel().isNSFW() && mustNSFW) {
|
||||
new MessageBuilder(MessageType.RED_MESSAGE)
|
||||
.setDescription("You joined an NSFW Room. Please set this Channel to NSFW or change the Room with `s!rooms`")
|
||||
.send(e.getChannel());
|
||||
return;
|
||||
}
|
||||
|
||||
// Send Message To all Servers
|
||||
sendGlobal(e, langcode, roomID);
|
||||
|
||||
// Increase Level
|
||||
|
||||
int memberCount = e.getGuild().getMemberCount();
|
||||
int extraMultiplier = 1;
|
||||
if (memberCount <= 2500) extraMultiplier = 2;
|
||||
if (memberCount <= 1000) extraMultiplier = 3;
|
||||
if (memberCount <= 10) extraMultiplier = 4;
|
||||
|
||||
int possibility = new Random().nextInt(99);
|
||||
if (possibility == 50) {
|
||||
lm.increase(e.getChannel(), "15");
|
||||
} else {
|
||||
int multiplier = sm.getItemCount("booster");
|
||||
multiplier += 1;
|
||||
lm.increase(e.getChannel(), String.valueOf(new Random().nextInt(5*multiplier*extraMultiplier)));
|
||||
}
|
||||
|
||||
// Insert it to Log
|
||||
gm.insertLog(e.getGuild().getId(), e.getAuthor().getId(), e.getMessage().getContentRaw(), langcode, roomID);
|
||||
}
|
||||
|
||||
|
||||
public void sendGlobal(GuildMessageReceivedEvent e, String langcode, String roomID) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM guilds WHERE languageCode=? AND roomID=?", langcode, roomID);
|
||||
GlobalManager gm = Main.getGlobalManager();
|
||||
try {
|
||||
while (rs.next()) {
|
||||
try {
|
||||
// Preset Server Variables
|
||||
Guild currentGuild = Main.getInstance().getGuildById(rs.getString("guildID"));
|
||||
TextChannel currentChannel = currentGuild.getTextChannelById(rs.getString("channelID"));
|
||||
boolean letItWork = true;
|
||||
if (!currentChannel.isNSFW() && roomID.startsWith("n")) letItWork = false;
|
||||
if (letItWork) {
|
||||
if (gm.getDesign(currentGuild).equals("4")) {
|
||||
currentChannel.sendMessage(
|
||||
"[" + e.getAuthor().getAsTag() + "] " + e.getMessage().getContentRaw()
|
||||
).queue();
|
||||
} else {
|
||||
EmbedBuilder eb = new EmbedBuilder();
|
||||
String iconUrl = e.getGuild().getIconUrl();
|
||||
if (iconUrl == null) iconUrl = "https://i.giphy.com/media/38pPhtupwYMerEQeBT/source.gif";
|
||||
eb.setThumbnail(iconUrl);
|
||||
eb.setTimestamp(OffsetDateTime.now().atZoneSameInstant(ZoneId.of("Europe/Berlin")));
|
||||
if (roomID.startsWith("n")) {
|
||||
eb.addField(" ", "`NSFW` :underage:", false);
|
||||
} else {
|
||||
if (!(gm.getDesign(currentGuild).equals("2") || gm.getDesign(currentGuild).equals("3"))) {
|
||||
eb.addField(" ", " ", false);
|
||||
}
|
||||
}
|
||||
if (!gm.getDesign(currentGuild).equals("3")) {
|
||||
String links = "[Support Server](https://discord.gg/jbne9JTJtU) ║ [Bot Invite](https://discord.com/api/oauth2/authorize?client_id=772513556116930580&permissions=321536&scope=bot)";
|
||||
eb.addField("Links & Help", links, false);
|
||||
}
|
||||
if (!gm.getDesign(currentGuild).equals("5")) {
|
||||
eb.setFooter("Sent by " + e.getGuild().getName(), iconUrl);
|
||||
} else {
|
||||
eb.setFooter("Sent by " + e.getGuild().getId() + " from " + e.getAuthor().getId(), iconUrl);
|
||||
}
|
||||
if (e.getMessage().getAttachments().size() > 0)
|
||||
eb.setImage(e.getMessage().getAttachments().get(0).getUrl());
|
||||
|
||||
eb.setDescription(e.getMessage().getContentRaw());
|
||||
eb.setAuthor(e.getAuthor().getAsTag(), null, e.getAuthor().getAvatarUrl());
|
||||
eb.setColor(e.getMember().getColor());
|
||||
currentChannel.sendMessage(eb.build()).queue();
|
||||
}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,110 @@
|
||||
package de.sheepstar.globalWrapper.listeners;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageBuilder;
|
||||
import de.sheepstar.globalWrapper.api.messagebuilder.MessageType;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.entities.Emote;
|
||||
import net.dv8tion.jda.api.entities.MessageEmbed;
|
||||
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 16.12.20
|
||||
********************************/
|
||||
|
||||
public class RoomReactionListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent e) {
|
||||
e.getChannel().retrieveMessageById(e.getMessageId()).queue(msg -> {
|
||||
if (e.getUser().isBot()) return;
|
||||
if (!msg.getAuthor().isBot()) return;
|
||||
if (!msg.getAuthor().getName().contains("Sheepstar")) return;
|
||||
if (msg.getEmbeds().size() != 1) return;
|
||||
if (msg.getEmbeds().get(0).getFooter() == null) return;
|
||||
if (!msg.getEmbeds().get(0).getFooter().getText().contains("Change with")) return;
|
||||
HashMap<String, String> emotes = new HashMap<>();
|
||||
ResultSet rst = MySQL.getResult("SELECT * FROM room_categories");
|
||||
try {
|
||||
while (rst.next()) {
|
||||
emotes.put(rst.getString("reaction"), rst.getString("id"));
|
||||
}
|
||||
} catch (Exception err) { }
|
||||
|
||||
if (e.getReactionEmote().isEmoji()) {
|
||||
if (e.getReactionEmote().getEmoji().equals("⬅️")) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM room_categories");
|
||||
String msgContent = "";
|
||||
|
||||
try { int count = 0;
|
||||
while (rs.next()) {
|
||||
if (count != 0) msgContent += "\n"; count++;
|
||||
msgContent += "`"+rs.getString("name")+"` "+Main.getInstance().getEmotesByName(rs.getString("reaction"), false).get(0).getAsMention();
|
||||
} } catch (Exception err) {}
|
||||
|
||||
MessageEmbed newMsg = new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("Sheepstar rooms")
|
||||
.setDescription(msgContent)
|
||||
.setThumbnail(null)
|
||||
.setFooter("Change with s!room <code>")
|
||||
.get();
|
||||
msg.editMessage(newMsg).queue();
|
||||
msg.removeReaction(e.getReactionEmote().getEmoji(), e.getUser()).queue();
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!emotes.containsKey(e.getReactionEmote().getName())) return;
|
||||
|
||||
// Prepare Message
|
||||
|
||||
String searchID = emotes.get(e.getReactionEmote().getName());
|
||||
|
||||
ResultSet rsb = MySQL.getResult("SELECT * FROM guilds WHERE guildID=? AND channelID=?", e.getGuild().getId(), e.getChannel().getId());
|
||||
String currentRoom = "";
|
||||
String currentLang = "";
|
||||
try {
|
||||
while (rsb.next()) {
|
||||
currentRoom = rsb.getString("roomID");
|
||||
currentLang = rsb.getString("languageCode");
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM rooms WHERE categorie=?", searchID);
|
||||
String msgContent = "";
|
||||
|
||||
try {
|
||||
int count = 0;
|
||||
while (rs.next()) {
|
||||
if (count != 0) msgContent += "\n";
|
||||
|
||||
ResultSet rstb = MySQL.getResult("SELECT * FROM guilds WHERE roomID=? AND languageCode=?", rs.getString("code"), currentLang);
|
||||
int roomCount = 0;
|
||||
try {while (rstb.next()) {roomCount++;}} catch (Exception err) {}
|
||||
count++;
|
||||
msgContent += "`[code] - [name] | [mem] Servers`"
|
||||
.replace("[code]", rs.getString("code"))
|
||||
.replace("[name]", rs.getString("name"))
|
||||
.replace("[mem]", String.valueOf(roomCount))
|
||||
+ ((rs.getString("code").toLowerCase().equals(currentRoom.toLowerCase())) ? " " + Main.getInstance().getEmotesByName("Sstar_larrow", true)
|
||||
.get(0).getAsMention(): "");
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
|
||||
MessageEmbed newEmbed = new MessageBuilder(MessageType.GREEN_MESSAGE)
|
||||
.setTitle("Sheepstar rooms")
|
||||
.setDescription(msgContent)
|
||||
.setFooter("Change with s!room <code>")
|
||||
.get();
|
||||
msg.editMessage(newEmbed).queue();
|
||||
msg.removeReaction(e.getReactionEmote().getEmote(), e.getUser()).queue();
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,63 @@
|
||||
package de.sheepstar.globalWrapper.listeners;
|
||||
|
||||
import de.sheepstar.globalWrapper.api.StrangerManager;
|
||||
import de.sheepstar.globalWrapper.api.ValidationCheck;
|
||||
import de.sheepstar.globalWrapper.api.sql.MySQL;
|
||||
import de.sheepstar.globalWrapper.core.Main;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.entities.Guild;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.api.hooks.ListenerAdapter;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.sql.ResultSet;
|
||||
import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
|
||||
/********************************
|
||||
* @author Mathias Wagner
|
||||
* Created 17.12.20
|
||||
********************************/
|
||||
|
||||
public class StrangerListener extends ListenerAdapter {
|
||||
|
||||
@Override
|
||||
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent e) {
|
||||
StrangerManager sm = Main.getStrangerManager();
|
||||
if (!sm.isRegistered(e.getGuild(), e.getChannel())) return;
|
||||
if (new ValidationCheck().validate(e)) {
|
||||
sendConnection(e, sm.getConnectID(e.getGuild(), e.getChannel()));
|
||||
}
|
||||
}
|
||||
|
||||
public void sendConnection(GuildMessageReceivedEvent e, String connectID) {
|
||||
ResultSet rs = MySQL.getResult("SELECT * FROM strangers WHERE connectID=?", connectID);
|
||||
try {
|
||||
while (rs.next()) {
|
||||
try {
|
||||
System.out.println(connectID);
|
||||
System.out.println("debug");
|
||||
Guild currentGuild = Main.getInstance().getGuildById(rs.getString("guildID"));
|
||||
TextChannel currentChannel = currentGuild.getTextChannelById(rs.getString("channelID"));
|
||||
EmbedBuilder eb = new EmbedBuilder();
|
||||
String iconUrl = e.getGuild().getIconUrl();
|
||||
if (iconUrl == null) iconUrl = "https://i.giphy.com/media/38pPhtupwYMerEQeBT/source.gif";
|
||||
eb.setThumbnail(iconUrl);
|
||||
eb.setTimestamp(OffsetDateTime.now().atZoneSameInstant(ZoneId.of("Europe/Berlin")));
|
||||
String links = "[Support Server](https://discord.gg/jbne9JTJtU) ║ [Bot Invite](https://discord.com/api/oauth2/authorize?client_id=772513556116930580&permissions=321536&scope=bot)";
|
||||
eb.addField("Links & Help", links, false);
|
||||
eb.setFooter("Sent by " + e.getGuild().getName(), iconUrl);
|
||||
if (e.getMessage().getAttachments().size() > 0) {
|
||||
eb.setImage(e.getMessage().getAttachments().get(0).getUrl());
|
||||
}
|
||||
eb.setDescription(e.getMessage().getContentRaw());
|
||||
eb.setAuthor(e.getAuthor().getAsTag(), null, e.getAuthor().getAvatarUrl());
|
||||
eb.setColor(e.getMember().getColor());
|
||||
currentChannel.sendMessage(eb.build()).queue();
|
||||
} catch (Exception err) {}
|
||||
}
|
||||
} catch (Exception err) {}
|
||||
}
|
||||
|
||||
}
|
3
SheepstarGlobal/src/main/resources/META-INF/MANIFEST.MF
Executable file
3
SheepstarGlobal/src/main/resources/META-INF/MANIFEST.MF
Executable file
@ -0,0 +1,3 @@
|
||||
Manifest-Version: 1.0
|
||||
Main-Class: de.sheepstar.globalWrapper.core.Main
|
||||
|
Reference in New Issue
Block a user