Uploaded SheepstarV1

This commit is contained in:
Mathias Wagner 2022-07-19 21:00:28 +02:00
parent ac26ae6ef4
commit 221cf5db37
84 changed files with 3949 additions and 0 deletions

4
SheepstarV1/.gitignore vendored Executable file
View File

@ -0,0 +1,4 @@
/beta.json
/target/*
*.class
/target/

2
SheepstarV1/.idea/Sheepstar.iml generated Normal file
View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

14
SheepstarV1/.idea/compiler.xml generated Normal file
View File

@ -0,0 +1,14 @@
<?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" />
<module name="sheepstar" />
</profile>
</annotationProcessing>
</component>
</project>

6
SheepstarV1/.idea/discord.xml generated Normal file
View 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>

35
SheepstarV1/.idea/jarRepositories.xml generated Normal file
View File

@ -0,0 +1,35 @@
<?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="jitpack.io" />
<option name="name" value="jitpack.io" />
<option name="url" value="https://jitpack.io" />
</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="nsn" />
<option name="name" value="maven-nsn" />
<option name="url" value="https://maven.nsnetwork.de" />
</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="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>

14
SheepstarV1/.idea/misc.xml generated Normal file
View 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
SheepstarV1/.idea/uiDesigner.xml generated Normal file
View 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
SheepstarV1/.idea/vcs.xml generated Normal file
View 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>

265
SheepstarV1/.idea/workspace.xml generated Normal file
View File

@ -0,0 +1,265 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AutoImportSettings">
<option name="autoReloadType" value="SELECTIVE" />
</component>
<component name="ChangeListManager">
<list default="true" id="367ac1fd-6e19-4124-9fe5-00deac83e291" name="Default Changelist" comment="">
<change afterPath="$PROJECT_DIR$/google.json" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/essentials/UptimeCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/CommandInfoCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/ModuleInfoCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/trending/LeaderboardCacheUpdater.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/trending/LeaderboardCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/trending/LeaderboardManager.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/Bootstrap.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/api/ChatCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/api/ChatManager.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/api/DialogflowProcess.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/commands/AddChatCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/commands/RemoveChatCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/chat/listeners/MessageSentListener.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/embed/Bootstrap.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/commands/ChangeLanguageCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/commands/ChangeRoomCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/commands/RemoveGlobalCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/commands/RulesCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/commands/ShowLanguagesCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/commands/ShowRoomsCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/moderation/Bootstrap.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/moderation/commands/BanCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/moderation/commands/KickCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/moderation/commands/UserInfoCommand.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/autoupdater/AutoUpdate.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/economy/EconomyManager.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/economy/ShopManager.java" afterDir="false" />
<change afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/settings/SettingsManager.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pom.xml" beforeDir="false" afterPath="$PROJECT_DIR$/pom.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/core/Bootstrap.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/core/Bootstrap.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/core/Main.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/core/Main.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/essentials/HelpCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/essentials/HelpCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/DisableModuleCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/DisableModuleCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/EnableModuleCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/EnableModuleCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/ListModulesCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/ListModulesCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/TestCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/main/commands/modules/ShowModulesCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/Bootstrap.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/Bootstrap.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/api/GlobalManager.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/api/GlobalManager.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/api/ValidationCheck.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/api/ValidationCheck.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/listeners/GlobalListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/global/listeners/GlobalListener.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/voice/http/StatusHandler.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/http/StatusHandler.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/modules/voice/http/WebServer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/http/WebServer.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/GuildEssentials.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/GuildEssentials.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/builder/message/MessageBuilder.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/builder/message/MessageBuilder.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/command/GuildCommand.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/command/GuildCommand.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/listener/GuildListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/listener/GuildListener.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/sql/StorageMedium.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/xyz/sheepstar/wrapper/util/api/sql/StorageMedium.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/core/Bootstrap.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/core/Bootstrap.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/core/Main.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/core/Main.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/main/commands/modules/EnableModuleCommand.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/main/commands/modules/EnableModuleCommand.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/modules/global/Bootstrap.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/modules/global/Bootstrap.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/modules/voice/http/StatusHandler.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/modules/voice/http/WebServer.class" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/util/api/builder/message/MessageBuilder.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/util/api/builder/message/MessageBuilder.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/util/api/command/GuildCommand.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/util/api/command/GuildCommand.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/util/api/listener/GuildListener.class" beforeDir="false" afterPath="$PROJECT_DIR$/target/classes/xyz/sheepstar/wrapper/util/api/listener/GuildListener.class" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Enum" />
<option value="Class" />
</list>
</option>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
<component name="GitSEFilterConfiguration">
<file-type-list>
<filtered-out-file-type name="LOCAL_BRANCH" />
<filtered-out-file-type name="REMOTE_BRANCH" />
<filtered-out-file-type name="TAG" />
<filtered-out-file-type name="COMMIT_BY_MESSAGE" />
</file-type-list>
</component>
<component name="ProjectId" id="1nRTbqTfJESFa8Wcs4Zw8VAnyQN" />
<component name="ProjectLevelVcsManager" settingsEditedManually="true">
<ConfirmationsSetting value="2" id="Add" />
</component>
<component name="ProjectViewState">
<option name="hideEmptyMiddlePackages" value="true" />
<option name="showLibraryContents" value="true" />
</component>
<component name="PropertiesComponent">
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" />
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" />
<property name="SHARE_PROJECT_CONFIGURATION_FILES" value="true" />
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="aspect.path.notification.shown" value="true" />
<property name="dart.analysis.tool.window.visible" value="false" />
<property name="last_opened_file_path" value="$PROJECT_DIR$" />
<property name="nodejs_package_manager_path" value="npm" />
<property name="project.structure.last.edited" value="Modules" />
<property name="project.structure.proportion" value="0.15" />
<property name="project.structure.side.proportion" value="0.20689656" />
<property name="restartRequiresConfirmation" value="false" />
<property name="settings.editor.selected.configurable" value="preferences.lookFeel" />
<property name="show.migrate.to.gradle.popup" value="false" />
</component>
<component name="RecentsManager">
<key name="CopyFile.RECENT_KEYS">
<recent name="$PROJECT_DIR$" />
</key>
<key name="CopyClassDialog.RECENTS_KEY">
<recent name="xyz.sheepstar.wrapper.modules.global.api" />
<recent name="xyz.sheepstar.wrapper.modules.chat.api" />
<recent name="xyz.sheepstar.wrapper.modules.moderation.commands" />
</key>
</component>
<component name="RunAnythingCache">
<option name="myCommands">
<command value="mvn compile" />
</option>
</component>
<component name="RunManager" selected="Application.BETA">
<configuration name="BETA" type="Application" factoryName="Application">
<option name="ALTERNATIVE_JRE_PATH" value="/usr/lib/jvm/java-1.8.0-openjdk-amd64/jre" />
<option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
<envs>
<env name="GOOGLE_APPLICATION_CREDENTIALS" value="google.json" />
</envs>
<option name="MAIN_CLASS_NAME" value="xyz.sheepstar.wrapper.core.Main" />
<module name="sheepstar" />
<option name="PROGRAM_PARAMETERS" value="-cf beta.json" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration name="Main" type="Application" factoryName="Application" temporary="true" nameIsGenerated="true">
<option name="MAIN_CLASS_NAME" value="xyz.sheepstar.wrapper.core.Main" />
<module name="Sheepstar" />
<option name="PROGRAM_PARAMETERS" value="-cf def.json" />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<configuration default="true" type="ArquillianTestNG" factoryName="" nameIsGenerated="true">
<option name="arquillianRunConfiguration">
<value>
<option name="containerStateName" value="" />
</value>
</option>
<option name="TEST_OBJECT" value="CLASS" />
<properties />
<listeners />
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
<list>
<item itemvalue="Application.BETA" />
<item itemvalue="Application.Main" />
</list>
<recent_temporary>
<list>
<item itemvalue="Application.Main" />
</list>
</recent_temporary>
</component>
<component name="SpellCheckerSettings" RuntimeDictionaries="0" Folders="0" CustomDictionaries="0" DefaultDictionary="application-level" UseSingleDictionary="true" transferred="true" />
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="367ac1fd-6e19-4124-9fe5-00deac83e291" name="Default Changelist" comment="" />
<created>1611351980160</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1611351980160</updated>
<workItem from="1611351982513" duration="3877000" />
<workItem from="1611358472819" duration="1203000" />
<workItem from="1611411128769" duration="13677000" />
<workItem from="1611501011292" duration="460000" />
<workItem from="1611501524339" duration="2545000" />
<workItem from="1611504605660" duration="21123000" />
<workItem from="1611535169312" duration="167000" />
<workItem from="1611535358765" duration="3472000" />
<workItem from="1611589601608" duration="11549000" />
<workItem from="1611659076684" duration="9212000" />
<workItem from="1611680141302" duration="1531000" />
<workItem from="1611692651425" duration="19649000" />
<workItem from="1611733607400" duration="7464000" />
<workItem from="1611764604782" duration="9955000" />
<workItem from="1611852020729" duration="618000" />
<workItem from="1611853240119" duration="1204000" />
<workItem from="1611890234647" duration="1231000" />
<workItem from="1611947854447" duration="106000" />
<workItem from="1611948008903" duration="9409000" />
<workItem from="1611967242367" duration="1875000" />
<workItem from="1612120350713" duration="55000" />
<workItem from="1612363403113" duration="71000" />
<workItem from="1612435816974" duration="578000" />
<workItem from="1612436417223" duration="3833000" />
<workItem from="1612484859989" duration="193000" />
<workItem from="1612485157347" duration="205000" />
<workItem from="1612485760040" duration="599000" />
<workItem from="1612678004948" duration="6000" />
<workItem from="1612707189188" duration="4569000" />
<workItem from="1612715788326" duration="12000" />
<workItem from="1612715823958" duration="10000" />
<workItem from="1612716117027" duration="2910000" />
<workItem from="1612727579254" duration="1444000" />
<workItem from="1612758915500" duration="19380000" />
<workItem from="1612811841786" duration="398000" />
<workItem from="1612853177363" duration="1204000" />
<workItem from="1612874942318" duration="24917000" />
<workItem from="1612943218123" duration="14586000" />
<workItem from="1612980395321" duration="8046000" />
<workItem from="1613029197836" duration="19032000" />
<workItem from="1613068766891" duration="4568000" />
<workItem from="1613115092013" duration="2859000" />
<workItem from="1613143454577" duration="12517000" />
<workItem from="1613213617428" duration="17563000" />
</task>
<task id="LOCAL-00001" summary="Added multiple Monitors to Counter Module&#10;Added Global v1 Module&#10;Added Bot Info Command&#10;Edited some other commands">
<created>1612973584862</created>
<option name="number" value="00001" />
<option name="presentableId" value="LOCAL-00001" />
<option name="project" value="LOCAL" />
<updated>1612973584862</updated>
</task>
<option name="localTasksCounter" value="2" />
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="3" />
</component>
<component name="Vcs.Log.Tabs.Properties">
<option name="TAB_STATES">
<map>
<entry key="MAIN">
<value>
<State />
</value>
</entry>
</map>
</option>
<option name="oldMeFiltersMigrated" value="true" />
</component>
<component name="VcsManagerConfiguration">
<ignored-roots>
<path value="$PROJECT_DIR$" />
</ignored-roots>
<MESSAGE value="Added multiple Monitors to Counter Module&#10;Added Global v1 Module&#10;Added Bot Info Command&#10;Edited some other commands" />
<option name="LAST_COMMIT_MESSAGE" value="Added multiple Monitors to Counter Module&#10;Added Global v1 Module&#10;Added Bot Info Command&#10;Edited some other commands" />
</component>
<component name="XSLT-Support.FileAssociations.UIState">
<expand />
<select />
</component>
</project>

View File

@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4" />

85
SheepstarV1/pom.xml Normal file
View File

@ -0,0 +1,85 @@
<?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>xyz.sheepstar</groupId>
<artifactId>sheepstar</artifactId>
<version>1.0</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>
<repositories>
<repository>
<id>nsn</id>
<url>https://maven.nsnetwork.de</url>
<name>maven-nsn</name>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>jcenter</id>
<name>jcenter-bintray</name>
<url>https://jcenter.bintray.com</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.23</version>
</dependency>
<dependency>
<groupId>de.tools</groupId>
<artifactId>SQLToolkit</artifactId>
<version>1.1</version>
</dependency>
<dependency>
<groupId>net.dv8tion</groupId>
<artifactId>JDA</artifactId>
<version>4.2.0_227</version>
</dependency>
<dependency>
<groupId>org.discordbots</groupId>
<artifactId>DBL-Java-Library</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>[18.0,)</version>
</dependency>
<dependency>
<groupId>com.googlecode.json-simple</groupId>
<artifactId>json-simple</artifactId>
<version>1.1.1</version>
</dependency>
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-dialogflow</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
<version>1.60.0</version>
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-dialogflow</artifactId>
<version>2.3.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,127 @@
package xyz.sheepstar.wrapper.core;
import com.google.common.reflect.ClassPath;
import drivers.MySQLConnection;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
import net.dv8tion.jda.api.requests.GatewayIntent;
import org.apache.commons.cli.*;
import types.LogLevelType;
import xyz.sheepstar.wrapper.util.Config;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
import javax.security.auth.login.LoginException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Set;
/********************************
* @author Mathias Wagner
* Created 23.01.2021
********************************/
public class Bootstrap {
private String[] args = null;
private Config config = null;
private CommandLine commandLine = null;
private MySQLConnection mySQLConnection = null;
private JDA jda;
public Bootstrap(String[] args) {
this.args = args;
}
public Bootstrap init() {
validateArguments();
loadConfiguration();
registerMySQL();
registerJDA();
return this;
}
private void validateArguments() {
Options options = new Options();
Option input = new Option("cf", "configFile", true, "Sheepstar Config File");
input.setRequired(true);
options.addOption(input);
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
try {
this.commandLine = parser.parse(options, this.args);
} catch (ParseException e) {
System.out.println(e.getMessage());
formatter.printHelp("sheepstar-bot", options);
System.exit(1);
}
}
private void loadConfiguration() {
this.config = new Config(this.commandLine.getOptionValue("configFile"));
}
private void registerMySQL() {
this.mySQLConnection = new MySQLConnection(
config.getString("mysql_host"),
config.getString("mysql_user"),
config.getString("mysql_pass"),
config.getString("mysql_data"),
LogLevelType.ALL
).connect();
}
private void registerJDA() {
try {
jda = JDABuilder.createDefault(config.getString("bot_token")).enableIntents(GatewayIntent.GUILD_MEMBERS).build();
} catch (LoginException e) {
System.out.println(e.getMessage());
System.exit(0);
}
}
public void enableModule(String module) {
try {
((SheepstarModule) Class.forName("xyz.sheepstar.wrapper.modules."+ module.toLowerCase()+".Bootstrap").newInstance()).init();
System.out.println("Modul '" + module + "' erfolgreich geladen.");
} catch (Exception e) {System.out.println("Modul '"+ module.toLowerCase() +"' konnte nicht geladen werden: " + e.getMessage()); }
}
public void enableModules(String... modules) {
for (String module : modules) enableModule(module);
}
public void enableAllModules(String moduleRoot) {
ArrayList<String> classes = new ArrayList<>();
try {
ClassLoader cl = getClass().getClassLoader();
Set<ClassPath.ClassInfo> classesInPackage = ClassPath.from(cl).getTopLevelClassesRecursive(moduleRoot);
classesInPackage.forEach(info -> {
String className = info.getPackageName().replaceAll(moduleRoot+".", "");
if (className.split("\\.").length != 1) className = className.split("\\.")[0];
if (!classes.contains(className)) classes.add(className);
});
} catch (IOException e) { }
classes.forEach(className -> {
try { enableModule(className); } catch (Exception ignored) {}
});
System.out.println("Laden der Module abgeschlossen");
}
public JDA getJDA() {
return jda;
}
public CommandLine getArgs() {
return commandLine;
}
public Config getConfig() {
return config;
}
public MySQLConnection getMySQLConnection() {
return mySQLConnection;
}
}

View File

@ -0,0 +1,99 @@
package xyz.sheepstar.wrapper.core;
import drivers.MySQLConnection;
import net.dv8tion.jda.api.JDA;
import org.apache.commons.cli.*;
import org.discordbots.api.client.DiscordBotListAPI;
import xyz.sheepstar.wrapper.main.commands.essentials.BotInfoCommand;
import xyz.sheepstar.wrapper.main.commands.essentials.HelpCommand;
import xyz.sheepstar.wrapper.main.commands.essentials.PingCommand;
import xyz.sheepstar.wrapper.main.commands.essentials.UptimeCommand;
import xyz.sheepstar.wrapper.main.commands.modules.*;
import xyz.sheepstar.wrapper.main.commands.trending.LeaderboardCacheUpdater;
import xyz.sheepstar.wrapper.main.commands.trending.LeaderboardCommand;
import xyz.sheepstar.wrapper.util.Config;
import xyz.sheepstar.wrapper.util.api.GuildManager;
import xyz.sheepstar.wrapper.util.api.autoupdater.AutoUpdate;
import xyz.sheepstar.wrapper.util.api.http.WebServer;
import xyz.sheepstar.wrapper.util.api.module.ModuleManager;
import xyz.sheepstar.wrapper.util.api.settings.SettingsManager;
/********************************
* @author Mathias Wagner
* Created 22.01.2021
********************************/
public class Main {
private static MySQLConnection mySQLConnection;
private static Config sheepstarConfig;
private static DiscordBotListAPI botListAPI;
private static CommandLine cmd;
private static JDA jda;
// Managers
private static GuildManager guildManager = new GuildManager();
private static ModuleManager moduleManager = new ModuleManager();
private static SettingsManager settingsManager = new SettingsManager();
public static void main(String[] args) throws Exception {
// Initialize Sheepstar
Bootstrap bootstrap = new Bootstrap(args).init();
mySQLConnection = bootstrap.getMySQLConnection();
sheepstarConfig = bootstrap.getConfig();
cmd = bootstrap.getArgs();
jda = bootstrap.getJDA();
jda.awaitReady();
// Start Webserver
new WebServer().start();
// Start AutoUpdate
new AutoUpdate().start();
// New Leaderboard Updater
new LeaderboardCacheUpdater().start();
// Register Sheepstar Commands
jda.addEventListener(new PingCommand());
jda.addEventListener(new HelpCommand());
jda.addEventListener(new EnableModuleCommand());
jda.addEventListener(new ListModulesCommand());
jda.addEventListener(new ModuleInfoCommand());
jda.addEventListener(new DisableModuleCommand());
jda.addEventListener(new BotInfoCommand());
jda.addEventListener(new ShowModulesCommand());
jda.addEventListener(new UptimeCommand());
jda.addEventListener(new CommandInfoCommand());
jda.addEventListener(new LeaderboardCommand());
// Register Sheepstar Modules
bootstrap.enableAllModules("xyz.sheepstar.wrapper.modules");
}
public static CommandLine getArgs() { return cmd; }
public static MySQLConnection getDB() {
return mySQLConnection;
}
public static GuildManager getGuildManager() {
return guildManager;
}
public static ModuleManager getModuleManager() {
return moduleManager;
}
public static SettingsManager getSettingsManager() {
return settingsManager;
}
public static Config getConfig() {
return sheepstarConfig;
}
public static JDA getJDA() {
return jda;
}
}

View File

@ -0,0 +1,36 @@
package xyz.sheepstar.wrapper.main.commands.essentials;
import com.sun.org.apache.xerces.internal.impl.dtd.DTDGrammar;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class BotInfoCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("botinfo", "botstats");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
sendMessage()
.addField("Servers", jda.getGuildCache().stream().count()+"", true)
.addField("Users", jda.getUserCache().stream().count()+"", true)
.addField("Ping", jda.getGatewayPing()+" ms", true)
.send(e.getChannel());
}
}

View File

@ -0,0 +1,41 @@
package xyz.sheepstar.wrapper.main.commands.essentials;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class HelpCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("help", "bothelp");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
sendMessage()
.setTitle(getEmoteString("Sstar_info") + " Sheepstar help")
.addField(":grey_question: How does ist work?", "Sheepstar is a bot that is divided into modules. " +
"Use the following commands to manage them:", false)
.addField(":keyboard: Available modules", "`s!modules`", true)
.addField(":keyboard: Activated modules", "`s!list`", true)
.addField(":keyboard: Enable module", "`s!enable <moduleName>`", true)
.addField(":keyboard: Disable module", "s!disable <moduleName>", true)
.addField(":keyboard: Commands in module", "s!commands <moduleName>", true)
.addField(":keyboard: Module information", "s!info <moduleName>", true)
.send(e.getChannel());
}
}

View File

@ -0,0 +1,34 @@
package xyz.sheepstar.wrapper.main.commands.essentials;
import net.dv8tion.jda.api.entities.Invite;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class PingCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("ping", "botping", "gatewayping");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
sendMessage()
.setTitle("Sheepstar ping")
.setDescription("Pong! " + jda.getGatewayPing() + " ms.")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,85 @@
package xyz.sheepstar.wrapper.main.commands.essentials;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.lang.management.ManagementFactory;
import java.lang.management.RuntimeMXBean;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class UptimeCommand extends GuildCommand {
private static final long SECOND = 1000;
private static final long MINUTE = 60 * SECOND;
private static final long HOUR = 60 * MINUTE;
private static final long DAY = 24 * HOUR;
@Override
public List<String> getAlias() {
return Collections.singletonList("uptime");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
sendMessage()
.setTitle("Sheepstar uptime")
.setDescription(formatUptime(rb.getUptime()))
.send(e.getChannel());
}
public static String formatUptime(long uptime) {
StringBuilder buf = new StringBuilder();
if (uptime > DAY) {
long days = (uptime - uptime % DAY) / DAY;
buf.append(days);
buf.append(" Days");
uptime = uptime % DAY;
}
if (uptime > HOUR) {
long hours = (uptime - uptime % HOUR) / HOUR;
if (buf.length() > 0) buf.append(", ");
buf.append(hours);
buf.append(" Hours");
uptime = uptime % HOUR;
}
if (uptime > MINUTE) {
long minutes = (uptime - uptime % MINUTE) / MINUTE;
if (buf.length() > 0) buf.append(", ");
buf.append(minutes);
buf.append(" Minutes");
uptime = uptime % MINUTE;
}
if (uptime > SECOND) {
long seconds = (uptime - uptime % SECOND) / SECOND;
if (buf.length() > 0) buf.append(", ");
buf.append(seconds);
buf.append(" Seconds");
uptime = uptime % SECOND;
}
if (uptime > 0) {
if (buf.length() > 0) buf.append(", ");
buf.append(uptime);
buf.append(" Milliseconds");
}
return buf.toString();
}
}

View File

@ -0,0 +1,41 @@
package xyz.sheepstar.wrapper.main.commands.modules;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 12.02.2021
********************************/
public class CommandInfoCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("commands");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (args.length != 1) { sendUsage(e, "<moduleName>");return; }
MessageBuilder builder = sendMessage();
if (!moduleManager.isEnabled(e.getGuild(), args[0])) {
sendErrorMessage().setDescription("This module is not activated").send(e.getChannel());
return;
}
String prefix = getModulePrefix(e.getGuild(), args[0]);
getCommands(args[0]).forEach((name, command) -> {
builder.addField(":keyboard: "+name, "`"+prefix+command+"`", true);
});
builder.send(e.getChannel());
}
}

View File

@ -0,0 +1,39 @@
package xyz.sheepstar.wrapper.main.commands.modules;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class DisableModuleCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("disable", "disablemodule", "unloadmodule", "unload");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (args.length != 1) { sendUsage(e,"<modul>");return; }
if (!moduleManager.isEnabled(e.getGuild(), args[0])) {
sendErrorMessage().setDescription("This module is not activated").send(e.getChannel());
return;
}
moduleManager.disable(e.getGuild(), args[0].toLowerCase());
sendMessage()
.setTitle("Modul disabled.")
.setDescription("Module `" + args[0] + "` disabled.")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,49 @@
package xyz.sheepstar.wrapper.main.commands.modules;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.builder.message.ColorType;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 24.01.2021
********************************/
public class EnableModuleCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("enablemodule", "activatemodule", "enable", "activate");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (args.length != 2) { sendUsage(e,"<module> <prefix>");return; }
// TODO: Secret Manager
if (args[0].equals("SheepstarIs") && args[1].equals("CUTE")) {
sendPlainMessage(e, "thank ya ;3");
return;
}
if (!moduleManager.exists(args[0])) {
sendErrorMessage().setDescription("This module does not exist.").send(e.getChannel());return;
}
if (moduleManager.usedWhereOther(e.getGuild(), args[1])) {
sendErrorMessage().setDescription("The prefix is already in use.").send(e.getChannel());return;
}
moduleManager.enable(e.getGuild(), args[0].toLowerCase(), args[1]);
sendMessage()
.setTitle("Modul enabled.")
.setDescription("Module `" + args[0] + "` enabled.")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,46 @@
package xyz.sheepstar.wrapper.main.commands.modules;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class ListModulesCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("prefixes", "enabled", "list");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
StringBuilder sb = new StringBuilder();
MessageBuilder mb = sendMessage()
.setTitle("Enabled modules");
Main.getDB()
.selectFrom("enabled_modules")
.where("guildID", e.getGuild().getId())
.getResult()
.getMultipleList("name", "prefix")
.forEach((v1, v2) -> {
mb.addField(toCamelCase(v1), "`"+v2+"help`", true);
});
if (sb.toString().isEmpty()) sb.append("Currently no module is active. Activate one with **%pre%enable <moduleName>** look at a list with **%pre%modules**".replace("%pre%", getPrefix(e.getGuild())));
else mb.setFooter("Look at a list with **%pre%modules**".replace("%pre%", getPrefix(e.getGuild())));
mb.send(e.getChannel());
}
}

View File

@ -0,0 +1,48 @@
package xyz.sheepstar.wrapper.main.commands.modules;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class ModuleInfoCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("info", "moduleinfo");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (args.length != 1) {
sendUsage(e, "<moduleName>");
return;
}
if (!moduleManager.exists(args[0])) {
sendErrorMessage()
.setDescription("This module does not exist.")
.send(e.getChannel());
return;
}
Main.getDB().getResult("SELECT * FROM existing_modules WHERE name=?", args[0]).getMultipleList("description", "icon_url").forEach((description, icon_url) -> {
sendMessage()
.setTitle(toCamelCase(args[0] + " module"))
.setDescription(description)
.setThumbnail(icon_url)
.send(e.getChannel());
});
}
}

View File

@ -0,0 +1,37 @@
package xyz.sheepstar.wrapper.main.commands.modules;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.modules.counter.api.Manager;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public class ShowModulesCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("modules", "existing_modules");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
MessageBuilder mb = sendMessage();
Main.getDB().selectFrom("existing_modules").getResult().getMultipleList("name", "description").forEach((name, description) -> {
mb.addField(toCamelCase(name), description, false);
});
mb.send(e.getChannel());
}
}

View File

@ -0,0 +1,44 @@
package xyz.sheepstar.wrapper.main.commands.trending;
import net.dv8tion.jda.api.entities.Guild;
import xyz.sheepstar.wrapper.core.Main;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class LeaderboardCacheUpdater extends Thread {
@Override
public void run() {
List<Guild> guildList = new ArrayList<>(Main.getJDA().getGuildCache().asList());
HashMap<Guild, Long> tempMap = new HashMap<>();
guildList.sort(Comparator
.comparingDouble((Guild guild) -> guild.loadMembers().get()
.stream()
.filter(member -> !member.getUser().isBot())
.count())
.reversed());
guildList.sort(Comparator.comparingDouble(Guild::getMemberCount)
.reversed());
guildList.forEach(guild -> {
if (Main.getSettingsManager().get(guild, "showInTrends").equals("true")) {
tempMap.put(guild, guild.loadMembers().get().stream().filter(member -> !member.getUser().isBot()).count());
}
});
LeaderboardManager.guildCache.clear();
tempMap.forEach(LeaderboardManager.guildCache::put);
try { Thread.sleep(300000); } catch (Exception ignored) { }
run();
}
}

View File

@ -0,0 +1,43 @@
package xyz.sheepstar.wrapper.main.commands.trending;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class LeaderboardCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("leaderboard", "top");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
MessageBuilder mb = sendMessage();
AtomicInteger countf = new AtomicInteger(1);
LeaderboardManager.guildCache.forEach((guild, integer) -> {
String count = "`"+countf.get()+".`";
if (countf.get() == 1) count = ":first_place:";
if (countf.get() == 2) count = ":second_place:";
if (countf.get() == 3) count = ":third_place:";
mb.addField(count+" "+ guild.getName() + " ["+integer+"]", "" , false);
countf.incrementAndGet();
});
mb.send(e.getChannel());
}
}

View File

@ -0,0 +1,23 @@
package xyz.sheepstar.wrapper.main.commands.trending;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import xyz.sheepstar.wrapper.util.api.GuildEssentials;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
import java.util.stream.Collectors;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class LeaderboardManager extends GuildEssentials {
public static HashMap<Guild, Long> guildCache = new HashMap<>();
}

View File

@ -0,0 +1,19 @@
package xyz.sheepstar.wrapper.modules.chat;
import xyz.sheepstar.wrapper.modules.chat.commands.AddChatCommand;
import xyz.sheepstar.wrapper.modules.chat.listeners.MessageSentListener;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class Bootstrap extends SheepstarModule {
@Override
public void init() throws Exception {
jda.addEventListener(new AddChatCommand());
jda.addEventListener(new MessageSentListener());
}
}

View File

@ -0,0 +1,17 @@
package xyz.sheepstar.wrapper.modules.chat.api;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public abstract class ChatCommand extends GuildCommand {
private static ChatManager chatManager = new ChatManager();
public static ChatManager getChatManager() {
return chatManager;
}
}

View File

@ -0,0 +1,39 @@
package xyz.sheepstar.wrapper.modules.chat.api;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.TextChannel;
import xyz.sheepstar.wrapper.core.Main;
import java.sql.ResultSet;
/********************************
* @author Mathias Wagner
* Created 13.12.20
********************************/
public class ChatManager {
public boolean isRegistered(Guild guild, TextChannel channel) {
return Main.getDB().getResult("SELECT * FROM chat_channels WHERE guildID=? AND channelID=?", guild.getId(), channel.getId()).getRowCount() == 1;
}
public String getLanguage(Guild guild, TextChannel channel) {
return Main.getDB().getResult("SELECT * FROM chat_channels WHERE guildID=? AND channelID=?", guild.getId(), channel.getId()).getString("language");
}
public void setLanguage(String langCode, Guild guild, TextChannel channel) {
if (!isRegistered(guild, channel)) return;
Main.getDB().update("UPDATE chat_channels SET language=? WHERE guildID=? AND channelID=?", langCode, guild.getId(), channel.getId());
}
public void register(Guild guild, TextChannel channel) {
if (isRegistered(guild, channel)) return;
Main.getDB().update("INSERT INTO chat_channels (guildID, channelID, language) VALUES (?, ?, 'EN')", guild.getId(), channel.getId());
}
public void unregister(Guild guild, TextChannel channel) {
if (!isRegistered(guild, channel)) return;
Main.getDB().update("DELETE FROM chat_channels WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
}
}

View File

@ -0,0 +1,59 @@
package xyz.sheepstar.wrapper.modules.chat.api;
import com.google.api.gax.rpc.ApiException;
import com.google.cloud.dialogflow.v2.QueryResult;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.User;
import xyz.sheepstar.wrapper.util.api.GuildEssentials;
import java.util.Collections;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 06.09.20
********************************/
public class DialogflowProcess extends GuildEssentials {
public String processMessage(String lang, User user, String msg) {
try {
String txt = detectIntentTexts("sheepstar-vyqb", Collections.singletonList(msg), user.getId(), (lang.equals("DE") ? "de" : "en"));
txt = txt.replace("%mention%", user.getAsMention())
.replace("%tag%", user.getAsTag());
for (String current : txt.split(" ")) {
if (current.startsWith(":") && current.endsWith(":")) {
String emoteName = current.replace(":", "");
try {
Emote emote = getEmote(emoteName);
txt = txt.replace(current, emote.getAsMention());
} catch (Exception err) {}
}
}
return (txt.isEmpty() ? "Connection to Servers lost." : txt);
} catch (Exception err) {}
return "Connection to API Servers lost.";
}
public static String detectIntentTexts(String projectId, List<String> texts, String sessionId, String languageCode)
throws ApiException {
try (com.google.cloud.dialogflow.v2.SessionsClient sessionsClient = com.google.cloud.dialogflow.v2.SessionsClient.create()) {
com.google.cloud.dialogflow.v2.SessionName session = com.google.cloud.dialogflow.v2.SessionName.of(projectId, sessionId);
for (String text : texts) {
com.google.cloud.dialogflow.v2.TextInput.Builder textInput = com.google.cloud.dialogflow.v2.TextInput.newBuilder().setText(text).setLanguageCode(languageCode);
com.google.cloud.dialogflow.v2.QueryInput queryInput = com.google.cloud.dialogflow.v2.QueryInput.newBuilder().setText(textInput).build();
com.google.cloud.dialogflow.v2.DetectIntentResponse response = sessionsClient.detectIntent(session, queryInput);
QueryResult queryResult = response.getQueryResult();
return queryResult.getFulfillmentText();
}
} catch (Exception err) {
err.printStackTrace();
return "Connection to Servers lost.";
}
return "Connection to Servers lost.";
}
}

View File

@ -0,0 +1,41 @@
package xyz.sheepstar.wrapper.modules.chat.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.chat.api.ChatCommand;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class AddChatCommand extends ChatCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("addchat", "addchatchannel", "ac");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (getChatManager().isRegistered(e.getGuild(), e.getChannel())) {
sendErrorMessage()
.setDescription("This channel is already an chat-channel. Remove it with s!removechat")
.send(e.getChannel());
} else {
getChatManager().register(e.getGuild(), e.getChannel());
sendMessage()
.setTitle("Channel added")
.setDescription("This channel is now an chat-channel")
.send(e.getChannel());
}
}
}

View File

@ -0,0 +1,41 @@
package xyz.sheepstar.wrapper.modules.chat.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.chat.api.ChatCommand;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 12.02.2021
********************************/
public class RemoveChatCommand extends ChatCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("removechat", "deletechat", "dc");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (!getChatManager().isRegistered(e.getGuild(), e.getChannel())) {
sendErrorMessage()
.setDescription("This channel is already an chat-channel. Remove it with s!removechat")
.send(e.getChannel());
} else {
getChatManager().register(e.getGuild(), e.getChannel());
sendMessage()
.setTitle("Channel added")
.setDescription("This channel is now an chat-channel")
.send(e.getChannel());
}
}
}

View File

@ -0,0 +1,30 @@
package xyz.sheepstar.wrapper.modules.chat.listeners;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import org.jetbrains.annotations.NotNull;
import xyz.sheepstar.wrapper.modules.chat.api.ChatCommand;
import xyz.sheepstar.wrapper.modules.chat.api.ChatManager;
import xyz.sheepstar.wrapper.modules.chat.api.DialogflowProcess;
import xyz.sheepstar.wrapper.util.api.listener.GuildListener;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class MessageSentListener extends GuildListener {
@Override
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
if (!isValid(event.getGuild())) return;
if (event.getAuthor().isBot()) return;
ChatManager cm = ChatCommand.getChatManager();
if (!cm.isRegistered(event.getGuild(), event.getChannel())) return;
sendPlainMessage(event, new DialogflowProcess().processMessage(
cm.getLanguage(event.getGuild(), event.getChannel()),
event.getAuthor(),
event.getMessage().getContentRaw()
));
}
}

View File

@ -0,0 +1,26 @@
package xyz.sheepstar.wrapper.modules.counter;
import xyz.sheepstar.wrapper.modules.counter.action.MemberUpdate;
import xyz.sheepstar.wrapper.modules.counter.commands.EnableCommand;
import xyz.sheepstar.wrapper.modules.counter.commands.MonitorListCommand;
import xyz.sheepstar.wrapper.modules.counter.commands.SetupCommand;
import xyz.sheepstar.wrapper.modules.counter.listeners.CounterDelete;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class Bootstrap extends SheepstarModule {
@Override
public void init() throws Exception {
jda.addEventListener(new EnableCommand());
jda.addEventListener(new MonitorListCommand());
jda.addEventListener(new SetupCommand());
jda.addEventListener(new CounterDelete());
new MemberUpdate().run();
}
}

View File

@ -0,0 +1,76 @@
package xyz.sheepstar.wrapper.modules.counter.action;
import net.dv8tion.jda.api.entities.*;
import xyz.sheepstar.wrapper.core.Main;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class MemberUpdate {
public void run() {
Runnable drawRunnable = new Runnable() {
public void run() {
ArrayList<String> currentGuilds = new ArrayList<>();
Main.getDB().selectFrom("counter_channels").getResult().getList("guildID").forEach(guildID -> {
if (!currentGuilds.contains(guildID)) {
currentGuilds.add(guildID);
try { update(Objects.requireNonNull(Main.getJDA().getGuildById(guildID))); } catch (Exception ignored) { }
}
});
}};
ScheduledExecutorService exec = Executors.newScheduledThreadPool(1);
exec.scheduleAtFixedRate(drawRunnable , 0, 10, TimeUnit.MINUTES);
}
public void update(Guild guild) {
Main.getDB().selectFrom("counter_channels").where("guildID", guild.getId()).getResult().getMultipleList("keyName", "value").forEach((monitorType, channelID) -> {
// Update Member Monitors
if (monitorType.equals("member_id") || monitorType.equals("allmembers_id") || monitorType.equals("bots_id")) {
guild.loadMembers().onSuccess(list -> updateMemberMonitor(monitorType, list, channelID));
}
// Update Channel Monitors
if (monitorType.equals("channels_id") || monitorType.equals("textchannels_id") || monitorType.equals("voicechannels_id")) {
updateChannelMonitor(monitorType, guild.getChannels(), channelID);
}
});
}
public void updateChannelMonitor(String monitorType, List<GuildChannel> guilds, String channelID) {
if (monitorType.equals("voicechannels_id"))
updateChannelName(channelID, guilds.stream().filter(guild -> guild instanceof VoiceChannel).count());
if (monitorType.equals("textchannels_id"))
updateChannelName(channelID,guilds.stream().filter(guild -> guild instanceof TextChannel).count());
if (monitorType.equals("channels_id"))
updateChannelName(channelID, guilds.size());
}
public void updateMemberMonitor(String monitorType, List<Member> members, String channelID) {
if (monitorType.equals("member_id"))
updateChannelName(channelID, members.stream().filter(member -> !member.getUser().isBot()).count());
if (monitorType.equals("bots_id"))
updateChannelName(channelID, members.stream().filter(member -> member.getUser().isBot()).count());
if (monitorType.equals("allmembers_id")) {
updateChannelName(channelID, members.size());
}
}
public void updateChannelName(String channelID, long count) {
try{
GuildChannel channel = Main.getJDA().getGuildChannelById(channelID);
channel.getManager().setName(channel.getName().replaceAll("\\d+", ""+count)).queue();
} catch (NullPointerException err) {
Main.getDB().updateTable("counter_channels").where("value", channelID).delete();
}
}
}

View File

@ -0,0 +1,17 @@
package xyz.sheepstar.wrapper.modules.counter.api;
import xyz.sheepstar.wrapper.util.api.sql.StorageMedium;
import java.util.ArrayList;
import java.util.Arrays;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class Manager {
public static ArrayList<String> monitorList =
new ArrayList<>(Arrays.asList("AllMembers", "Members", "Bots", "Channels", "Textchannels", "Voicechannels"));
}

View File

@ -0,0 +1,67 @@
package xyz.sheepstar.wrapper.modules.counter.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.counter.action.MemberUpdate;
import xyz.sheepstar.wrapper.modules.counter.api.Manager;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import xyz.sheepstar.wrapper.util.api.sql.StorageMedium;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class EnableCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("enablemodule", "enable", "activate", "activatemodule");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
StorageMedium storage = new StorageMedium(e.getGuild(), "counter_channels");
if (args.length != 2) {
sendUsage(e, "enable <monitorName> <text/voice>\nYou can find a list under " + moduleManager.getPrefix(e.getGuild(), "counter")+"list");
return;
}
String monitorName = args[0].toLowerCase();
if (Manager.monitorList.contains(monitorName.toLowerCase())) {
sendErrorMessage().setDescription("This module does not exist. Use a module from " + moduleManager.getPrefix(e.getGuild(), "counter")+"list");
return;
}
String channelType = args[1].toLowerCase();
if (!(channelType.equalsIgnoreCase("text") || channelType.equalsIgnoreCase("voice"))) {
sendErrorMessage().setDescription("Please use a valid channel type (voice/text)").send(e.getChannel());
return;
}
if (!storage.exists(monitorName+"_id")) {
if (channelType.equals("voice")) {
e.getGuild().createVoiceChannel("\uD83D\uDC65▎%channel%: 0".replace("%channel%", toCamelCase(monitorName))).setPosition(0).queue(voiceChannel -> {
storage.insert(monitorName+"_id", voiceChannel.getId());
new MemberUpdate().update(e.getGuild());
});
} else if (channelType.equals("text")) {
e.getGuild().createTextChannel("\uD83D\uDC65▎%channel%:0".replace("%channel%", monitorName)).setPosition(0).queue(textChannel -> {
storage.insert(monitorName+"_id", textChannel.getId());
new MemberUpdate().update(e.getGuild());
});
}
sendMessage()
.setDescription("You have successfully created a "+monitorName+" channel!").send(e.getChannel());
} else {
sendErrorMessage().setDescription("You already added this channel").send(e.getChannel());
}
}
}

View File

@ -0,0 +1,39 @@
package xyz.sheepstar.wrapper.modules.counter.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.counter.api.Manager;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class MonitorListCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("monitors", "list");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
StringBuilder descString = new StringBuilder();
Manager.monitorList.forEach(monitor -> {
descString.append(toCamelCase(monitor) + "\n");
});
sendMessage()
.setTitle("Counter monitors")
.setDescription(descString.toString())
.setFooter("Use " + moduleManager.getPrefix(e.getGuild(), "counter") + "<monitor> <text/voice> to create a stats channel")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,59 @@
package xyz.sheepstar.wrapper.modules.counter.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.counter.action.MemberUpdate;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import xyz.sheepstar.wrapper.util.api.sql.StorageMedium;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public class SetupCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Collections.singletonList("setup");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
StorageMedium storage = new StorageMedium(e.getGuild(), "counter_channels");
e.getGuild().createCategory("\uD83D\uDC65▎Stats").setPosition(1).queue(category -> {
if (!storage.exists("allmembers_id")) {
category.createVoiceChannel("\uD83D\uDC65▎All Members: 0").queue(voiceChannel -> {
storage.insert("allmembers_id", voiceChannel.getId());
new MemberUpdate().update(e.getGuild());
});
}
if (!storage.exists("member_id")) {
category.createVoiceChannel("\uD83D\uDC65▎Members: 0").queue(voiceChannel -> {
storage.insert("member_id", voiceChannel.getId());
new MemberUpdate().update(e.getGuild());
});
}
if (!storage.exists("bots_id")) {
category.createVoiceChannel("\uD83D\uDC65▎Bots: 0").queue(voiceChannel -> {
storage.insert("bots_id", voiceChannel.getId());
new MemberUpdate().update(e.getGuild());
});
}
});
sendMessage()
.setDescription("You have successfully created a stats category!")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,36 @@
package xyz.sheepstar.wrapper.modules.counter.listeners;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.events.channel.text.TextChannelDeleteEvent;
import net.dv8tion.jda.api.events.channel.voice.VoiceChannelDeleteEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import xyz.sheepstar.wrapper.util.api.listener.GuildListener;
import xyz.sheepstar.wrapper.util.api.sql.StorageMedium;
/********************************
* @author Mathias Wagner
* Created 08.02.2021
********************************/
public class CounterDelete extends GuildListener {
@Override
public void onTextChannelDelete(@NotNull TextChannelDeleteEvent e) {
if (!isValid(e.getGuild())) return;
delete(e.getGuild(), e.getChannel().getId());
}
@Override
public void onVoiceChannelDelete(@NotNull VoiceChannelDeleteEvent e) {
if (!isValid(e.getGuild())) return;
delete(e.getGuild(), e.getChannel().getId());
}
public void delete(Guild guild, String id) {
StorageMedium storage = new StorageMedium(guild, "counter_channels");
if (storage.existsValue(id)) storage.deleteValue(id);
}
}

View File

@ -0,0 +1,16 @@
package xyz.sheepstar.wrapper.modules.embed;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class Bootstrap extends SheepstarModule {
@Override
public void init() throws Exception {
}
}

View File

@ -0,0 +1,33 @@
package xyz.sheepstar.wrapper.modules.global;
import xyz.sheepstar.wrapper.modules.global.commands.*;
import xyz.sheepstar.wrapper.modules.global.listeners.GlobalListener;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
/********************************
* @author Mathias Wagner
* Created 23.01.2021
********************************/
public class Bootstrap extends SheepstarModule {
@Override
public void init() throws Exception {
jda.addEventListener(new RulesCommand());
jda.addEventListener(new AddGlobalCommand());
jda.addEventListener(new RemoveGlobalCommand());
jda.addEventListener(new GlobalListener());
jda.addEventListener(new ShowLanguagesCommand());
jda.addEventListener(new ChangeLanguageCommand());
jda.addEventListener(new ShowRoomsCommand());
jda.addEventListener(new ChangeRoomCommand());
}
}

View File

@ -0,0 +1,15 @@
package xyz.sheepstar.wrapper.modules.global.api;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public abstract class GlobalCommand extends GuildCommand {
public static GlobalManager globalManager = new GlobalManager();
public GlobalManager getGlobalManager() { return globalManager; }
}

View File

@ -0,0 +1,55 @@
package xyz.sheepstar.wrapper.modules.global.api;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.TextChannel;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public class GlobalManager {
public boolean isRegistered(Guild guild, TextChannel channel) {
return Main.getDB().getResult("SELECT * FROM global_channels WHERE guildID=? AND channelID=?", guild.getId(), channel.getId()).getRowCount() == 1;
}
public void register(Guild guild, TextChannel channel) {
if (isRegistered(guild, channel)) return;
Main.getDB().update("INSERT INTO global_channels (guildID, channelID, language, roomID) VALUES (?, ?, 'EN', '1')", guild.getId(), channel.getId());
}
public void unregister(Guild guild, TextChannel channel) {
if (!isRegistered(guild, channel)) return;
Main.getDB().update("DELETE FROM global_channels WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
}
public boolean isValidRoom(String roomCode) {
return Main.getDB().getResult("SELECT * FROM global_rooms WHERE code=?", roomCode).getRowCount() == 1;
}
public boolean isValidLanguage(String languageCode) {
return Main.getDB().getResult("SELECT * FROM global_languages WHERE code=?", languageCode).getRowCount() == 1;
}
public void changeLanguage(TextChannel channel, String newLanguage) {
if (!isValidLanguage(newLanguage)) return;
Main.getDB().update("UPDATE global_channels SET language=? WHERE channelID=?", newLanguage.toUpperCase(), channel.getId());
}
public void changeRoom(TextChannel channel, String newRoom) {
if (!isValidRoom(newRoom)) return;
Main.getDB().update("UPDATE global_channels SET roomID=? WHERE channelID=?", newRoom.toLowerCase(), channel.getId());
}
public String getRoom(TextChannel channel) {
return Main.getDB().getResult("SELECT * FROM global_channels WHERE channelID=?", channel.getId()).getString("roomID");
}
public String getLanguage(TextChannel channel) {
return Main.getDB().getResult("SELECT * FROM global_channels WHERE channelID=?", channel.getId()).getString("language");
}
}

View File

@ -0,0 +1,68 @@
package xyz.sheepstar.wrapper.modules.global.api;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.GuildEssentials;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class ValidationCheck extends GuildEssentials {
public boolean validate(GuildMessageReceivedEvent e) {
GlobalManager gm = GlobalCommand.globalManager;
String messageContent = e.getMessage().getContentRaw();
String lowerContent = e.getMessage().getContentRaw().toLowerCase();
if (e.getAuthor().isBot()) return false;
if (messageContent.startsWith(moduleManager.getPrefix(e.getGuild(), "global"))) return false;
if (messageContent.startsWith(guildManager.getPrefix(e.getGuild()))) return false;
if (e.getMessage().getContentRaw().startsWith("=")) { e.getMessage().addReaction(getEmote("Sstar_cross")).queue();return false; }
try {
e.getMessage().delete().queue();
} catch (Exception err) { return false; }
// TODO: guten spamschutz einbauen
// TODO: Schaun ob Server & User gebannt
// Check if Message Contains Ads TODO: überprüfen ob owner is, die dürfen werbung machen
String msg = e.getMessage().getContentRaw().toLowerCase();
if ((msg.contains("http://") ||
msg.contains("https://") ||
msg.contains("www."))) {
sendErrorMessage()
.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())) {
sendMessage()
.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(" ", "");
return Main.getDB().getResult("SELECT * FROM global_custom_blacklist WHERE guildID=? AND ? LIKE concat('%', word, '%')",
guildID, msgContent).getRowCount() == 1;
}
public boolean isBlocked(String msgContent) {
msgContent = msgContent.replace(" ", "");
return Main.getDB().getResult("SELECT * FROM global_blacklist WHERE ? LIKE concat('%', word, '%')", msgContent)
.getRowCount() == 1;
}
}

View File

@ -0,0 +1,47 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public class AddGlobalCommand extends GlobalCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("addglobal", "ag");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (getGlobalManager().isRegistered(e.getGuild(), e.getChannel())) {
sendErrorMessage()
.setDescription("You already have this GlobalChat on your server.")
.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());
}
}

View File

@ -0,0 +1,51 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class ChangeLanguageCommand extends GlobalCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("setlanguage", "lan", "language", "lang", "changelanguage", "sl", "cl", "setlang");
}
@Override
public PermissionNode getPermission() {
return null;
}
@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) {
sendUsage(e, "<code>\nYou can find a list under s!languages");
return;
}
if (!getGlobalManager().isValidLanguage(args[0])) {
sendErrorMessage()
.setDescription("This language does not exist\nYou can find a list under s!languages")
.send(e.getChannel());
return;
}
getGlobalManager().changeLanguage(e.getChannel(), args[0]);
sendMessage()
.setTitle("Channel language updated")
.setDescription("You changed this language to " + args[0].toUpperCase() + "!")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,57 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class ChangeRoomCommand extends GlobalCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("changeroom", "setroom", "sr", "room");
}
@Override
public PermissionNode getPermission() {
return null;
}
@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) {
sendUsage(e, " <code> \nYou can find a list under s!rooms");
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());
return;
}
if (args[0].contains("p") && !guildManager.hasPremium(e.getGuild())) {
sendErrorMessage()
.setDescription("You must have Premium to enter this Channel")
.send(e.getChannel());
return;
}
getGlobalManager().changeRoom(e.getChannel(), args[0]);
sendMessage()
.setTitle("Channel room updated")
.setDescription("You changed this room to " + args[0].toLowerCase() + "!")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,43 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class RemoveGlobalCommand extends GlobalCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("removeglobal", "remove", "delete", "deleteglobal", "unregister");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
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());
return;
}
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());
}
}

View File

@ -0,0 +1,42 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class RulesCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("rules", "regeln", "rule", "r");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
sendMessage()
.noThumbnail()
.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());
}
}

View File

@ -0,0 +1,51 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class ShowLanguagesCommand extends GlobalCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("languages", "langs");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
String currentLang = getGlobalManager().getLanguage(e.getChannel());
ResultSet rs = Main.getDB().getResultSet("SELECT * FROM global_languages");
String msgContent = "";
try {
while (rs.next()) {
if (!msgContent.isEmpty()) msgContent += "\n";
int roomCount = Main.getDB().getResult("SELECT * FROM global_channels WHERE language=?", rs.getString("code")).getRowCount();
msgContent += "`%code% - %name% | %mem% Servers`"
.replace("%code%", rs.getString("code"))
.replace("%name%", rs.getString("name"))
.replace("%mem%", String.valueOf(roomCount));
if (rs.getString("code").toLowerCase().equals(currentLang.toLowerCase()))
msgContent += " "+ getEmoteString("Sstar_larrow");
}
} catch (Exception ignored) {}
sendMessage()
.setTitle("Sheepstar languages")
.setDescription(msgContent)
.setFooter("Change with s!lang <code>")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,147 @@
package xyz.sheepstar.wrapper.modules.global.commands;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.api.events.message.react.MessageReactionAddEvent;
import org.jetbrains.annotations.NotNull;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.sql.ResultSet;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 10.02.2021
********************************/
public class ShowRoomsCommand extends GlobalCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("rooms", "showrooms");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
ResultSet rs = Main.getDB().getResultSet("SELECT * FROM global_categories");
String msgContent = "";
try {
while (rs.next()) {
if (!msgContent.isEmpty()) msgContent += "\n";
msgContent += "`"+rs.getString("name")+"` "+getEmoteString(rs.getString("reaction"));
} } catch (Exception err) {}
MessageEmbed msg = sendMessage()
.setTitle("Sheepstar rooms")
.setDescription(msgContent)
.setFooter("Change with s!room <code>")
.get();
e.getChannel().sendMessage(msg).queue(message -> {
message.addReaction("⬅️").queue();
try {
ResultSet rsb = Main.getDB().getResultSet("SELECT * FROM global_categories");
while (rsb.next()) {
try {
message.addReaction(getEmote(rsb.getString("reaction"))).queue();
} catch (Exception ignored) { }
}
} catch (Exception err) { }
});
}
@Override
public void onMessageReactionAdd(@NotNull MessageReactionAddEvent e) {
if (!isValid(e.getGuild())) return;
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 = Main.getDB().getResultSet("SELECT * FROM global_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("⬅️")) {
msg.removeReaction(e.getReactionEmote().getEmoji(), e.getUser()).queue();
ResultSet rs = Main.getDB().getResultSet("SELECT * FROM global_categories");
String msgContent = "";
try { int count = 0;
while (rs.next()) {
if (count != 0) msgContent += "\n"; count++;
msgContent += "`"+rs.getString("name")+"` "+getEmoteString(rs.getString("reaction"));
} } catch (Exception err) {}
MessageEmbed newMsg = sendMessage()
.setTitle("Sheepstar rooms")
.setDescription(msgContent)
.setThumbnail(null)
.setFooter("Change with s!room <code>")
.get();
msg.editMessage(newMsg).queue();
return;
}
} else {
msg.removeReaction(e.getReactionEmote().getEmote(), e.getUser()).queue();
}
if (!emotes.containsKey(e.getReactionEmote().getName())) return;
// Prepare Message
String searchID = emotes.get(e.getReactionEmote().getName());
ResultSet rsb = Main.getDB().getResultSet("SELECT * FROM global_channels 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("language");
}
} catch (Exception err) {}
ResultSet rs = Main.getDB().getResultSet("SELECT * FROM global_rooms WHERE category=?", searchID);
String msgContent = "";
try {
int count = 0;
while (rs.next()) {
if (count != 0) msgContent += "\n";
ResultSet rstb = Main.getDB().getResultSet("SELECT * FROM global_channels WHERE roomID=? AND language=?", 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())) ? " " + getEmoteString("Sstar_larrow") : "");
}
} catch (Exception err) {}
MessageEmbed newEmbed = sendMessage()
.setTitle("Sheepstar rooms")
.setDescription(msgContent)
.setFooter("Change with s!room <code>")
.get();
msg.editMessage(newEmbed).queue();
});
}
}

View File

@ -0,0 +1,84 @@
package xyz.sheepstar.wrapper.modules.global.listeners;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import org.jetbrains.annotations.NotNull;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.modules.global.api.GlobalCommand;
import xyz.sheepstar.wrapper.modules.global.api.GlobalManager;
import xyz.sheepstar.wrapper.modules.global.api.ValidationCheck;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.listener.GuildListener;
import java.sql.ResultSet;
import java.time.OffsetDateTime;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public class GlobalListener extends GuildListener {
@Override
public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent e) {
GlobalManager gm = GlobalCommand.globalManager;
if (!isValid(e.getGuild())) return;
if (!gm.isRegistered(e.getGuild(), e.getChannel())) return;
if (!new ValidationCheck().validate(e)) return;
String roomID = gm.getRoom(e.getChannel());
String language = gm.getLanguage(e.getChannel());
// NSFW check
if (!e.getChannel().isNSFW() && roomID.contains("n")) {
sendErrorMessage()
.setDescription("You joined an NSFW Room. Please set this Channel to NSFW or change the Room with `s!rooms`")
.send(e.getChannel());
}
// TODO:
sendGlobal(e, language, roomID);
}
public void sendGlobal(GuildMessageReceivedEvent e, String language, String roomID) {
GlobalManager gm = GlobalCommand.globalManager;
ResultSet rs = Main.getDB().getResult("SELECT * FROM global_channels WHERE language=? AND roomID=?", language, roomID).getResultSet();
try {
while (rs.next()) {
try {
String guildID = rs.getString("guildID");
String channelID = rs.getString("channelID");
Guild currentGuild = Main.getJDA().getGuildById(guildID);
TextChannel currentChannel = currentGuild.getTextChannelById(channelID);
if (!isValid(e.getGuild())) break;
MessageBuilder mb = sendMessage();
String iconURL = e.getGuild().getIconUrl();
if (iconURL == null) iconURL = "https://i.giphy.com/media/38pPhtupwYMerEQeBT/source.gif";
mb.setThumbnail(iconURL);
mb.enableTimeStamp();
if (roomID.startsWith("n")) mb.addField(" ", "`NSFW` :underage:", false);
mb.setFooter("Sent by " + e.getGuild().getName(), iconURL);
//https://github.com/sheepstar-dc/global-old/blob/master/src/main/java/de/sheepstar/globalWrapper/listeners/GlobalListener.java
String links = "[Support Server](https://discord.gg/jbne9JTJtU) ║ [Bot Invite](https://discord.com/api/oauth2/authorize?client_id=772513556116930580&permissions=321536&scope=bot)";
mb.addField("", links, false);
if (e.getMessage().getAttachments().size() > 0)
mb.setImage(e.getMessage().getAttachments().get(0).getUrl());
mb.setDescription(e.getMessage().getContentRaw());
mb.setAuthor(e.getAuthor().getAsTag(), e.getAuthor().getAvatarUrl());
mb.send(currentChannel);
} catch (Exception ignored) {}
}
} catch (Exception ignored) {}
}
}

View File

@ -0,0 +1,22 @@
package xyz.sheepstar.wrapper.modules.moderation;
import xyz.sheepstar.wrapper.modules.moderation.commands.BanCommand;
import xyz.sheepstar.wrapper.modules.moderation.commands.KickCommand;
import xyz.sheepstar.wrapper.modules.moderation.commands.UserInfoCommand;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class Bootstrap extends SheepstarModule {
@Override
public void init() throws Exception {
jda.addEventListener(new BanCommand());
jda.addEventListener(new KickCommand());
jda.addEventListener(new UserInfoCommand());
}
}

View File

@ -0,0 +1,48 @@
package xyz.sheepstar.wrapper.modules.moderation.commands;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class BanCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("ban", "banuser");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (e.getMessage().getMentionedUsers().isEmpty()) { sendUsage(e, "<@user> [days] [reason]");return; }
Member target = e.getMessage().getMentionedMembers().get(0);
int days = -1;
try { days = Integer.parseInt(args[1]); } catch (Exception err) {}
int usedString = (days == -1 ? 1 : 2);
String reason = "";
for (int i=usedString; i < args.length; i++) reason += args[i]+" ";
if (reason.isEmpty()) reason = "Not reason given";
if (reason.endsWith(" ")) reason = reason.substring(0, reason.length() - 1);
target.ban(days, reason).queue();
sendMessage()
.setThumbnail(target.getUser().getAvatarUrl())
.setDescription("The member **"+target.getUser().getName()+"** got banned for **"+days+"** days.\nReason: `" + reason + "`")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,44 @@
package xyz.sheepstar.wrapper.modules.moderation.commands;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class KickCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("kick", "kickuser");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (e.getMessage().getMentionedUsers().isEmpty()) { sendUsage(e, "<@user> [reason]");return; }
Member target = e.getMessage().getMentionedMembers().get(0);
String reason = "";
for (int i=1; i < args.length; i++) reason += args[i]+" ";
if (reason.isEmpty()) reason = "Not reason given";
if (reason.endsWith(" ")) reason = reason.substring(0, reason.length() - 1);
target.kick(reason).queue();
sendMessage()
.setThumbnail(target.getUser().getAvatarUrl())
.setDescription("The member **"+target.getUser().getName()+"** got kicked.\nReason: `" + reason + "`")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,60 @@
package xyz.sheepstar.wrapper.modules.moderation.commands;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import net.dv8tion.jda.api.entities.User;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class UserInfoCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("userinfo", "user");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
if (e.getMessage().getMentionedUsers().isEmpty()) { sendUsage(e, "<@user>");return; }
Member target = e.getMessage().getMentionedMembers().get(0);
StringBuilder roleText = new StringBuilder();
List<Role> roleList = target.getRoles();
roleList.forEach(role -> {
if (!roleText.toString().isEmpty()) roleText.append(", ");
roleText.append(role.getAsMention());
});
DateTimeFormatter format = DateTimeFormatter.ofPattern("dd-MM-yyyy HH:mm:ss");
String boostedTime = "";
if (target.getTimeBoosted() == null) boostedTime = ":x: Not boosting";
else boostedTime = target.getTimeBoosted().format(format);
sendMessage()
.setTitle(":information_source: Userinfo")
.addField(":id: Client-ID", target.getId(), true)
.addField(":pencil: Username", target.getUser().getAsTag(), true)
.addField(getEmoteString("Sstar_nitro")+" Boosting since", boostedTime, true)
.addField(":open_file_folder: Roles ("+roleList.size()+")", roleText.toString(), true)
.addField(":date: Joined date", target.getTimeJoined().format(format), true)
.addField(":date: Creation date", target.getTimeCreated().format(format), true)
.setColor(target.getColor())
.setThumbnail(target.getUser().getAvatarUrl())
.send(e.getChannel());
}
}

View File

@ -0,0 +1,21 @@
package xyz.sheepstar.wrapper.modules.voice;
import xyz.sheepstar.wrapper.modules.voice.commands.SetupCommand;
import xyz.sheepstar.wrapper.modules.voice.listeners.JoinListener;
import xyz.sheepstar.wrapper.util.api.module.SheepstarModule;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class Bootstrap extends SheepstarModule {
@Override
public void init() throws Exception {
jda.addEventListener(new JoinListener());
jda.addEventListener(new SetupCommand());
new DowntimeHandler();
}
}

View File

@ -0,0 +1,37 @@
package xyz.sheepstar.wrapper.modules.voice;
import net.dv8tion.jda.api.entities.VoiceChannel;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.modules.voice.api.Manager;
import xyz.sheepstar.wrapper.modules.voice.api.TempVoiceManager;
import java.util.concurrent.TransferQueue;
/********************************
* @author Mathias Wagner
* Created 26.01.2021
********************************/
public class DowntimeHandler {
TempVoiceManager tempVoiceManager = Manager.getTempVoiceManager();
public DowntimeHandler() {
new Thread(new Runnable() {
@Override
public void run() {
Main.getDB().getResult("SELECT * FROM voice_tempChannels").getList("channelID").forEach(channelID -> {
boolean delete = false;
try {
VoiceChannel channel = Main.getJDA().getVoiceChannelById(channelID);
if (channel.getMembers().size() <= 0) { channel.delete().queue(); delete = true; }
} catch (Exception err) { delete = true; }
if (delete) tempVoiceManager.unregister(channelID);
});
}
}).start();
}
}

View File

@ -0,0 +1,21 @@
package xyz.sheepstar.wrapper.modules.voice.api;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class Manager {
private static TempVoiceManager tempVoiceManager = new TempVoiceManager();
private static VoiceManager voiceManager = new VoiceManager();
public static TempVoiceManager getTempVoiceManager() {
return tempVoiceManager;
}
public static VoiceManager getVoiceManager() {
return voiceManager;
}
}

View File

@ -0,0 +1,44 @@
package xyz.sheepstar.wrapper.modules.voice.api;
import net.dv8tion.jda.api.entities.Category;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.VoiceChannel;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class TempVoiceManager {
public boolean isRegistered(String channelID) {
return Main.getDB().getResult("SELECT * FROM voice_tempChannels WHERE channelID=?", channelID).getRowCount() == 1;
}
public boolean isRegistered(VoiceChannel channel) {
return isRegistered(channel.getId());
}
public void register(String guildID, String channelID) {
if (isRegistered(channelID)) return;
Main.getDB().update("INSERT INTO voice_tempChannels (guildID, channelID) VALUES (?, ?)", guildID, channelID);
}
public void register(Guild guild, VoiceChannel channel) {
register(guild.getId(), channel.getId());
}
public void unregister(String channelID) {
if (!isRegistered(channelID)) return;
Main.getDB().update("DELETE FROM voice_tempChannels WHERE channelID=?", channelID);
}
public void unregister(VoiceChannel channel) {
unregister(channel.getId());
}
}

View File

@ -0,0 +1,33 @@
package xyz.sheepstar.wrapper.modules.voice.api;
import net.dv8tion.jda.api.entities.Category;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.VoiceChannel;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class VoiceManager {
public String getChannelName(VoiceChannel channel) {
return Main.getDB().getResult("SELECT * FROM voice_channels WHERE channelID=?", channel.getId()).getString("channelName");
}
public boolean isRegistered(VoiceChannel channel) {
return Main.getDB().getResult("SELECT * FROM voice_channels WHERE channelID=?", channel.getId()).getRowCount() == 1;
}
public void register(Guild guild, VoiceChannel channel) {
if (isRegistered(channel)) return;
Main.getDB().update("INSERT INTO voice_channels (guildID, channelID) VALUES (?, ?)", guild.getId(), channel.getId());
}
public void unregister(Guild guild, VoiceChannel channel) {
if (!isRegistered(channel)) return;
Main.getDB().update("DELETE FROM voice_channels WHERE guildID=? AND channelID=?", guild.getId(), channel.getId());
}
}

View File

@ -0,0 +1,30 @@
package xyz.sheepstar.wrapper.modules.voice.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class LimitCommand extends GuildCommand {
@Override
public List<String> getAlias() {
return Arrays.asList("setup", "create");
}
@Override
public PermissionNode getPermission() {
return null;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
}
}

View File

@ -0,0 +1,43 @@
package xyz.sheepstar.wrapper.modules.voice.commands;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.modules.voice.api.Manager;
import xyz.sheepstar.wrapper.modules.voice.api.VoiceManager;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.Arrays;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class SetupCommand extends GuildCommand {
private VoiceManager voiceManager = Manager.getVoiceManager();
@Override
public List<String> getAlias() {
return Arrays.asList("setup", "generate");
}
@Override
public PermissionNode getPermission() {
return PermissionNode.ADMINISTRATOR;
}
@Override
public void executeCommand(String[] args, GuildMessageReceivedEvent e) {
e.getGuild().createCategory("Sheepstar Voice").queue(cat -> {
cat.createVoiceChannel("Click to create").queue(channel -> {
voiceManager.register(e.getGuild(), channel);
});
});
sendMessage()
.setTitle("Tempchannel created")
.setDescription("Modify it by using s!help or by going in the [Dashboard](https://sheepstar.xyz/dashboard)")
.send(e.getChannel());
}
}

View File

@ -0,0 +1,71 @@
package xyz.sheepstar.wrapper.modules.voice.listeners;
import net.dv8tion.jda.api.entities.Category;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.VoiceChannel;
import net.dv8tion.jda.api.events.Event;
import net.dv8tion.jda.api.events.guild.GenericGuildEvent;
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceJoinEvent;
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceLeaveEvent;
import net.dv8tion.jda.api.events.guild.voice.GuildVoiceMoveEvent;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.jetbrains.annotations.NotNull;
import xyz.sheepstar.wrapper.modules.voice.api.Manager;
import xyz.sheepstar.wrapper.modules.voice.api.TempVoiceManager;
import xyz.sheepstar.wrapper.modules.voice.api.VoiceManager;
import xyz.sheepstar.wrapper.util.api.listener.GuildListener;
/********************************
* @author Mathias Wagner
* Created 25.01.2021
********************************/
public class JoinListener extends GuildListener {
private TempVoiceManager tempVoiceManager = Manager.getTempVoiceManager();
private VoiceManager voiceManager = Manager.getVoiceManager();
@Override
public void onGuildVoiceJoin(@NotNull GuildVoiceJoinEvent e) {
if (isValid(e.getGuild())) join(e.getChannelJoined(), e.getMember());
}
@Override
public void onGuildVoiceLeave(@NotNull GuildVoiceLeaveEvent e) {
if (isValid(e.getGuild())) leave(e.getChannelLeft());
}
@Override
public void onGuildVoiceMove(@NotNull GuildVoiceMoveEvent e) {
if (!isValid(e.getGuild())) return;
leave(e.getChannelLeft());
join(e.getChannelJoined(), e.getMember());
}
public void join(VoiceChannel joined, Member memb) {
if (voiceManager.isRegistered(joined)) {
Category cat = joined.getParent();
String origin = voiceManager.getChannelName(joined)
.replace("%name%", memb.getEffectiveName())
.replace("%tag%", memb.getUser().getAsTag().split("#")[1]);
cat.createVoiceChannel(origin).queue(vc -> {
vc.getManager().setUserLimit(joined.getUserLimit()).queue();
Guild guild = vc.getGuild();
guild.moveVoiceMember(memb, vc).queue();
tempVoiceManager.register(guild, vc);
});
}
}
public void leave(VoiceChannel channel) {
if (channel.getMembers().size() <= 0) {
if(tempVoiceManager.isRegistered(channel)) {
channel.delete().queue();
tempVoiceManager.unregister(channel);
}
}
}
}

View File

@ -0,0 +1,55 @@
package xyz.sheepstar.wrapper.util;
import org.json.simple.JSONObject;
import org.json.simple.parser.JSONParser;
import java.io.*;
/********************************
* @author Mathias Wagner
* Created 22.01.2021
********************************/
public class Config {
private File configFile;
public Config(String fileName) {
File tempFile = new File(fileName);
if (tempFile.exists()) {
try { this.configFile = tempFile; } catch (Exception ignored) { }
} else System.exit(0);
}
public void update(String str, Object obj) {
JSONObject jsonObject = new JSONObject();
// Get old configuration
JSONParser parser = new JSONParser();
try (Reader reader = new FileReader(configFile.getAbsolutePath())) {
JSONObject jsonObject2 = (JSONObject) parser.parse(reader);
jsonObject2.forEach(jsonObject::put);
} catch (Exception ignored) { }
// Updat new
jsonObject.put(str, obj);
try (FileWriter file = new FileWriter(configFile.getAbsolutePath())) { file.write(jsonObject.toJSONString()); } catch (IOException e) { }
}
public Object get(String path) {
JSONParser parser = new JSONParser();
try (Reader reader = new FileReader(configFile.getAbsolutePath())) {
JSONObject jsonObject = (JSONObject) parser.parse(reader);
return jsonObject.get(path);
} catch (Exception ignored) { ignored.printStackTrace(); }
return null;
}
public String getString(String path) {
return (String) get(path);
}
public int getInteger(String path) {
return (int) get(path);
}
}

View File

@ -0,0 +1,113 @@
package xyz.sheepstar.wrapper.util.api;
import com.google.common.base.CaseFormat;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Emote;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import org.apache.commons.lang3.StringUtils;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageType;
import xyz.sheepstar.wrapper.util.api.command.GuildCommand;
import xyz.sheepstar.wrapper.util.api.module.ModuleManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Random;
/********************************
* @author Mathias Wagner
* Created 09.02.2021
********************************/
public class GuildEssentials extends ListenerAdapter {
public JDA jda = Main.getJDA();
public ModuleManager moduleManager = Main.getModuleManager();
public GuildManager guildManager = Main.getGuildManager();
public MessageBuilder sendMessage() {
return new MessageBuilder(MessageType.SUCCESS).setThumbnail(getModuleIcon());
}
public MessageBuilder sendErrorMessage() {
return new MessageBuilder(MessageType.ERROR).setThumbnail(getModuleIcon());
}
// TODO: translate
public void sendPlainMessage(MessageReceivedEvent e, String msg) {
e.getChannel().sendMessage(msg).queue();
}
public void sendPlainMessage(GuildMessageReceivedEvent e, String msg) {
e.getChannel().sendMessage(msg).queue();
}
public String toCamelCase(String msg) {
return CaseFormat.UPPER_UNDERSCORE.to(CaseFormat.UPPER_CAMEL, msg);
}
public String getEmoteString(String emoteName) {
try {
return getEmote(emoteName).getAsMention();
} catch (Exception err) { return ":star:"; }
}
public Emote getEmote(String emoteName) {
try {
return jda.getEmotesByName(emoteName, true).get(0);
} catch (Exception err) {
return jda.getEmotesByName(":star:", true).get(0);
}
}
public boolean isValid(Guild guild) {
String packageName = this.getClass().getPackage().getName();
if (packageName.startsWith("xyz.sheepstar.wrapper.modules") && packageName.endsWith(".listeners") || packageName.endsWith(".commands")) {
packageName = packageName.replace("xyz.sheepstar.wrapper.modules.", "");
if (packageName.split("\\.").length >= 1) packageName = packageName.split("\\.")[0];
if (!moduleManager.exists(packageName)) return false;
if (!moduleManager.isEnabled(guild, packageName)) return false;
return true;
} else return false;
}
public String getModuleName() {
String packageName = this.getClass().getPackage().getName();
if (packageName.startsWith("xyz.sheepstar.wrapper.modules") && packageName.endsWith(".listeners") || packageName.endsWith(".commands")) {
packageName = packageName.replace("xyz.sheepstar.wrapper.modules.", "");
if (packageName.split("\\.").length >= 1) packageName = packageName.split("\\.")[0];
return packageName;
} else return "default";
}
public String getModuleIcon() {
String moduleName = getModuleName();
if (!moduleName.equals("default")) {
String icon = Main.getDB().getResult("SELECT * FROM existing_modules WHERE name=?", moduleName).getString("icon_url");
if (!icon.startsWith("http")) return "https://sheepstar.xyz/assets/favicon.png";
return icon;
} else return "https://sheepstar.xyz/assets/favicon.png";
}
public HashMap<String, String> getCommands(String moduleName) {
HashMap<String, String> aliases = new HashMap<>();
jda.getRegisteredListeners().forEach(obj -> {
if (obj.getClass().getName().startsWith("xyz.sheepstar.wrapper.modules."+moduleName+".commands")) {
GuildCommand cmd = (GuildCommand) obj;
String className = obj.getClass().getSimpleName().replace("Command", "");
className = StringUtils.join(StringUtils.splitByCharacterTypeCamelCase(className.replaceAll("\\d+", "")), " ");
aliases.put(className, cmd.getAlias().get(0));
}
});
return aliases;
}
}

View File

@ -0,0 +1,65 @@
package xyz.sheepstar.wrapper.util.api;
import net.dv8tion.jda.api.entities.Guild;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 24.01.2021
********************************/
public class GuildManager {
private void updateString(Guild guild, String column, String newContent) {
if (!isRegistered(guild)) register(guild);
Main.getDB().update("UPDATE guilds SET ?=? WHERE guildID=?", column, newContent, guild.getId());
}
private String getString(Guild guild, String column) {
if (!isRegistered(guild)) register(guild);
return Main.getDB().getResult("SELECT * FROM guilds WHERE guildID=?", guild.getId()).getString(column);
}
public boolean isRegistered(Guild guild) {
return Main.getDB().getResult("SELECT * FROM guilds WHERE guildID=?", guild.getId()).getRowCount() == 1;
}
public void register(Guild guild) {
if (isRegistered(guild)) return;
Main.getDB().update("INSERT INTO guilds (guildID, prefix, language, hasPremium, isBanned)" +
" VALUES (?, ?, ?, ?, ?)", guild.getId(), "s!", "EN", "false", "false");
}
public String getLanguage(Guild guild) {
return getString(guild, "language").toUpperCase();
}
public void updateLanguage(Guild guild, String newLanguage) {
updateString(guild, "language", newLanguage.toUpperCase());
}
public String getPrefix(Guild guild) {
return getString(guild, "prefix");
}
public void updatePrefix(Guild guild, String newLanguage) {
updateString(guild, "prefix", newLanguage);
}
public boolean hasPremium(Guild guild) {
return Boolean.parseBoolean(getString(guild, "hasPremium"));
}
public void setPremium(Guild guild, String premiumValue) {
updateString(guild, "hasPremium", premiumValue);
}
public boolean isBanned(Guild guild) {
return Boolean.parseBoolean(getString(guild, "isBanned"));
}
public void setBanned(Guild guild, String banValue) {
updateString(guild, "isBanned", banValue);
}
}

View File

@ -0,0 +1,26 @@
package xyz.sheepstar.wrapper.util.api.autoupdater;
import net.dv8tion.jda.api.OnlineStatus;
import net.dv8tion.jda.api.entities.Activity;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 11.02.2021
********************************/
public class AutoUpdate extends Thread {
@Override
public void run() {
if (Main.getConfig().get("beta_state").equals(true)) {
Main.getJDA().getPresence().setActivity(Activity.streaming("⚠️ Beta instance! Possibly unstable.", "https://twitch.tv/sheepstar"));
} else {
Main.getJDA().getPresence().setActivity(Activity.watching("discord.gg/jbne9JTJtU"));
try {Thread.sleep(5000);} catch (Exception ignored) {}
Main.getJDA().getPresence().setActivity(Activity.listening("s!help | sheepstar.xyz"));
try {Thread.sleep(20000);} catch (Exception ignored) {}
run();
}
}
}

View File

@ -0,0 +1,23 @@
package xyz.sheepstar.wrapper.util.api.builder.message;
import java.awt.*;
public enum ColorType {
RED(new Color(0xde1f1f)),
GREEN(new Color(0x2ecc71)),
ORANGE(new Color(0xFF8C00)),
GRAY(new Color(0x4E4C4C)),
WHITE(new Color(0xE9E3E3)),
BLACK(new Color(0x222222));
private Color color;
ColorType(Color color) {
this.color = color;
}
public Color getColor() {
return color;
}
}

View File

@ -0,0 +1,105 @@
package xyz.sheepstar.wrapper.util.api.builder.message;
import net.dv8tion.jda.api.EmbedBuilder;
import net.dv8tion.jda.api.entities.MessageEmbed;
import net.dv8tion.jda.api.entities.TextChannel;
import xyz.sheepstar.wrapper.util.api.GuildEssentials;
import java.awt.*;
import java.time.OffsetDateTime;
import java.time.ZoneId;
/********************************
* @author Mathias Wagner
* Created 24.01.2021
********************************/
public class MessageBuilder extends GuildEssentials {
private EmbedBuilder eb;
public MessageBuilder(MessageType type) {
eb = new EmbedBuilder();
if (type == MessageType.SUCCESS) {
setColor(ColorType.GREEN);
} else if (type == MessageType.WARNING) {
setColor(ColorType.ORANGE);
} else if (type == MessageType.ERROR) {
setColor(ColorType.RED);
}
}
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 setColor(ColorType colorType) {
eb.setColor(colorType.getColor());
return this;
}
public MessageBuilder setColor(Color color) {
eb.setColor(color);
return this;
}
public MessageBuilder setDescription(String description) {
eb.setDescription(description);
return this;
}
public MessageBuilder setAuthor(String author) {
eb.setAuthor(author);
return this;
}
public MessageBuilder setAuthor(String author, String url) {
eb.setAuthor(author, null, url);
return this;
}
public MessageBuilder setThumbnail(String url) {
eb.setThumbnail(url);
return this;
}
public MessageBuilder noThumbnail() {
eb.setThumbnail(null);
return this;
}
public MessageBuilder setFooter(String footer) {
eb.setFooter(footer);
return this;
}
public MessageBuilder setFooter(String footer, String url) {
eb.setFooter(footer, url);
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;
}
public MessageBuilder setImage(String url) {
eb.setImage(url);
return this;
}
}

View File

@ -0,0 +1,9 @@
package xyz.sheepstar.wrapper.util.api.builder.message;
public enum MessageType {
SUCCESS,
WARNING,
ERROR;
}

View File

@ -0,0 +1,23 @@
package xyz.sheepstar.wrapper.util.api.command;
import com.google.common.base.CaseFormat;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.GuildEssentials;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageBuilder;
import xyz.sheepstar.wrapper.util.api.builder.message.MessageType;
import java.util.HashMap;
/********************************
* @author Mathias Wagner
* Created 24.01.2021
********************************/
public abstract class Command extends GuildEssentials {
}

View File

@ -0,0 +1,72 @@
package xyz.sheepstar.wrapper.util.api.command;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Message;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.GuildManager;
import xyz.sheepstar.wrapper.util.api.module.ModuleManager;
import xyz.sheepstar.wrapper.util.api.permission.PermissionNode;
import java.util.ArrayList;
import java.util.List;
/********************************
* @author Mathias Wagner
* Created 23.01.2021
********************************/
public abstract class GuildCommand extends Command {
public abstract List<String> getAlias();
public abstract PermissionNode getPermission();
public abstract void executeCommand(String[] args, GuildMessageReceivedEvent e);
public ModuleManager moduleManager = Main.getModuleManager();
public GuildManager guildManager = Main.getGuildManager();
public String getPrefix(Guild guild) { return Main.getGuildManager().getPrefix(guild); }
public String getModulePrefix(Guild guild, String moduleName) { return moduleManager.getPrefix(guild, moduleName); }
@Override
public void onGuildMessageReceived( GuildMessageReceivedEvent e) {
if (e.getAuthor() == null || e.getChannel() == null) return;
if (e.getAuthor().isBot()) return;
String packageName = this.getClass().getPackage().getName();
if (packageName.startsWith("xyz.sheepstar.wrapper.modules.")) {
packageName = packageName.replace("xyz.sheepstar.wrapper.modules.", "");
if (packageName.split("\\.").length >= 1) packageName = packageName.split("\\.")[0];
if (!moduleManager.exists(packageName)) return;
if (!isValidCommand(e.getGuild(), e.getMessage(), getModulePrefix(e.getGuild(), packageName))) return;
executeCommand( commandArgs( e.getGuild(), e.getMessage() ), e );
} else {
if (!isValidCommand(e.getGuild(), e.getMessage(), getPrefix(e.getGuild()))) return;
executeCommand( commandArgs( e.getGuild(), e.getMessage() ), e );
}
}
public void sendUsage(GuildMessageReceivedEvent e, String usage) {
sendErrorMessage()
.setTitle("Wrong usage")
.setDescription("Use " + getPrefix(e.getGuild()) + getAlias().get(0) + " " + usage)
.send(e.getChannel());
}
private boolean isValidCommand(Guild guild, Message msg, String prefix) {
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.toLowerCase());
}
private String[] commandArgs(Guild guild, Message msg) {
String prefix = getPrefix(guild);
String noPrefix = msg.getContentRaw().substring(prefix.length());
if (!noPrefix.contains(" ")) return new String[]{};
return noPrefix.substring(noPrefix.indexOf(" ") + 1).split("\\s+");
}
}

View File

@ -0,0 +1,46 @@
package xyz.sheepstar.wrapper.util.api.economy;
import net.dv8tion.jda.api.entities.Guild;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class EconomyManager {
public boolean isRegistered(Guild guild) {
return Main.getDB().getResult("SELECT * FROM guild_economy WHERE guildID=?", guild.getId()).getRowCount() == 1;
}
public void register(Guild guild) {
if (isRegistered(guild)) return;
Main.getDB().update("INSERT INTO guild_economy (guildID, money) VALUES (?, '100')", guild.getId());
}
public void increase(Guild guild, String addMoney) {
if (!isRegistered(guild)) register(guild);
Main.getDB().update("UPDATE guild_economy SET money=money+? WHERE guildID=?", addMoney, guild.getId());
}
public void decrease(Guild guild, String removeMoney) {
if (!isRegistered(guild)) register(guild);
Main.getDB().update("UPDATE guild_economy SET money=money-? WHERE guildID=?", removeMoney, guild.getId());
}
public void set(Guild guild, String newMoney) {
if (!isRegistered(guild)) register(guild);
Main.getDB().update("UPDATE guild_economy SET money=? WHERE guildID=?", newMoney, guild.getId());
}
public String get(Guild guild) {
if (!isRegistered(guild)) register(guild);
return Main.getDB().getResult("SELECT * FROM guild_economy WHERE guildID=?", guild.getId()).getString("money");
}
public long getLong(Guild guild) {
if (!isRegistered(guild)) register(guild);
return Long.parseLong(get(guild));
}
}

View File

@ -0,0 +1,41 @@
package xyz.sheepstar.wrapper.util.api.economy;
import net.dv8tion.jda.api.entities.Guild;
import xyz.sheepstar.wrapper.util.api.sql.StorageMedium;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class ShopManager {
private EconomyManager em;
private Guild guild;
private StorageMedium sm;
public ShopManager(EconomyManager em, Guild guild) {
this.em = em;
this.guild = guild;
this.sm = new StorageMedium(guild, "purchased_items");
}
public void buyItem(String price, String itemName, boolean checkAlready) {
if (checkAlready && hasItem(itemName)) return;
if (Integer.parseInt(em.get(guild)) >= Integer.parseInt(price)) {
// if (item.equals("premium")) { Main.getGlobalManager().setPremium(guild);return; }
sm.inUpdate(itemName, String.valueOf(getItemCount(itemName)+1));
em.decrease(guild, price);
}
}
public boolean hasItem(String itemName) {
return sm.exists(itemName);
}
public int getItemCount(String itemName) {
return Integer.parseInt(String.valueOf(sm.getValue(itemName)));
}
}

View File

@ -0,0 +1,24 @@
package xyz.sheepstar.wrapper.util.api.http;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import xyz.sheepstar.wrapper.core.Main;
import java.io.IOException;
import java.io.OutputStream;
/********************************
* @author Mathias Wagner
* Created 29.01.2021
********************************/
public class StatusHandler implements HttpHandler {
@Override
public void handle(HttpExchange t) throws IOException {
String res = "{\"status\":\""+Main.getJDA().getStatus().name()+"\",\"init\":\""+Main.getJDA().getStatus().isInit()+"\"}";
t.sendResponseHeaders(200, res.length());
OutputStream os = t.getResponseBody();
os.write(res.getBytes());
os.close();
}
}

View File

@ -0,0 +1,23 @@
package xyz.sheepstar.wrapper.util.api.http;
import com.sun.net.httpserver.HttpServer;
import java.net.InetSocketAddress;
/********************************
* @author Mathias Wagner
* Created 29.01.2021
********************************/
public class WebServer extends Thread {
@Override
public void run() {
try {
HttpServer server = HttpServer.create(new InetSocketAddress(7279), 0);
server.createContext("/getStatus", new StatusHandler());
server.setExecutor(null);
server.start();
} catch (Exception ignored) {}
}
}

View File

@ -0,0 +1,19 @@
package xyz.sheepstar.wrapper.util.api.listener;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.hooks.ListenerAdapter;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.GuildEssentials;
import xyz.sheepstar.wrapper.util.api.module.ModuleManager;
/********************************
* @author Mathias Wagner
* Created 27.01.2021
********************************/
public abstract class GuildListener extends GuildEssentials {
}

View File

@ -0,0 +1,47 @@
package xyz.sheepstar.wrapper.util.api.module;
import net.dv8tion.jda.api.entities.Guild;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 24.01.2021
********************************/
public class ModuleManager {
public boolean isEnabled(String guildID, String module) {
return Main.getDB()
.getResult("SELECT * FROM enabled_modules WHERE guildID=? AND name=?", guildID, module)
.getRowCount() == 1;
}
public boolean isEnabled(Guild guild, String module) {
return isEnabled(guild.getId(), module);
}
public boolean exists(String module) {
return Main.getDB().getResult("SELECT * FROM existing_modules WHERE name=?", module).getRowCount() == 1;
}
public boolean usedWhereOther(Guild guild, String prefix) {
return Main.getDB().getResult("SELECT * FROM enabled_modules WHERE guildiD=? AND prefix=?", guild.getId(), prefix)
.getRowCount() == 1;
}
public void disable(Guild guild, String module) {
if (!isEnabled(guild, module)) return;
Main.getDB().update("DELETE FROM enabled_modules WHERE name=? AND guildID=?", module, guild.getId());
}
public void enable(Guild guild, String module, String prefix) {
if (isEnabled(guild, module)) return;
Main.getDB().update("INSERT INTO enabled_modules (name, guildID, prefix) VALUES (?, ?, ?)", module, guild.getId(), prefix);
}
public String getPrefix(Guild guild, String module) {
if (!isEnabled(guild, module)) return "";
return Main.getDB().getResult("SELECT * FROM enabled_modules WHERE guildID=? AND name=?", guild.getId(), module).getString("prefix");
}
}

View File

@ -0,0 +1,17 @@
package xyz.sheepstar.wrapper.util.api.module;
import net.dv8tion.jda.api.JDA;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 22.01.2021
********************************/
public abstract class SheepstarModule {
public JDA jda = Main.getJDA();
public abstract void init() throws Exception;
}

View File

@ -0,0 +1,15 @@
package xyz.sheepstar.wrapper.util.api.permission;
/********************************
* @author Mathias Wagner
* Created 24.01.2021
********************************/
public enum PermissionNode {
ADMINISTRATOR,
SUPPORTER,
BOT_OWNER,
UNKNOWN;
}

View File

@ -0,0 +1,27 @@
package xyz.sheepstar.wrapper.util.api.settings;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.entities.Guild;
import xyz.sheepstar.wrapper.core.Main;
import xyz.sheepstar.wrapper.util.api.sql.StorageMedium;
/********************************
* @author Mathias Wagner
* Created 13.02.2021
********************************/
public class SettingsManager {
public void update(Guild guild, String key, String value) {
getStorage(guild).inUpdate(key, value);
}
public String get(Guild guild, String key) {
return String.valueOf(getStorage(guild).getValue(key));
}
private StorageMedium getStorage(Guild guild) {
return new StorageMedium(guild, "settings");
}
}

View File

@ -0,0 +1,101 @@
package xyz.sheepstar.wrapper.util.api.sql;
import drivers.MySQLConnection;
import fields.SQLField;
import generator.TableGenerator;
import net.dv8tion.jda.api.entities.Guild;
import types.SQLType;
import xyz.sheepstar.wrapper.core.Main;
/********************************
* @author Mathias Wagner
* Created 07.02.2021
********************************/
public class StorageMedium {
private Guild guild;
private String tableName;
public StorageMedium(Guild guild, String tableName) {
this.guild = guild;
this.tableName = tableName;
this.createTable();
}
public StorageMedium(String tableName) {
this.tableName = tableName;
this.createTable();
}
private void createTable() {
TableGenerator tg = Main.getDB().updateTable(tableName).generateTable().useID();
if (this.guild != null) tg.addField(new SQLField(SQLType.STRING, "guildID", 255));
tg.addField(new SQLField(SQLType.STRING, "keyName", 255))
.addField(new SQLField(SQLType.STRING, "value", 255))
.create();
}
public boolean exists(String key) {
return this.guild != null ?
Main.getDB().selectFrom(this.tableName).where("keyName", key).where("guildID", guild.getId()).getResult().getRowCount() != 0
: Main.getDB().selectFrom(this.tableName).where("keyName", key).getResult().getRowCount() != 0;
}
public boolean existsValue(String value) {
return this.guild != null ?
Main.getDB().selectFrom(this.tableName).where("value", value).where("guildID", guild.getId()).getResult().getRowCount() != 0
: Main.getDB().selectFrom(this.tableName).where("value", value).getResult().getRowCount() != 0;
}
public void insert(String key, Object value) {
if (this.guild != null) {
Main.getDB().update("INSERT INTO " + this.tableName + " (guildID, keyName, value) VALUES (?, ?, ?)", guild.getId(), key, value + "");
} else {
Main.getDB().update("INSERT INTO " + this.tableName + " (keyName, value) VALUES (?, ?)", key, value + "");
}
}
public void delete(String key) {
if (this.guild != null) {
Main.getDB().updateTable(this.tableName).where("keyName", key).where("guildID", this.guild.getId()).delete();
} else {
Main.getDB().updateTable(this.tableName).where("keyName", key).delete();
}
}
public void deleteValue(String value) {
if (this.guild != null) {
Main.getDB().updateTable(this.tableName).where("value", value).where("guildID", this.guild.getId()).delete();
} else {
Main.getDB().updateTable(this.tableName).where("value", value).delete();
}
}
public void update(String key, String newValue) {
if (this.guild != null) {
Main.getDB().update("UPDATE " + this.tableName + " SET value=? WHERE guildID=? AND keyName=?", newValue, guild.getId(), key);
} else {
Main.getDB().update("UPDATE " + this.tableName + " SET value=? WHERE keyName=?", key);
}
}
public void inUpdate(String key, String newValue) {
if (exists(key)) update(key, newValue); else insert(key, newValue);
}
public Object getValue(String key) {
if (!exists(key)) return "0";
return (guild != null) ? Main.getDB().selectFrom(this.tableName).where("keyName", key).where("guildID", guild.getId()).getResult().getObject("value")
: Main.getDB().selectFrom(this.tableName).where("keyName", key).getResult().getObject("value");
}
public int getCount(String key) {
return this.guild != null ?
Main.getDB().selectFrom(this.tableName).where("keyName", key).where("guildID", guild.getId()).getResult().getRowCount()
: Main.getDB().selectFrom(this.tableName).where("keyName", key).getResult().getRowCount();
}
}