Added addRoles/removeRoles command, added UserData structure.
This commit is contained in:
parent
151b367c88
commit
d3f37ae2ac
@ -9,7 +9,7 @@
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="Gradle: net.dv8tion:JDA:3.1.1_223" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.dv8tion:JDA:3.1.1_215" level="project" />
|
||||
<orderEntry type="library" name="Gradle: mysql:mysql-connector-java:5.1.38" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.sedmelluq:lavaplayer:1.2.42" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-stream:4.0.6" level="project" />
|
||||
@ -19,8 +19,8 @@
|
||||
<orderEntry type="library" name="Gradle: org.json:json:20160810" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.java.dev.jna:jna:4.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.neovisionaries:nv-websocket-client:2.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.neovisionaries:nv-websocket-client:2.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.mashape.unirest:unirest-java:1.4.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.sedmelluq:lavaplayer-common:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.22" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
|
||||
@ -29,11 +29,13 @@
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.8.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.10.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.iharder:base64:2.3.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.13.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpasyncclient:4.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore-nio:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.6" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -10,7 +10,7 @@
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="module" module-name="Rixa_main" />
|
||||
<orderEntry type="library" name="Gradle: net.dv8tion:JDA:3.1.1_223" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.dv8tion:JDA:3.1.1_215" level="project" />
|
||||
<orderEntry type="library" name="Gradle: mysql:mysql-connector-java:5.1.38" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.sedmelluq:lavaplayer:1.2.42" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-stream:4.0.6" level="project" />
|
||||
@ -20,8 +20,8 @@
|
||||
<orderEntry type="library" name="Gradle: org.json:json:20160810" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.java.dev.jna:jna:4.4.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.neovisionaries:nv-websocket-client:2.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.neovisionaries:nv-websocket-client:2.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.mashape.unirest:unirest-java:1.4.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.sedmelluq:lavaplayer-common:1.0.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.slf4j:slf4j-api:1.7.22" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpclient:4.5.2" level="project" />
|
||||
@ -30,11 +30,13 @@
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-databind:2.8.5" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.jsoup:jsoup:1.10.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: net.iharder:base64:2.3.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.squareup.okio:okio:1.13.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpasyncclient:4.1.1" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpmime:4.5.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: commons-logging:commons-logging:1.2" level="project" />
|
||||
<orderEntry type="library" name="Gradle: commons-codec:commons-codec:1.9" level="project" />
|
||||
<orderEntry type="library" name="Gradle: com.fasterxml.jackson.core:jackson-annotations:2.8.0" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.apache.httpcomponents:httpcore-nio:4.4.4" level="project" />
|
||||
<orderEntry type="library" name="Gradle: org.twitter4j:twitter4j-core:4.0.6" level="project" />
|
||||
</component>
|
||||
<component name="TestModuleProperties" production-module="Rixa_main" />
|
||||
|
@ -2,8 +2,8 @@
|
||||
<project version="4">
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="d884bc5a-63a1-4e03-b68b-617ebe9b8e2a" name="Default" comment="">
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/twitter/TwitterModule.java" afterPath="$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/twitter/TwitterModule.java" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
|
||||
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/twitter/TwitterModule.java" afterPath="$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/twitter/TwitterModule.java" />
|
||||
</list>
|
||||
<ignored path="Rixa.iws" />
|
||||
<ignored path=".idea/workspace.xml" />
|
||||
@ -41,28 +41,7 @@
|
||||
<favorites_list name="Rixa" />
|
||||
</component>
|
||||
<component name="FileEditorManager">
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="375">
|
||||
<file leaf-file-name=".gitignore" pinned="false" current-in-tab="false">
|
||||
<entry file="file://$PROJECT_DIR$/.gitignore">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="0">
|
||||
<caret line="0" column="0" lean-forward="false" selection-start-line="0" selection-start-column="0" selection-end-line="0" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
<file leaf-file-name="build.gradle" pinned="false" current-in-tab="true">
|
||||
<entry file="file://$PROJECT_DIR$/build.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="545">
|
||||
<caret line="33" column="0" lean-forward="true" selection-start-line="33" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</file>
|
||||
</leaf>
|
||||
<leaf SIDE_TABS_SIZE_LIMIT_KEY="375" />
|
||||
</component>
|
||||
<component name="FileTemplateManagerImpl">
|
||||
<option name="RECENT_TEMPLATES">
|
||||
@ -346,8 +325,8 @@
|
||||
</option>
|
||||
<option name="modificationStamps">
|
||||
<map>
|
||||
<entry key="$PROJECT_DIR$" value="4491037036015" />
|
||||
<entry key="$PROJECT_DIR$/build.gradle" value="1641097090" />
|
||||
<entry key="$PROJECT_DIR$" value="4491037440387" />
|
||||
<entry key="$PROJECT_DIR$/build.gradle" value="4040259557" />
|
||||
<entry key="$PROJECT_DIR$/../../Rixa" value="2973686032224" />
|
||||
</map>
|
||||
</option>
|
||||
@ -529,10 +508,6 @@
|
||||
<component name="IdeDocumentHistory">
|
||||
<option name="CHANGED_PATHS">
|
||||
<list>
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/placeholder/PlaceHolder.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/LanguageManager.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/database/DataType.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/thunderbolt/io/ThunderFile.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/permissions/Permission.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/handlers/RixaPermission.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/audio/AudioReceiveHandleer.java" />
|
||||
@ -559,7 +534,6 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/utils/WebUtil.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/general/UrbanDictionaryCommand.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/general/YoutubeCommand.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/locale/Language.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/twitter/TwitterModule.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/guild/RixaManager.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/general/MusicCommand.java" />
|
||||
@ -578,8 +552,13 @@
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/mod/MuteCommand.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/guild/RixaGuild.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/ConfigManager.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/Rixa.java" />
|
||||
<option value="$PROJECT_DIR$/build.gradle" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/LanguageManager.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/locale/Language.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/admin/AddRoleCommand.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/admin/RemoveRoleCommand.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/Rixa.java" />
|
||||
<option value="$PROJECT_DIR$/src/main/java/me/savvy/rixa/guild/user/UserData.java" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
@ -616,7 +595,7 @@
|
||||
<foldersAlwaysOnTop value="true" />
|
||||
</navigator>
|
||||
<panes>
|
||||
<pane id="PackagesPane" />
|
||||
<pane id="Scope" />
|
||||
<pane id="ProjectPane">
|
||||
<subPane>
|
||||
<PATH>
|
||||
@ -736,7 +715,7 @@
|
||||
</subPane>
|
||||
</pane>
|
||||
<pane id="Scratches" />
|
||||
<pane id="Scope" />
|
||||
<pane id="PackagesPane" />
|
||||
</panes>
|
||||
</component>
|
||||
<component name="PropertiesComponent">
|
||||
@ -751,10 +730,10 @@
|
||||
<property name="ChangesBrowser.SHOW_FLATTEN" value="false" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\modules\music" />
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\locale\manager" />
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa" />
|
||||
<key name="CreateClassDialog.RecentsKey">
|
||||
<recent name="me.savvy.rixa.data.database" />
|
||||
<recent name="me.savvy.rixa.utils" />
|
||||
<recent name="me.savvy.rixa.commands.handlers" />
|
||||
</key>
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\modules\music" />
|
||||
@ -762,10 +741,13 @@
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\enums" />
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\database" />
|
||||
</key>
|
||||
<key name="CreateClassDialog.RecentsKey">
|
||||
<recent name="me.savvy.rixa.data.database" />
|
||||
<recent name="me.savvy.rixa.utils" />
|
||||
<recent name="me.savvy.rixa.commands.handlers" />
|
||||
<key name="CopyClassDialog.RECENTS_KEY">
|
||||
<recent name="me.savvy.rixa.commands.admin" />
|
||||
</key>
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\modules\music" />
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa\src\main\java\me\savvy\rixa\locale\manager" />
|
||||
<recent name="C:\Users\Timber\Documents\intellij-workspace\Rixa" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunDashboard">
|
||||
@ -1115,18 +1097,17 @@
|
||||
<window_info id="Palette	" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33403805" sideWeight="0.51875" order="7" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Maven Projects" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32941177" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.63424945" sideWeight="0.49573562" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="true" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33403805" sideWeight="0.48125" order="9" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="10" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Terminal" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.33403805" sideWeight="0.48125" order="9" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Designer" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23958333" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32980973" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Project" active="true" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" show_stripe_button="true" weight="0.23958333" sideWeight="0.5" order="0" side_tool="false" content_ui="combo" />
|
||||
<window_info id="Gradle" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Ant Build" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="UI Designer" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="true" content_ui="tabs" />
|
||||
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Nl-Palette" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Message" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="0" side_tool="false" content_ui="tabs" />
|
||||
@ -1140,6 +1121,7 @@
|
||||
<window_info id="Capture Analysis" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="8" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Inspection" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.4" sideWeight="0.5" order="5" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Floobits" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Find" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.32980973" sideWeight="0.5" order="1" side_tool="false" content_ui="tabs" />
|
||||
<window_info id="Theme Preview" active="false" anchor="right" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" show_stripe_button="true" weight="0.33" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
|
||||
</layout>
|
||||
<layout-to-restore>
|
||||
@ -1193,28 +1175,6 @@
|
||||
<option name="FILTER_TARGETS" value="false" />
|
||||
</component>
|
||||
<component name="editorHistoryManager">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/reactions/handlers/ReactRegistrar.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="7" column="13" lean-forward="false" selection-start-line="7" selection-start-column="13" selection-end-line="7" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/modules/ccommands.java" />
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/action/ActionManager.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="21" column="5" lean-forward="false" selection-start-line="21" selection-start-column="5" selection-end-line="21" selection-end-column="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/action/actions/MessageResponse.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="9" column="13" lean-forward="false" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/action/Action.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
@ -1315,13 +1275,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/general/YoutubeCommand.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="374">
|
||||
<caret line="31" column="5" lean-forward="true" selection-start-line="31" selection-start-column="5" selection-end-line="31" selection-end-column="5" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/enums/Result.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
@ -1329,13 +1282,6 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/locale/Language.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="136">
|
||||
<caret line="8" column="83" lean-forward="false" selection-start-line="8" selection-start-column="83" selection-end-line="8" selection-end-column="83" />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/handlers/CommandType.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
@ -1347,7 +1293,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="375">
|
||||
<caret line="28" column="25" lean-forward="false" selection-start-line="28" selection-start-column="25" selection-end-line="28" selection-end-column="25" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1362,7 +1307,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="102">
|
||||
<caret line="22" column="13" lean-forward="false" selection-start-line="22" selection-start-column="13" selection-end-line="22" selection-end-column="13" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1370,9 +1314,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="391">
|
||||
<caret line="23" column="0" lean-forward="false" selection-start-line="23" selection-start-column="0" selection-end-line="23" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1380,7 +1321,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="473">
|
||||
<caret line="118" column="16" lean-forward="false" selection-start-line="118" selection-start-column="16" selection-end-line="119" selection-end-column="63" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1388,15 +1328,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="374">
|
||||
<caret line="56" column="33" lean-forward="false" selection-start-line="56" selection-start-column="33" selection-end-line="56" selection-end-column="33" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/admin/BatchMoveCommand.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="203">
|
||||
<caret line="28" column="40" lean-forward="false" selection-start-line="28" selection-start-column="40" selection-end-line="28" selection-end-column="40" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1404,10 +1335,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="635">
|
||||
<caret line="191" column="27" lean-forward="false" selection-start-line="191" selection-start-column="27" selection-end-line="191" selection-end-column="27" />
|
||||
<folding>
|
||||
<marker date="1500025973768" expanded="false" signature="18904:18915" ph=" { " />
|
||||
<marker date="1500025973768" expanded="false" signature="18931:18937" ph=" }" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1415,7 +1342,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="203">
|
||||
<caret line="23" column="39" lean-forward="false" selection-start-line="23" selection-start-column="39" selection-end-line="23" selection-end-column="39" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1423,10 +1349,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="646">
|
||||
<caret line="40" column="67" lean-forward="false" selection-start-line="40" selection-start-column="67" selection-end-line="40" selection-end-column="67" />
|
||||
<folding>
|
||||
<element signature="e#1646#1647#0" expanded="false" />
|
||||
<element signature="e#1677#1678#0" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1434,9 +1356,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="198">
|
||||
<caret line="60" column="48" lean-forward="false" selection-start-line="60" selection-start-column="48" selection-end-line="60" selection-end-column="48" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="false" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1444,7 +1363,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="408">
|
||||
<caret line="37" column="39" lean-forward="false" selection-start-line="37" selection-start-column="39" selection-end-line="37" selection-end-column="39" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1452,7 +1370,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="203">
|
||||
<caret line="24" column="39" lean-forward="false" selection-start-line="24" selection-start-column="39" selection-end-line="24" selection-end-column="39" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1471,7 +1388,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-159">
|
||||
<caret line="34" column="39" lean-forward="false" selection-start-line="34" selection-start-column="39" selection-end-line="34" selection-end-column="39" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1479,7 +1395,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="9" column="13" lean-forward="false" selection-start-line="9" selection-start-column="13" selection-end-line="9" selection-end-column="13" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1487,7 +1402,6 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="31" column="39" lean-forward="false" selection-start-line="31" selection-start-column="39" selection-end-line="31" selection-end-column="39" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1495,23 +1409,14 @@
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="147">
|
||||
<caret line="28" column="39" lean-forward="false" selection-start-line="28" selection-start-column="39" selection-end-line="28" selection-end-column="39" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/guild/RixaManager.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="119">
|
||||
<caret line="10" column="26" lean-forward="false" selection-start-line="10" selection-start-column="26" selection-end-line="10" selection-end-column="26" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/guild/RixaManager.java" />
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/utils/YoutubeSearch.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-57">
|
||||
<caret line="13" column="13" lean-forward="false" selection-start-line="13" selection-start-column="13" selection-end-line="13" selection-end-column="13" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
@ -1531,28 +1436,10 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/ConfigManager.java">
|
||||
<entry file="file://$PROJECT_DIR$/build.gradle">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="188">
|
||||
<caret line="27" column="46" lean-forward="false" selection-start-line="27" selection-start-column="46" selection-end-line="27" selection-end-column="46" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/LanguageManager.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="273">
|
||||
<caret line="23" column="9" lean-forward="false" selection-start-line="23" selection-start-column="9" selection-end-line="23" selection-end-column="9" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/Rixa.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="-340">
|
||||
<caret line="59" column="16" lean-forward="false" selection-start-line="59" selection-start-column="16" selection-end-line="59" selection-end-column="16" />
|
||||
<state relative-caret-position="460">
|
||||
<caret line="33" column="0" lean-forward="false" selection-start-line="33" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
@ -1565,14 +1452,92 @@
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/build.gradle">
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/LanguageManager.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="545">
|
||||
<caret line="33" column="0" lean-forward="true" selection-start-line="33" selection-start-column="0" selection-end-line="33" selection-end-column="0" />
|
||||
<state relative-caret-position="663">
|
||||
<caret line="54" column="3" lean-forward="false" selection-start-line="54" selection-start-column="3" selection-end-line="54" selection-end-column="3" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/filemanager/ConfigManager.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="86">
|
||||
<caret line="15" column="13" lean-forward="false" selection-start-line="16" selection-start-column="0" selection-end-line="71" selection-end-column="0" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/placeholder/PlaceHolder.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="85">
|
||||
<caret line="5" column="13" lean-forward="false" selection-start-line="5" selection-start-column="13" selection-end-line="5" selection-end-column="13" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/general/YoutubeCommand.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="408">
|
||||
<caret line="31" column="5" lean-forward="true" selection-start-line="31" selection-start-column="5" selection-end-line="31" selection-end-column="5" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/admin/BatchMoveCommand.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="220">
|
||||
<caret line="29" column="7" lean-forward="false" selection-start-line="29" selection-start-column="7" selection-end-line="29" selection-end-column="181" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/admin/AddRoleCommand.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="52">
|
||||
<caret line="26" column="36" lean-forward="false" selection-start-line="26" selection-start-column="36" selection-end-line="26" selection-end-column="36" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/commands/admin/RemoveRoleCommand.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="306">
|
||||
<caret line="39" column="17" lean-forward="true" selection-start-line="39" selection-start-column="17" selection-end-line="39" selection-end-column="17" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/Rixa.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="171">
|
||||
<caret line="104" column="61" lean-forward="false" selection-start-line="104" selection-start-column="61" selection-end-line="104" selection-end-column="61" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/data/locale/Language.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="204">
|
||||
<caret line="12" column="11" lean-forward="false" selection-start-line="12" selection-start-column="11" selection-end-line="12" selection-end-column="11" />
|
||||
<folding />
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
<entry file="file://$PROJECT_DIR$/src/main/java/me/savvy/rixa/guild/user/UserData.java">
|
||||
<provider selected="true" editor-type-id="text-editor">
|
||||
<state relative-caret-position="272">
|
||||
<caret line="16" column="19" lean-forward="false" selection-start-line="16" selection-start-column="19" selection-end-line="16" selection-end-column="19" />
|
||||
<folding>
|
||||
<element signature="imports" expanded="true" />
|
||||
<element signature="e#506#507#0" expanded="true" />
|
||||
<element signature="e#538#539#0" expanded="true" />
|
||||
</folding>
|
||||
</state>
|
||||
</provider>
|
||||
</entry>
|
||||
</component>
|
||||
<component name="masterDetails">
|
||||
<states>
|
||||
|
@ -2,9 +2,7 @@ package me.savvy.rixa;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.savvy.rixa.commands.admin.BatchMoveCommand;
|
||||
import me.savvy.rixa.commands.admin.ConfigCommand;
|
||||
import me.savvy.rixa.commands.admin.InviteCommand;
|
||||
import me.savvy.rixa.commands.admin.*;
|
||||
import me.savvy.rixa.commands.general.*;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandHandler;
|
||||
@ -75,7 +73,7 @@ public class Rixa {
|
||||
String.valueOf(config.getJsonObject().getJSONObject("sql").getString("userName")),
|
||||
String.valueOf(config.getJsonObject().getJSONObject("sql").getString("password")));
|
||||
dbManager.createTable();
|
||||
getInstance().setLanguageManager(new LanguageManager());
|
||||
getInstance().setLanguageManager(new LanguageManager(new File("Rixa/languages/language.json")));
|
||||
try {
|
||||
int shards = 5;
|
||||
for(int i = 0; i < shards; i++) {
|
||||
@ -103,7 +101,8 @@ public class Rixa {
|
||||
new InfoCommand(), new ServerInfoCommand(), new HelpCommand(),
|
||||
new DeleteMessagesCommand(), new PingCommand(), new PurgeMessagesCommand(),
|
||||
new BatchMoveCommand(), new MuteCommand(), new MusicCommand(),
|
||||
new ConfigCommand(), new UrbanDictionaryCommand(), new YoutubeCommand()});
|
||||
new ConfigCommand(), new UrbanDictionaryCommand(), new YoutubeCommand(),
|
||||
new AddRoleCommand(), new RemoveRoleCommand()});
|
||||
register(new React[] {new HelpReaction(), new ConfigReaction()});
|
||||
data = new Data(DataType.SQL);
|
||||
}
|
||||
|
@ -0,0 +1,55 @@
|
||||
package me.savvy.rixa.commands.admin;
|
||||
|
||||
import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Role;
|
||||
import net.dv8tion.jda.core.entities.TextChannel;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
import net.dv8tion.jda.core.managers.GuildManager;
|
||||
import net.dv8tion.jda.core.requests.restaction.InviteAction;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by savit on 7/7/2017.
|
||||
*/
|
||||
public class AddRoleCommand implements CommandExec {
|
||||
|
||||
@Command(
|
||||
description = "Give a user a role",
|
||||
type = CommandType.ADMIN,
|
||||
channelType = ChannelType.TEXT,
|
||||
usage = "%paddrole", mainCommand = "addrole", aliases = {"ar", "addroles", "ars"})
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.ADD_ROLE)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
String[] messages = event.getMessage().getContent().split(" ");
|
||||
if (messages.length >= 3) {
|
||||
if(event.getMessage().getMentionedRoles().size() < 1 ||
|
||||
event.getMessage().getMentionedUsers().size() < 1) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + messages[0] + " <role> <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<Role> roles = event.getMessage().getMentionedRoles();
|
||||
User user = event.getMessage().getMentionedUsers().get(0);
|
||||
event.getGuild().getController().addRolesToMember(event.getGuild().getMember(user), roles).queue();
|
||||
new MessageBuilder("Successfully given " + user.getAsMention() + " `" + roles.size() + "` role(s)").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} catch (PermissionException ex) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", sorry I do not have permission for this!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
} else {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + messages[0] + " <role> <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package me.savvy.rixa.commands.admin;
|
||||
|
||||
import me.savvy.rixa.commands.handlers.Command;
|
||||
import me.savvy.rixa.commands.handlers.CommandExec;
|
||||
import me.savvy.rixa.commands.handlers.CommandType;
|
||||
import me.savvy.rixa.commands.handlers.RixaPermission;
|
||||
import me.savvy.rixa.guild.RixaGuild;
|
||||
import me.savvy.rixa.utils.MessageBuilder;
|
||||
import net.dv8tion.jda.core.entities.ChannelType;
|
||||
import net.dv8tion.jda.core.entities.Role;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
import net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent;
|
||||
import net.dv8tion.jda.core.exceptions.PermissionException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by savit on 7/7/2017.
|
||||
*/
|
||||
public class RemoveRoleCommand implements CommandExec {
|
||||
|
||||
@Command(
|
||||
description = "Remove a user's role",
|
||||
type = CommandType.ADMIN,
|
||||
channelType = ChannelType.TEXT,
|
||||
usage = "%premoverole", mainCommand = "removerole", aliases = {"rr", "removeroles"})
|
||||
public void execute(GuildMessageReceivedEvent event) {
|
||||
RixaGuild rixaGuild = RixaGuild.getGuild(event.getGuild());
|
||||
if(!rixaGuild.hasPermission(event.getMember(), RixaPermission.REMOVE_ROLE)) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", you do not have permission for this command.").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
String[] messages = event.getMessage().getContent().split(" ");
|
||||
if (messages.length >= 3) {
|
||||
if(event.getMessage().getMentionedRoles().size() < 1 ||
|
||||
event.getMessage().getMentionedUsers().size() < 1) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + messages[0] + " <role> <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
return;
|
||||
}
|
||||
try {
|
||||
List<Role> roles = event.getMessage().getMentionedRoles();
|
||||
User user = event.getMessage().getMentionedUsers().get(0);
|
||||
event.getGuild().getController().removeRolesFromMember(event.getGuild().getMember(user), roles).queue();
|
||||
new MessageBuilder("Successfully removed `" + roles.size() + "` role(s) from " + user.getAsMention() + "!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
} catch (PermissionException ex) {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", sorry I do not have permission for this!").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
} else {
|
||||
new MessageBuilder(event.getMember().getAsMention() + ", incorrect usage try [" + messages[0] + " <role> <user>].").setColor(event.getMember().getColor()).queue(event.getChannel());
|
||||
}
|
||||
}
|
||||
}
|
@ -1,37 +1,64 @@
|
||||
package me.savvy.rixa.data.filemanager;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.savvy.rixa.data.locale.Language;
|
||||
import me.savvy.rixa.data.thunderbolt.Thunderbolt;
|
||||
import me.savvy.rixa.data.thunderbolt.exceptions.FileLoadException;
|
||||
import me.savvy.rixa.data.thunderbolt.io.ThunderFile;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Created by Timber on 5/31/2017.
|
||||
*/
|
||||
public class LanguageManager {
|
||||
private ThunderFile tf;
|
||||
public LanguageManager() {
|
||||
tf = null;
|
||||
|
||||
@Getter
|
||||
private File file;
|
||||
@Getter
|
||||
private JSONObject jsonObject;
|
||||
|
||||
public LanguageManager(File file) {
|
||||
this.file = file;
|
||||
if (!(file.exists())) {
|
||||
FileWriter fileWriter = null;
|
||||
try {
|
||||
if(!Thunderbolt.load("language", "Rixa/language")) {
|
||||
tf = Thunderbolt.get("language");
|
||||
addDefaults();
|
||||
file.getParentFile().mkdirs();
|
||||
file.createNewFile();
|
||||
jsonObject = new JSONObject();
|
||||
|
||||
for(Language language: Language.values()) {
|
||||
jsonObject.put(language.getKey(), language.getDefaultValue());
|
||||
}
|
||||
} catch (FileLoadException | IOException e) {
|
||||
fileWriter = new FileWriter(file);
|
||||
fileWriter.write(jsonObject.toString());
|
||||
System.out.println("Successfully generated language file.");
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
} finally {
|
||||
if(fileWriter != null) {
|
||||
try {
|
||||
fileWriter.flush();
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public ThunderFile getLanguage() {
|
||||
return tf;
|
||||
}
|
||||
|
||||
private void addDefaults() throws IOException {
|
||||
for(Language language: Language.values()) {
|
||||
tf.set(language.getKey(), language.getDefaultValue());
|
||||
return;
|
||||
}
|
||||
tf.save();
|
||||
String jsonTxt = null;
|
||||
try {
|
||||
jsonTxt = IOUtils.toString(new FileReader(file));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
jsonObject = new JSONObject(jsonTxt);
|
||||
}
|
||||
}
|
||||
|
@ -1,165 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt;
|
||||
|
||||
import me.savvy.rixa.data.thunderbolt.exceptions.FileLoadException;
|
||||
import me.savvy.rixa.data.thunderbolt.io.ThunderFile;
|
||||
import me.savvy.rixa.data.thunderbolt.io.ThunderboltThreadPool;
|
||||
import me.savvy.rixa.data.thunderbolt.utils.Validator;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public abstract class Thunderbolt {
|
||||
|
||||
private final static Map<String, ThunderFile> fileMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Get a file by its name. Doesn't require .json extension. This method is thread-safe
|
||||
*
|
||||
* <p>This method returns null if the file is not loaded</p>
|
||||
*
|
||||
* @param name : The name of the file to get.
|
||||
*/
|
||||
public static ThunderFile get(String name) {
|
||||
name = Validator.checkName(name);
|
||||
|
||||
synchronized (fileMap) {
|
||||
return fileMap.get(name);
|
||||
}
|
||||
}
|
||||
|
||||
private static ThunderFile create(String name, String path) throws FileLoadException {
|
||||
name = Validator.checkName(name);
|
||||
|
||||
synchronized (fileMap) {
|
||||
if (!fileMap.containsKey(name)) {
|
||||
ThunderFile tf = new ThunderFile(name, path);
|
||||
fileMap.put(name, tf);
|
||||
|
||||
return tf;
|
||||
} else {
|
||||
throw new FileLoadException(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a file into memory.
|
||||
* <p>
|
||||
* NOTE: Make sure to call {@link Thunderbolt#unload(String)} when you're done using this file,
|
||||
* otherwise a memory leak may occur!
|
||||
*
|
||||
* @param name : The name of the file to load.
|
||||
* @param path : The path to the file.
|
||||
* @throws IOException
|
||||
* @throws FileLoadException
|
||||
*/
|
||||
public static boolean load(String name, String path) throws FileLoadException, IOException {
|
||||
name = Validator.checkName(name);
|
||||
|
||||
boolean contains;
|
||||
synchronized (fileMap) {
|
||||
contains = fileMap.containsKey(name);
|
||||
}
|
||||
|
||||
if (!contains) {
|
||||
File f = new File(path + File.separator + name + ".json");
|
||||
if (f.exists()) {
|
||||
ThunderFile tf;
|
||||
if (f.length() != 0) {
|
||||
final String s1 = name;
|
||||
final String s2 = path;
|
||||
Callable<byte[]> c = () -> Files.readAllBytes(Paths.get(s2 + File.separator + s1 + ".json"));
|
||||
try {
|
||||
tf = new ThunderFile(name, path, new String(ThunderboltThreadPool.getPool().submit(c).get()));
|
||||
} catch(InterruptedException | ExecutionException e) {
|
||||
tf = new ThunderFile(name, path);
|
||||
System.out.println("[Thunderbolt] Error loading '" + name + ".json'. Please check for errors and try again.");
|
||||
}
|
||||
} else {
|
||||
tf = new ThunderFile(name, path);
|
||||
}
|
||||
fileMap.put(name, tf);
|
||||
return true;
|
||||
} else {
|
||||
create(name, path);
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
throw new FileLoadException(name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unload a file from memory.
|
||||
*
|
||||
* @param name : The name of the file to unload
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static void unload(String name) {
|
||||
name = Validator.checkName(name);
|
||||
|
||||
ThunderFile file;
|
||||
synchronized (fileMap) {
|
||||
file = fileMap.remove(name);
|
||||
}
|
||||
|
||||
if (file == null) {
|
||||
new FileNotFoundException("[Thunderbolt] The file '" + name + ".json' isn't loaded and/or doesn't exist.")
|
||||
.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file and remove it from memory.
|
||||
*
|
||||
* @param name : The name of the file to delete
|
||||
* @throws IOException
|
||||
*/
|
||||
public static void delete(String name) {
|
||||
name = Validator.checkName(name);
|
||||
|
||||
ThunderFile tf;
|
||||
synchronized (fileMap) {
|
||||
tf = fileMap.remove(name);
|
||||
}
|
||||
|
||||
if (tf == null) {
|
||||
new FileNotFoundException("[Thunderbolt] The file '" + name + ".json' isn't loaded and/or doesn't exist.")
|
||||
.printStackTrace();
|
||||
} else {
|
||||
delete(name, tf.getPath());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a file on disk.
|
||||
*
|
||||
* @param name : The name of the file
|
||||
* @param path : The path to the file
|
||||
*/
|
||||
private static void delete(String name, String path) {
|
||||
name = Validator.checkName(name);
|
||||
|
||||
boolean exists;
|
||||
synchronized (fileMap) {
|
||||
exists = fileMap.containsKey(name);
|
||||
}
|
||||
|
||||
if (!exists) {
|
||||
try {
|
||||
Files.delete(Paths.get(path + File.separator + name + ".json"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
delete(name);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.exceptions;
|
||||
|
||||
public class FileLoadException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 12930275846413931L;
|
||||
|
||||
public FileLoadException(String name){
|
||||
super("[Thunderbolt] The file '" + name + ".json' is already loaded!");
|
||||
}
|
||||
}
|
@ -1,380 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.io;
|
||||
|
||||
import lombok.Getter;
|
||||
import me.savvy.rixa.data.thunderbolt.json.JSONArray;
|
||||
import me.savvy.rixa.data.thunderbolt.json.JSONObject;
|
||||
import me.savvy.rixa.data.thunderbolt.utils.Validator;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* File class containing numerous useful methods for
|
||||
* setting, saving, and retrieving information from JSON files
|
||||
*
|
||||
* @author Daniel S. (The Gaming Grunts)
|
||||
*/
|
||||
public class ThunderFile {
|
||||
|
||||
@Getter
|
||||
private final String name, path;
|
||||
private JSONObject jo = new JSONObject();
|
||||
@Getter
|
||||
private File f;
|
||||
|
||||
/**
|
||||
* @see ThunderFile
|
||||
* @param name : The name of the file, excluding the .json extension.
|
||||
* @param path : The path to the file
|
||||
*/
|
||||
public ThunderFile(String name, String path){
|
||||
this.path = path;
|
||||
this.name = Validator.checkName(name);
|
||||
|
||||
f = new File(path + File.separator + name + ".json");
|
||||
if (!f.exists()){
|
||||
try {
|
||||
new File(path).mkdirs();
|
||||
f.createNewFile();
|
||||
System.out.println("[Thunderbolt] Created new file " + name + ".json at " + path);
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else{
|
||||
System.out.println("[Thunderbolt] A file named '" + name + ".json' already exists at the specified path, " + path);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ThunderFile
|
||||
* @param name : The name of the file, excluding the .json extension.
|
||||
* @param path : The path to the file
|
||||
* @param jsonData : JSON-formatted data
|
||||
*/
|
||||
public ThunderFile(String name, String path, String jsonData){
|
||||
this(name, path);
|
||||
jo = new JSONObject(jsonData);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set an object in the file's map. This works like any old Map.
|
||||
*
|
||||
* @param key : The key
|
||||
* @param value : The value
|
||||
*/
|
||||
public void set(String key, Object value){
|
||||
jo.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an object by a specified key
|
||||
*
|
||||
* @param key : The key associated with the object
|
||||
* @return The object associated with this key
|
||||
*/
|
||||
public Object get(String key){
|
||||
return jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a String by a specific key
|
||||
*
|
||||
* @param key : The key associated with this String
|
||||
* @return The String associated with this key
|
||||
*/
|
||||
public String getString(String key) {
|
||||
return (String)jo.get(key);
|
||||
}
|
||||
|
||||
public Object getObjectinObj(String key, String secondKey) {
|
||||
return jo.getJSONObject(key).get(secondKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Byte by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Byte
|
||||
* @return The Byte associated with this key
|
||||
*/
|
||||
public byte getByte(String key){
|
||||
return (byte)jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Short by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Short
|
||||
* @return The Short associated with this key
|
||||
*/
|
||||
public short getShort(String key){
|
||||
return (short)jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an Integer by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Integer
|
||||
* @return The Integer associated with this key
|
||||
*/
|
||||
public int getInt(String key){
|
||||
return (int)jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Double by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Double
|
||||
* @return The Double associated with this key
|
||||
*/
|
||||
public double getDouble(String key){
|
||||
return (double)jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Long by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Long
|
||||
* @return The Long associated with this key
|
||||
*/
|
||||
public long getLong(String key){
|
||||
return (long)jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Float by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Float
|
||||
* @return The Float associated with this key
|
||||
*/
|
||||
public float getFloat(String key){
|
||||
return (float)jo.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Boolean by a specific key
|
||||
*
|
||||
* @param key : The key associated with this Boolean
|
||||
* @return The Boolean associated with this key
|
||||
*/
|
||||
public boolean getBoolean(String key){
|
||||
return (boolean)jo.get(key);
|
||||
}
|
||||
|
||||
|
||||
private List<?> getList(String key) {
|
||||
Object o = jo.get(key);
|
||||
List<Object> l = new ArrayList<Object>();
|
||||
JSONArray ja = new JSONArray(o.toString());
|
||||
for (int i = 0; i < ja.length(); i++){
|
||||
l.add(ja.get(i));
|
||||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Strings
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return String List
|
||||
*/
|
||||
public List<String> getStringList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof String){
|
||||
list.add(String.valueOf(o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Bytes
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return Byte List
|
||||
*/
|
||||
public List<Byte> getByteList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<Byte> list = new ArrayList<Byte>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof Byte){
|
||||
list.add((Byte)o);
|
||||
}else if (o instanceof String){
|
||||
list.add(Byte.valueOf((String)o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Shorts
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return Short List
|
||||
*/
|
||||
public List<Short> getShortList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<Short> list = new ArrayList<Short>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof Short){
|
||||
list.add((Short)o);
|
||||
}else if (o instanceof String){
|
||||
list.add(Short.valueOf((String)o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Integers
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return Integer List
|
||||
*/
|
||||
public List<Integer> getIntList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<Integer> list = new ArrayList<Integer>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof Integer){
|
||||
list.add((Integer)o);
|
||||
}else if (o instanceof String){
|
||||
list.add(Integer.valueOf((String)o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Doubles
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return Double List
|
||||
*/
|
||||
public List<Double> getDoubleList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<Double> list = new ArrayList<Double>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof Double){
|
||||
list.add((Double)o);
|
||||
}else if (o instanceof String){
|
||||
list.add(Double.valueOf((String)o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Longs
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return Long List
|
||||
*/
|
||||
public List<Long> getLongList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<Long> list = new ArrayList<Long>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof Long){
|
||||
list.add((Long)o);
|
||||
}else if (o instanceof String){
|
||||
list.add(Long.valueOf((String)o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a List containing various Floats
|
||||
*
|
||||
* @param key : The key associated with this list
|
||||
* @return Float List
|
||||
*/
|
||||
public List<Float> getFloatList(String key){
|
||||
List<?> temp = getList(key);
|
||||
List<Float> list = new ArrayList<Float>();
|
||||
for (Object o : temp){
|
||||
if (o instanceof Integer){
|
||||
list.add((Float)o);
|
||||
}else if (o instanceof String){
|
||||
list.add(Float.valueOf((String)o));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an array given a key
|
||||
*
|
||||
* @param key The key associated with the array
|
||||
* @return A generic object array
|
||||
* @throws IllegalArgumentException Value is not an array
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public <T> T[] getArray(String key){
|
||||
Object array = jo.get(key);
|
||||
if (array instanceof Object[]){
|
||||
return (T[]) jo.get(key);
|
||||
}else{
|
||||
throw new IllegalArgumentException("Value associated with key '" + key + "' is not an Array");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Map given a key
|
||||
*
|
||||
* @param key The key associated with the Map
|
||||
* @return A Map
|
||||
* @throws IllegalArgumentException Value is not a Map
|
||||
*/
|
||||
public Map<?, ?> getMap(String key){
|
||||
Object map = jo.get(key);
|
||||
if (map instanceof Map){
|
||||
return (Map<?, ?>) jo.get(key);
|
||||
}else{
|
||||
throw new IllegalArgumentException("Value associated with key '" + key + "' is not an instance of Map");
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Save this file to disk
|
||||
*
|
||||
* @throws IOException
|
||||
*/
|
||||
public void save() throws IOException{
|
||||
Runnable r = new Runnable(){
|
||||
public void run(){
|
||||
try {
|
||||
Writer writer = new PrintWriter(new FileWriter(path + File.separator + name + ".json", false));
|
||||
writer.write(jo.toString(2));
|
||||
writer.close();
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
};
|
||||
ThunderboltThreadPool.getPool().submit(r);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Set containing all the keys in the map
|
||||
*
|
||||
* @return A Set containing all keys
|
||||
*/
|
||||
public Set<String> keySet(){
|
||||
return jo.keySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Set containing all the values in the map
|
||||
*
|
||||
* @return A Set containing all the values
|
||||
*/
|
||||
public Set<Object> valueSet(){
|
||||
Set<Object> set = new HashSet<Object>();
|
||||
Iterator<String> i = jo.keys();
|
||||
while (i.hasNext()){
|
||||
set.add(jo.get(i.next()));
|
||||
}
|
||||
return set;
|
||||
}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.io;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
public abstract class ThunderboltThreadPool {
|
||||
|
||||
@Getter
|
||||
private static ExecutorService pool = Executors.newCachedThreadPool();
|
||||
|
||||
private ThunderboltThreadPool(){}
|
||||
|
||||
}
|
@ -1,147 +0,0 @@
|
||||
/*
|
||||
* $Id: ItemList.java,v 1.1 2006/04/15 14:10:48 platform Exp $
|
||||
* Created on 2006-3-24
|
||||
*/
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
/**
|
||||
* |a:b:c| => |a|,|b|,|c|
|
||||
* |:| => ||,||
|
||||
* |a:| => |a|,||
|
||||
* @author FangYidong<fangyidong@yahoo.com.cn>
|
||||
*/
|
||||
public class ItemList {
|
||||
private String sp=",";
|
||||
List items=new ArrayList();
|
||||
|
||||
|
||||
public ItemList(){}
|
||||
|
||||
|
||||
public ItemList(String s){
|
||||
this.split(s,sp,items);
|
||||
}
|
||||
|
||||
public ItemList(String s,String sp){
|
||||
this.sp=s;
|
||||
this.split(s,sp,items);
|
||||
}
|
||||
|
||||
public ItemList(String s,String sp,boolean isMultiToken){
|
||||
split(s,sp,items,isMultiToken);
|
||||
}
|
||||
|
||||
public List getItems(){
|
||||
return this.items;
|
||||
}
|
||||
|
||||
public String[] getArray(){
|
||||
return (String[])this.items.toArray();
|
||||
}
|
||||
|
||||
public void split(String s,String sp,List append,boolean isMultiToken){
|
||||
if(s==null || sp==null)
|
||||
return;
|
||||
if(isMultiToken){
|
||||
StringTokenizer tokens=new StringTokenizer(s,sp);
|
||||
while(tokens.hasMoreTokens()){
|
||||
append.add(tokens.nextToken().trim());
|
||||
}
|
||||
}
|
||||
else{
|
||||
this.split(s,sp,append);
|
||||
}
|
||||
}
|
||||
|
||||
public void split(String s,String sp,List append){
|
||||
if(s==null || sp==null)
|
||||
return;
|
||||
int pos=0;
|
||||
int prevPos=0;
|
||||
do{
|
||||
prevPos=pos;
|
||||
pos=s.indexOf(sp,pos);
|
||||
if(pos==-1)
|
||||
break;
|
||||
append.add(s.substring(prevPos,pos).trim());
|
||||
pos+=sp.length();
|
||||
}while(pos!=-1);
|
||||
append.add(s.substring(prevPos).trim());
|
||||
}
|
||||
|
||||
public void setSP(String sp){
|
||||
this.sp=sp;
|
||||
}
|
||||
|
||||
public void add(int i,String item){
|
||||
if(item==null)
|
||||
return;
|
||||
items.add(i,item.trim());
|
||||
}
|
||||
|
||||
public void add(String item){
|
||||
if(item==null)
|
||||
return;
|
||||
items.add(item.trim());
|
||||
}
|
||||
|
||||
public void addAll(ItemList list){
|
||||
items.addAll(list.items);
|
||||
}
|
||||
|
||||
public void addAll(String s){
|
||||
this.split(s,sp,items);
|
||||
}
|
||||
|
||||
public void addAll(String s,String sp){
|
||||
this.split(s,sp,items);
|
||||
}
|
||||
|
||||
public void addAll(String s,String sp,boolean isMultiToken){
|
||||
this.split(s,sp,items,isMultiToken);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param i 0-based
|
||||
* @return
|
||||
*/
|
||||
public String get(int i){
|
||||
return (String)items.get(i);
|
||||
}
|
||||
|
||||
public int size(){
|
||||
return items.size();
|
||||
}
|
||||
|
||||
public String toString(){
|
||||
return toString(sp);
|
||||
}
|
||||
|
||||
public String toString(String sp){
|
||||
StringBuffer sb=new StringBuffer();
|
||||
|
||||
for(int i=0;i<items.size();i++){
|
||||
if(i==0)
|
||||
sb.append(items.get(i));
|
||||
else{
|
||||
sb.append(sp);
|
||||
sb.append(items.get(i));
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
items.clear();
|
||||
}
|
||||
|
||||
public void reset(){
|
||||
sp=",";
|
||||
items.clear();
|
||||
}
|
||||
}
|
@ -1,981 +0,0 @@
|
||||
/*
|
||||
* $Id: JSONArray.java,v 1.1 2006/04/15 14:10:48 platform Exp $
|
||||
* Created on 2006-4-10
|
||||
*/
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.io.Writer;
|
||||
import java.lang.reflect.Array;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A JSONArray is an ordered sequence of values. Its external text form is a
|
||||
* string wrapped in square brackets with commas separating the values. The
|
||||
* internal form is an object having <code>get</code> and <code>opt</code>
|
||||
* methods for accessing the values by index, and <code>put</code> methods for
|
||||
* adding or replacing values. The values can be any of these types:
|
||||
* <code>Boolean</code>, <code>JSONArray</code>, <code>JSONObject</code>,
|
||||
* <code>Number</code>, <code>String</code>, or the
|
||||
* <code>JSONObject.NULL object</code>.
|
||||
* <p>
|
||||
* The constructor can convert a JSON text into a Java object. The
|
||||
* <code>toString</code> method converts to JSON text.
|
||||
* <p>
|
||||
* A <code>get</code> method returns a value if one can be found, and throws an
|
||||
* exception if one cannot be found. An <code>opt</code> method returns a
|
||||
* default value instead of throwing an exception, and so is useful for
|
||||
* obtaining optional values.
|
||||
* <p>
|
||||
* The generic <code>get()</code> and <code>opt()</code> methods return an
|
||||
* object which you can cast or query for type. There are also typed
|
||||
* <code>get</code> and <code>opt</code> methods that do type checking and type
|
||||
* coercion for you.
|
||||
* <p>
|
||||
* The texts produced by the <code>toString</code> methods strictly conform to
|
||||
* JSON syntax rules. The constructors are more forgiving in the texts they will
|
||||
* accept:
|
||||
* <ul>
|
||||
* <li>An extra <code>,</code> <small>(comma)</small> may appear just
|
||||
* before the closing bracket.</li>
|
||||
* <li>The <code>null</code> value will be inserted when there is <code>,</code>
|
||||
* <small>(comma)</small> elision.</li>
|
||||
* <li>Strings may be quoted with <code>'</code> <small>(single
|
||||
* quote)</small>.</li>
|
||||
* <li>Strings do not need to be quoted at all if they do not begin with a quote
|
||||
* or single quote, and if they do not contain leading or trailing spaces, and
|
||||
* if they do not contain any of these characters:
|
||||
* <code>{ } [ ] / \ : , #</code> and if they do not look like numbers and
|
||||
* if they are not the reserved words <code>true</code>, <code>false</code>, or
|
||||
* <code>null</code>.</li>
|
||||
* </ul>
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class JSONArray {
|
||||
|
||||
/**
|
||||
* The arrayList where the JSONArray's properties are kept.
|
||||
*/
|
||||
private final ArrayList<Object> myArrayList;
|
||||
|
||||
/**
|
||||
* Construct an empty JSONArray.
|
||||
*/
|
||||
public JSONArray() {
|
||||
this.myArrayList = new ArrayList<Object>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONArray from a JSONTokener.
|
||||
*
|
||||
* @param x
|
||||
* A JSONTokener
|
||||
* @throws JSONException
|
||||
* If there is a syntax error.
|
||||
*/
|
||||
public JSONArray(JSONTokener x) throws JSONException {
|
||||
this();
|
||||
if (x.nextClean() != '[') {
|
||||
throw x.syntaxError("A JSONArray text must start with '['");
|
||||
}
|
||||
if (x.nextClean() != ']') {
|
||||
x.back();
|
||||
for (;;) {
|
||||
if (x.nextClean() == ',') {
|
||||
x.back();
|
||||
this.myArrayList.add(JSONObject.NULL);
|
||||
} else {
|
||||
x.back();
|
||||
this.myArrayList.add(x.nextValue());
|
||||
}
|
||||
switch (x.nextClean()) {
|
||||
case ',':
|
||||
if (x.nextClean() == ']') {
|
||||
return;
|
||||
}
|
||||
x.back();
|
||||
break;
|
||||
case ']':
|
||||
return;
|
||||
default:
|
||||
throw x.syntaxError("Expected a ',' or ']'");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONArray from a source JSON text.
|
||||
*
|
||||
* @param source
|
||||
* A string that begins with <code>[</code> <small>(left
|
||||
* bracket)</small> and ends with <code>]</code>
|
||||
* <small>(right bracket)</small>.
|
||||
* @throws JSONException
|
||||
* If there is a syntax error.
|
||||
*/
|
||||
public JSONArray(String source) throws JSONException {
|
||||
this(new JSONTokener(source));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONArray from a Collection.
|
||||
*
|
||||
* @param collection
|
||||
* A Collection.
|
||||
*/
|
||||
public JSONArray(Collection<Object> collection) {
|
||||
this.myArrayList = new ArrayList<Object>();
|
||||
if (collection != null) {
|
||||
Iterator<Object> iter = collection.iterator();
|
||||
while (iter.hasNext()) {
|
||||
this.myArrayList.add(JSONObject.wrap(iter.next()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct a JSONArray from an array
|
||||
*
|
||||
* @throws JSONException
|
||||
* If not an array.
|
||||
*/
|
||||
public JSONArray(Object array) throws JSONException {
|
||||
this();
|
||||
if (array.getClass().isArray()) {
|
||||
int length = Array.getLength(array);
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
this.put(JSONObject.wrap(Array.get(array, i)));
|
||||
}
|
||||
} else {
|
||||
throw new JSONException(
|
||||
"JSONArray initial value should be a string or collection or array.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the object value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return An object value.
|
||||
* @throws JSONException
|
||||
* If there is no value for the index.
|
||||
*/
|
||||
public Object get(int index) throws JSONException {
|
||||
Object object = this.opt(index);
|
||||
if (object == null) {
|
||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the boolean value associated with an index. The string values "true"
|
||||
* and "false" are converted to boolean.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The truth.
|
||||
* @throws JSONException
|
||||
* If there is no value for the index or if the value is not
|
||||
* convertible to boolean.
|
||||
*/
|
||||
public boolean getBoolean(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object.equals(Boolean.FALSE)
|
||||
|| (object instanceof String && ((String) object)
|
||||
.equalsIgnoreCase("false"))) {
|
||||
return false;
|
||||
} else if (object.equals(Boolean.TRUE)
|
||||
|| (object instanceof String && ((String) object)
|
||||
.equalsIgnoreCase("true"))) {
|
||||
return true;
|
||||
}
|
||||
throw new JSONException("JSONArray[" + index + "] is not a boolean.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the double value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
* @throws JSONException
|
||||
* If the key is not found or if the value cannot be converted
|
||||
* to a number.
|
||||
*/
|
||||
public double getDouble(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
try {
|
||||
return object instanceof Number ? ((Number) object).doubleValue()
|
||||
: Double.parseDouble((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONArray[" + index + "] is not a number.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the int value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
* @throws JSONException
|
||||
* If the key is not found or if the value is not a number.
|
||||
*/
|
||||
public int getInt(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
try {
|
||||
return object instanceof Number ? ((Number) object).intValue()
|
||||
: Integer.parseInt((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONArray[" + index + "] is not a number.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JSONArray associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return A JSONArray value.
|
||||
* @throws JSONException
|
||||
* If there is no value for the index. or if the value is not a
|
||||
* JSONArray
|
||||
*/
|
||||
public JSONArray getJSONArray(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof JSONArray) {
|
||||
return (JSONArray) object;
|
||||
}
|
||||
throw new JSONException("JSONArray[" + index + "] is not a JSONArray.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JSONObject associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* subscript
|
||||
* @return A JSONObject value.
|
||||
* @throws JSONException
|
||||
* If there is no value for the index or if the value is not a
|
||||
* JSONObject
|
||||
*/
|
||||
public JSONObject getJSONObject(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof JSONObject) {
|
||||
return (JSONObject) object;
|
||||
}
|
||||
throw new JSONException("JSONArray[" + index + "] is not a JSONObject.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the long value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
* @throws JSONException
|
||||
* If the key is not found or if the value cannot be converted
|
||||
* to a number.
|
||||
*/
|
||||
public long getLong(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
try {
|
||||
return object instanceof Number ? ((Number) object).longValue()
|
||||
: Long.parseLong((String) object);
|
||||
} catch (Exception e) {
|
||||
throw new JSONException("JSONArray[" + index + "] is not a number.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the string associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return A string value.
|
||||
* @throws JSONException
|
||||
* If there is no string value for the index.
|
||||
*/
|
||||
public String getString(int index) throws JSONException {
|
||||
Object object = this.get(index);
|
||||
if (object instanceof String) {
|
||||
return (String) object;
|
||||
}
|
||||
throw new JSONException("JSONArray[" + index + "] not a string.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if the value is null.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return true if the value at the index is null, or if there is no value.
|
||||
*/
|
||||
public boolean isNull(int index) {
|
||||
return JSONObject.NULL.equals(this.opt(index));
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a string from the contents of this JSONArray. The
|
||||
* <code>separator</code> string is inserted between each element. Warning:
|
||||
* This method assumes that the data structure is acyclical.
|
||||
*
|
||||
* @param separator
|
||||
* A string that will be inserted between the elements.
|
||||
* @return a string.
|
||||
* @throws JSONException
|
||||
* If the array contains an invalid number.
|
||||
*/
|
||||
public String join(String separator) throws JSONException {
|
||||
int len = this.length();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
||||
for (int i = 0; i < len; i += 1) {
|
||||
if (i > 0) {
|
||||
sb.append(separator);
|
||||
}
|
||||
sb.append(JSONObject.valueToString(this.myArrayList.get(i)));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of elements in the JSONArray, included nulls.
|
||||
*
|
||||
* @return The length (or size).
|
||||
*/
|
||||
public int length() {
|
||||
return this.myArrayList.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional object value associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return An object value, or null if there is no object at that index.
|
||||
*/
|
||||
public Object opt(int index) {
|
||||
return (index < 0 || index >= this.length()) ? null : this.myArrayList
|
||||
.get(index);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional boolean value associated with an index. It returns false
|
||||
* if there is no value at that index, or if the value is not Boolean.TRUE
|
||||
* or the String "true".
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The truth.
|
||||
*/
|
||||
public boolean optBoolean(int index) {
|
||||
return this.optBoolean(index, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional boolean value associated with an index. It returns the
|
||||
* defaultValue if there is no value at that index or if it is not a Boolean
|
||||
* or the String "true" or "false" (case insensitive).
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @param defaultValue
|
||||
* A boolean default.
|
||||
* @return The truth.
|
||||
*/
|
||||
public boolean optBoolean(int index, boolean defaultValue) {
|
||||
try {
|
||||
return this.getBoolean(index);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional double value associated with an index. NaN is returned
|
||||
* if there is no value for the index, or if the value is not a number and
|
||||
* cannot be converted to a number.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
*/
|
||||
public double optDouble(int index) {
|
||||
return this.optDouble(index, Double.NaN);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional double value associated with an index. The defaultValue
|
||||
* is returned if there is no value for the index, or if the value is not a
|
||||
* number and cannot be converted to a number.
|
||||
*
|
||||
* @param index
|
||||
* subscript
|
||||
* @param defaultValue
|
||||
* The default value.
|
||||
* @return The value.
|
||||
*/
|
||||
public double optDouble(int index, double defaultValue) {
|
||||
try {
|
||||
return this.getDouble(index);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional int value associated with an index. Zero is returned if
|
||||
* there is no value for the index, or if the value is not a number and
|
||||
* cannot be converted to a number.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
*/
|
||||
public int optInt(int index) {
|
||||
return this.optInt(index, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional int value associated with an index. The defaultValue is
|
||||
* returned if there is no value for the index, or if the value is not a
|
||||
* number and cannot be converted to a number.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @param defaultValue
|
||||
* The default value.
|
||||
* @return The value.
|
||||
*/
|
||||
public int optInt(int index, int defaultValue) {
|
||||
try {
|
||||
return this.getInt(index);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional JSONArray associated with an index.
|
||||
*
|
||||
* @param index
|
||||
* subscript
|
||||
* @return A JSONArray value, or null if the index has no value, or if the
|
||||
* value is not a JSONArray.
|
||||
*/
|
||||
public JSONArray optJSONArray(int index) {
|
||||
Object o = this.opt(index);
|
||||
return o instanceof JSONArray ? (JSONArray) o : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional JSONObject associated with an index. Null is returned if
|
||||
* the key is not found, or null if the index has no value, or if the value
|
||||
* is not a JSONObject.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return A JSONObject value.
|
||||
*/
|
||||
public JSONObject optJSONObject(int index) {
|
||||
Object o = this.opt(index);
|
||||
return o instanceof JSONObject ? (JSONObject) o : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional long value associated with an index. Zero is returned if
|
||||
* there is no value for the index, or if the value is not a number and
|
||||
* cannot be converted to a number.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return The value.
|
||||
*/
|
||||
public long optLong(int index) {
|
||||
return this.optLong(index, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional long value associated with an index. The defaultValue is
|
||||
* returned if there is no value for the index, or if the value is not a
|
||||
* number and cannot be converted to a number.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @param defaultValue
|
||||
* The default value.
|
||||
* @return The value.
|
||||
*/
|
||||
public long optLong(int index, long defaultValue) {
|
||||
try {
|
||||
return this.getLong(index);
|
||||
} catch (Exception e) {
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional string value associated with an index. It returns an
|
||||
* empty string if there is no value at that index. If the value is not a
|
||||
* string and is not null, then it is coverted to a string.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @return A String value.
|
||||
*/
|
||||
public String optString(int index) {
|
||||
return this.optString(index, "");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the optional string associated with an index. The defaultValue is
|
||||
* returned if the key is not found.
|
||||
*
|
||||
* @param index
|
||||
* The index must be between 0 and length() - 1.
|
||||
* @param defaultValue
|
||||
* The default value.
|
||||
* @return A String value.
|
||||
*/
|
||||
public String optString(int index, String defaultValue) {
|
||||
Object object = this.opt(index);
|
||||
return JSONObject.NULL.equals(object) ? defaultValue : object
|
||||
.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a boolean value. This increases the array's length by one.
|
||||
*
|
||||
* @param value
|
||||
* A boolean value.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(boolean value) {
|
||||
this.put(value ? Boolean.TRUE : Boolean.FALSE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONArray which
|
||||
* is produced from a Collection.
|
||||
*
|
||||
* @param value
|
||||
* A Collection value.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(Collection<Object> value) {
|
||||
this.put(new JSONArray(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append a double value. This increases the array's length by one.
|
||||
*
|
||||
* @param value
|
||||
* A double value.
|
||||
* @throws JSONException
|
||||
* if the value is not finite.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(double value) throws JSONException {
|
||||
Double d = new Double(value);
|
||||
JSONObject.testValidity(d);
|
||||
this.put(d);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an int value. This increases the array's length by one.
|
||||
*
|
||||
* @param value
|
||||
* An int value.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(int value) {
|
||||
this.put(new Integer(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an long value. This increases the array's length by one.
|
||||
*
|
||||
* @param value
|
||||
* A long value.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(long value) {
|
||||
this.put(new Long(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONObject which
|
||||
* is produced from a Map.
|
||||
*
|
||||
* @param value
|
||||
* A Map value.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(Map<String, Object> value) {
|
||||
this.put(new JSONObject(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Append an object value. This increases the array's length by one.
|
||||
*
|
||||
* @param value
|
||||
* An object value. The value should be a Boolean, Double,
|
||||
* Integer, JSONArray, JSONObject, Long, or String, or the
|
||||
* JSONObject.NULL object.
|
||||
* @return this.
|
||||
*/
|
||||
public JSONArray put(Object value) {
|
||||
this.myArrayList.add(value);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put or replace a boolean value in the JSONArray. If the index is greater
|
||||
* than the length of the JSONArray, then null elements will be added as
|
||||
* necessary to pad it out.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* A boolean value.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative.
|
||||
*/
|
||||
public JSONArray put(int index, boolean value) throws JSONException {
|
||||
this.put(index, value ? Boolean.TRUE : Boolean.FALSE);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONArray which
|
||||
* is produced from a Collection.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* A Collection value.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative or if the value is not finite.
|
||||
*/
|
||||
public JSONArray put(int index, Collection<Object> value) throws JSONException {
|
||||
this.put(index, new JSONArray(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put or replace a double value. If the index is greater than the length of
|
||||
* the JSONArray, then null elements will be added as necessary to pad it
|
||||
* out.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* A double value.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative or if the value is not finite.
|
||||
*/
|
||||
public JSONArray put(int index, double value) throws JSONException {
|
||||
this.put(index, new Double(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put or replace an int value. If the index is greater than the length of
|
||||
* the JSONArray, then null elements will be added as necessary to pad it
|
||||
* out.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* An int value.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative.
|
||||
*/
|
||||
public JSONArray put(int index, int value) throws JSONException {
|
||||
this.put(index, new Integer(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put or replace a long value. If the index is greater than the length of
|
||||
* the JSONArray, then null elements will be added as necessary to pad it
|
||||
* out.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* A long value.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative.
|
||||
*/
|
||||
public JSONArray put(int index, long value) throws JSONException {
|
||||
this.put(index, new Long(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put a value in the JSONArray, where the value will be a JSONObject that
|
||||
* is produced from a Map.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* The Map value.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative or if the the value is an invalid
|
||||
* number.
|
||||
*/
|
||||
public JSONArray put(int index, Map<String, Object> value) throws JSONException {
|
||||
this.put(index, new JSONObject(value));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put or replace an object value in the JSONArray. If the index is greater
|
||||
* than the length of the JSONArray, then null elements will be added as
|
||||
* necessary to pad it out.
|
||||
*
|
||||
* @param index
|
||||
* The subscript.
|
||||
* @param value
|
||||
* The value to put into the array. The value should be a
|
||||
* Boolean, Double, Integer, JSONArray, JSONObject, Long, or
|
||||
* String, or the JSONObject.NULL object.
|
||||
* @return this.
|
||||
* @throws JSONException
|
||||
* If the index is negative or if the the value is an invalid
|
||||
* number.
|
||||
*/
|
||||
public JSONArray put(int index, Object value) throws JSONException {
|
||||
JSONObject.testValidity(value);
|
||||
if (index < 0) {
|
||||
throw new JSONException("JSONArray[" + index + "] not found.");
|
||||
}
|
||||
if (index < this.length()) {
|
||||
this.myArrayList.set(index, value);
|
||||
} else {
|
||||
while (index != this.length()) {
|
||||
this.put(JSONObject.NULL);
|
||||
}
|
||||
this.put(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove an index and close the hole.
|
||||
*
|
||||
* @param index
|
||||
* The index of the element to be removed.
|
||||
* @return The value that was associated with the index, or null if there
|
||||
* was no value.
|
||||
*/
|
||||
public Object remove(int index) {
|
||||
return index >= 0 && index < this.length()
|
||||
? this.myArrayList.remove(index)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if two JSONArrays are similar.
|
||||
* They must contain similar sequences.
|
||||
*
|
||||
* @param other The other JSONArray
|
||||
* @return true if they are equal
|
||||
*/
|
||||
public boolean similar(Object other) {
|
||||
if (!(other instanceof JSONArray)) {
|
||||
return false;
|
||||
}
|
||||
int len = this.length();
|
||||
if (len != ((JSONArray)other).length()) {
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < len; i += 1) {
|
||||
Object valueThis = this.get(i);
|
||||
Object valueOther = ((JSONArray)other).get(i);
|
||||
if (valueThis instanceof JSONObject) {
|
||||
if (!((JSONObject)valueThis).similar(valueOther)) {
|
||||
return false;
|
||||
}
|
||||
} else if (valueThis instanceof JSONArray) {
|
||||
if (!((JSONArray)valueThis).similar(valueOther)) {
|
||||
return false;
|
||||
}
|
||||
} else if (!valueThis.equals(valueOther)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Produce a JSONObject by combining a JSONArray of names with the values of
|
||||
* this JSONArray.
|
||||
*
|
||||
* @param names
|
||||
* A JSONArray containing a list of key strings. These will be
|
||||
* paired with the values.
|
||||
* @return A JSONObject, or null if there are no names or if this JSONArray
|
||||
* has no values.
|
||||
* @throws JSONException
|
||||
* If any of the names are null.
|
||||
*/
|
||||
public JSONObject toJSONObject(JSONArray names) throws JSONException {
|
||||
if (names == null || names.length() == 0 || this.length() == 0) {
|
||||
return null;
|
||||
}
|
||||
JSONObject jo = new JSONObject();
|
||||
for (int i = 0; i < names.length(); i += 1) {
|
||||
jo.put(names.getString(i), this.opt(i));
|
||||
}
|
||||
return jo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a JSON text of this JSONArray. For compactness, no unnecessary
|
||||
* whitespace is added. If it is not possible to produce a syntactically
|
||||
* correct JSON text then null will be returned instead. This could occur if
|
||||
* the array contains an invalid number.
|
||||
* <p>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
*
|
||||
* @return a printable, displayable, transmittable representation of the
|
||||
* array.
|
||||
*/
|
||||
public String toString() {
|
||||
try {
|
||||
return this.toString(0);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Make a prettyprinted JSON text of this JSONArray. Warning: This method
|
||||
* assumes that the data structure is acyclical.
|
||||
*
|
||||
* @param indentFactor
|
||||
* The number of spaces to add to each level of indentation.
|
||||
* @return a printable, displayable, transmittable representation of the
|
||||
* object, beginning with <code>[</code> <small>(left
|
||||
* bracket)</small> and ending with <code>]</code>
|
||||
* <small>(right bracket)</small>.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public String toString(int indentFactor) throws JSONException {
|
||||
StringWriter sw = new StringWriter();
|
||||
synchronized (sw.getBuffer()) {
|
||||
return this.write(sw, indentFactor, 0).toString();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the contents of the JSONArray as JSON text to a writer. For
|
||||
* compactness, no whitespace is added.
|
||||
* <p>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
*
|
||||
* @return The writer.
|
||||
* @throws JSONException
|
||||
*/
|
||||
public Writer write(Writer writer) throws JSONException {
|
||||
return this.write(writer, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Write the contents of the JSONArray as JSON text to a writer. For
|
||||
* compactness, no whitespace is added.
|
||||
* <p>
|
||||
* Warning: This method assumes that the data structure is acyclical.
|
||||
*
|
||||
* @param indentFactor
|
||||
* The number of spaces to add to each level of indentation.
|
||||
* @param indent
|
||||
* The indention of the top level.
|
||||
* @return The writer.
|
||||
* @throws JSONException
|
||||
*/
|
||||
Writer write(Writer writer, int indentFactor, int indent)
|
||||
throws JSONException {
|
||||
try {
|
||||
boolean commanate = false;
|
||||
int length = this.length();
|
||||
writer.write('[');
|
||||
|
||||
if (length == 1) {
|
||||
JSONObject.writeValue(writer, this.myArrayList.get(0),
|
||||
indentFactor, indent);
|
||||
} else if (length != 0) {
|
||||
final int newindent = indent + indentFactor;
|
||||
|
||||
for (int i = 0; i < length; i += 1) {
|
||||
if (commanate) {
|
||||
writer.write(',');
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write('\n');
|
||||
}
|
||||
JSONObject.indent(writer, newindent);
|
||||
JSONObject.writeValue(writer, this.myArrayList.get(i),
|
||||
indentFactor, newindent);
|
||||
commanate = true;
|
||||
}
|
||||
if (indentFactor > 0) {
|
||||
writer.write('\n');
|
||||
}
|
||||
JSONObject.indent(writer, indent);
|
||||
}
|
||||
writer.write(']');
|
||||
return writer;
|
||||
} catch (IOException e) {
|
||||
throw new JSONException(e);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
/**
|
||||
* Beans that support customized output of JSON text shall implement this interface.
|
||||
* @author FangYidong<fangyidong@yahoo.com.cn>
|
||||
*/
|
||||
public interface JSONAware {
|
||||
/**
|
||||
* @return JSON text
|
||||
*/
|
||||
String toJSONString();
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
/**
|
||||
* The JSONException is thrown by the JSON.org classes when things are amiss.
|
||||
*
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class JSONException extends RuntimeException {
|
||||
private static final long serialVersionUID = 0;
|
||||
private Throwable cause;
|
||||
|
||||
/**
|
||||
* Constructs a JSONException with an explanatory message.
|
||||
*
|
||||
* @param message
|
||||
* Detail about the reason for the exception.
|
||||
*/
|
||||
public JSONException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new JSONException with the specified cause.
|
||||
* @param cause The cause.
|
||||
*/
|
||||
public JSONException(Throwable cause) {
|
||||
super(cause.getMessage());
|
||||
this.cause = cause;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cause of this exception or null if the cause is nonexistent
|
||||
* or unknown.
|
||||
*
|
||||
* @return the cause of this exception or null if the cause is nonexistent
|
||||
* or unknown.
|
||||
*/
|
||||
@Override
|
||||
public Throwable getCause() {
|
||||
return this.cause;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@ -1,15 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* Beans that support customized output of JSON text to a writer shall implement this interface.
|
||||
* @author FangYidong<fangyidong@yahoo.com.cn>
|
||||
*/
|
||||
public interface JSONStreamAware {
|
||||
/**
|
||||
* write JSON string to out.
|
||||
*/
|
||||
void writeJSONString(Writer out) throws IOException;
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
/**
|
||||
* The <code>JSONString</code> interface allows a <code>toJSONString()</code>
|
||||
* method so that a class can change the behavior of
|
||||
* <code>JSONObject.toString()</code>, <code>JSONArray.toString()</code>,
|
||||
* and <code>JSONWriter.value(</code>Object<code>)</code>. The
|
||||
* <code>toJSONString</code> method will be used instead of the default behavior
|
||||
* of using the Object's <code>toString()</code> method and quoting the result.
|
||||
*/
|
||||
public interface JSONString {
|
||||
/**
|
||||
* The <code>toJSONString</code> method allows a class to produce its own JSON
|
||||
* serialization.
|
||||
*
|
||||
* @return A strictly syntactically correct JSON text.
|
||||
*/
|
||||
public String toJSONString();
|
||||
}
|
@ -1,446 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.json;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.io.StringReader;
|
||||
|
||||
/*
|
||||
Copyright (c) 2002 JSON.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
The Software shall be used for Good, not Evil.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* A JSONTokener takes a source string and extracts characters and tokens from
|
||||
* it. It is used by the JSONObject and JSONArray constructors to parse
|
||||
* JSON source strings.
|
||||
* @author JSON.org
|
||||
* @version 2014-05-03
|
||||
*/
|
||||
public class JSONTokener {
|
||||
|
||||
private long character;
|
||||
private boolean eof;
|
||||
private long index;
|
||||
private long line;
|
||||
private char previous;
|
||||
private Reader reader;
|
||||
private boolean usePrevious;
|
||||
|
||||
|
||||
/**
|
||||
* Construct a JSONTokener from a Reader.
|
||||
*
|
||||
* @param reader A reader.
|
||||
*/
|
||||
public JSONTokener(Reader reader) {
|
||||
this.reader = reader.markSupported()
|
||||
? reader
|
||||
: new BufferedReader(reader);
|
||||
this.eof = false;
|
||||
this.usePrevious = false;
|
||||
this.previous = 0;
|
||||
this.index = 0;
|
||||
this.character = 1;
|
||||
this.line = 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a JSONTokener from an InputStream.
|
||||
* @param inputStream The source.
|
||||
*/
|
||||
public JSONTokener(InputStream inputStream) throws JSONException {
|
||||
this(new InputStreamReader(inputStream));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct a JSONTokener from a string.
|
||||
*
|
||||
* @param s A source string.
|
||||
*/
|
||||
public JSONTokener(String s) {
|
||||
this(new StringReader(s));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Back up one character. This provides a sort of lookahead capability,
|
||||
* so that you can test for a digit or letter before attempting to parse
|
||||
* the next number or identifier.
|
||||
*/
|
||||
public void back() throws JSONException {
|
||||
if (this.usePrevious || this.index <= 0) {
|
||||
throw new JSONException("Stepping back two steps is not supported");
|
||||
}
|
||||
this.index -= 1;
|
||||
this.character -= 1;
|
||||
this.usePrevious = true;
|
||||
this.eof = false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the hex value of a character (base16).
|
||||
* @param c A character between '0' and '9' or between 'A' and 'F' or
|
||||
* between 'a' and 'f'.
|
||||
* @return An int between 0 and 15, or -1 if c was not a hex digit.
|
||||
*/
|
||||
public static int dehexchar(char c) {
|
||||
if (c >= '0' && c <= '9') {
|
||||
return c - '0';
|
||||
}
|
||||
if (c >= 'A' && c <= 'F') {
|
||||
return c - ('A' - 10);
|
||||
}
|
||||
if (c >= 'a' && c <= 'f') {
|
||||
return c - ('a' - 10);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean end() {
|
||||
return this.eof && !this.usePrevious;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Determine if the source string still contains characters that next()
|
||||
* can consume.
|
||||
* @return true if not yet at the end of the source.
|
||||
*/
|
||||
public boolean more() throws JSONException {
|
||||
this.next();
|
||||
if (this.end()) {
|
||||
return false;
|
||||
}
|
||||
this.back();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next character in the source string.
|
||||
*
|
||||
* @return The next character, or 0 if past the end of the source string.
|
||||
*/
|
||||
public char next() throws JSONException {
|
||||
int c;
|
||||
if (this.usePrevious) {
|
||||
this.usePrevious = false;
|
||||
c = this.previous;
|
||||
} else {
|
||||
try {
|
||||
c = this.reader.read();
|
||||
} catch (IOException exception) {
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
|
||||
if (c <= 0) { // End of stream
|
||||
this.eof = true;
|
||||
c = 0;
|
||||
}
|
||||
}
|
||||
this.index += 1;
|
||||
if (this.previous == '\r') {
|
||||
this.line += 1;
|
||||
this.character = c == '\n' ? 0 : 1;
|
||||
} else if (c == '\n') {
|
||||
this.line += 1;
|
||||
this.character = 0;
|
||||
} else {
|
||||
this.character += 1;
|
||||
}
|
||||
this.previous = (char) c;
|
||||
return this.previous;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Consume the next character, and check that it matches a specified
|
||||
* character.
|
||||
* @param c The character to match.
|
||||
* @return The character.
|
||||
* @throws JSONException if the character does not match.
|
||||
*/
|
||||
public char next(char c) throws JSONException {
|
||||
char n = this.next();
|
||||
if (n != c) {
|
||||
throw this.syntaxError("Expected '" + c + "' and instead saw '" +
|
||||
n + "'");
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next n characters.
|
||||
*
|
||||
* @param n The number of characters to take.
|
||||
* @return A string of n characters.
|
||||
* @throws JSONException
|
||||
* Substring bounds error if there are not
|
||||
* n characters remaining in the source string.
|
||||
*/
|
||||
public String next(int n) throws JSONException {
|
||||
if (n == 0) {
|
||||
return "";
|
||||
}
|
||||
|
||||
char[] chars = new char[n];
|
||||
int pos = 0;
|
||||
|
||||
while (pos < n) {
|
||||
chars[pos] = this.next();
|
||||
if (this.end()) {
|
||||
throw this.syntaxError("Substring bounds error");
|
||||
}
|
||||
pos += 1;
|
||||
}
|
||||
return new String(chars);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next char in the string, skipping whitespace.
|
||||
* @throws JSONException
|
||||
* @return A character, or 0 if there are no more characters.
|
||||
*/
|
||||
public char nextClean() throws JSONException {
|
||||
for (;;) {
|
||||
char c = this.next();
|
||||
if (c == 0 || c > ' ') {
|
||||
return c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the characters up to the next close quote character.
|
||||
* Backslash processing is done. The formal JSON format does not
|
||||
* allow strings in single quotes, but an implementation is allowed to
|
||||
* accept them.
|
||||
* @param quote The quoting character, either
|
||||
* <code>"</code> <small>(double quote)</small> or
|
||||
* <code>'</code> <small>(single quote)</small>.
|
||||
* @return A String.
|
||||
* @throws JSONException Unterminated string.
|
||||
*/
|
||||
public String nextString(char quote) throws JSONException {
|
||||
char c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
c = this.next();
|
||||
switch (c) {
|
||||
case 0:
|
||||
case '\n':
|
||||
case '\r':
|
||||
throw this.syntaxError("Unterminated string");
|
||||
case '\\':
|
||||
c = this.next();
|
||||
switch (c) {
|
||||
case 'b':
|
||||
sb.append('\b');
|
||||
break;
|
||||
case 't':
|
||||
sb.append('\t');
|
||||
break;
|
||||
case 'n':
|
||||
sb.append('\n');
|
||||
break;
|
||||
case 'f':
|
||||
sb.append('\f');
|
||||
break;
|
||||
case 'r':
|
||||
sb.append('\r');
|
||||
break;
|
||||
case 'u':
|
||||
sb.append((char)Integer.parseInt(this.next(4), 16));
|
||||
break;
|
||||
case '"':
|
||||
case '\'':
|
||||
case '\\':
|
||||
case '/':
|
||||
sb.append(c);
|
||||
break;
|
||||
default:
|
||||
throw this.syntaxError("Illegal escape.");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (c == quote) {
|
||||
return sb.toString();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the text up but not including the specified character or the
|
||||
* end of line, whichever comes first.
|
||||
* @param delimiter A delimiter character.
|
||||
* @return A string.
|
||||
*/
|
||||
public String nextTo(char delimiter) throws JSONException {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
char c = this.next();
|
||||
if (c == delimiter || c == 0 || c == '\n' || c == '\r') {
|
||||
if (c != 0) {
|
||||
this.back();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the text up but not including one of the specified delimiter
|
||||
* characters or the end of line, whichever comes first.
|
||||
* @param delimiters A set of delimiter characters.
|
||||
* @return A string, trimmed.
|
||||
*/
|
||||
public String nextTo(String delimiters) throws JSONException {
|
||||
char c;
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (;;) {
|
||||
c = this.next();
|
||||
if (delimiters.indexOf(c) >= 0 || c == 0 ||
|
||||
c == '\n' || c == '\r') {
|
||||
if (c != 0) {
|
||||
this.back();
|
||||
}
|
||||
return sb.toString().trim();
|
||||
}
|
||||
sb.append(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the next value. The value can be a Boolean, Double, Integer,
|
||||
* JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
|
||||
* @throws JSONException If syntax error.
|
||||
*
|
||||
* @return An object.
|
||||
*/
|
||||
public Object nextValue() throws JSONException {
|
||||
char c = this.nextClean();
|
||||
String string;
|
||||
|
||||
switch (c) {
|
||||
case '"':
|
||||
case '\'':
|
||||
return this.nextString(c);
|
||||
case '{':
|
||||
this.back();
|
||||
return new JSONObject(this);
|
||||
case '[':
|
||||
this.back();
|
||||
return new JSONArray(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* Handle unquoted text. This could be the values true, false, or
|
||||
* null, or it can be a number. An implementation (such as this one)
|
||||
* is allowed to also accept non-standard forms.
|
||||
*
|
||||
* Accumulate characters until we reach the end of the text or a
|
||||
* formatting character.
|
||||
*/
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
while (c >= ' ' && ",:]}/\\\"[{;=#".indexOf(c) < 0) {
|
||||
sb.append(c);
|
||||
c = this.next();
|
||||
}
|
||||
this.back();
|
||||
|
||||
string = sb.toString().trim();
|
||||
if ("".equals(string)) {
|
||||
throw this.syntaxError("Missing value");
|
||||
}
|
||||
return JSONObject.stringToValue(string);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Skip characters until the next character is the requested character.
|
||||
* If the requested character is not found, no characters are skipped.
|
||||
* @param to A character to skip to.
|
||||
* @return The requested character, or zero if the requested character
|
||||
* is not found.
|
||||
*/
|
||||
public char skipTo(char to) throws JSONException {
|
||||
char c;
|
||||
try {
|
||||
long startIndex = this.index;
|
||||
long startCharacter = this.character;
|
||||
long startLine = this.line;
|
||||
this.reader.mark(1000000);
|
||||
do {
|
||||
c = this.next();
|
||||
if (c == 0) {
|
||||
this.reader.reset();
|
||||
this.index = startIndex;
|
||||
this.character = startCharacter;
|
||||
this.line = startLine;
|
||||
return c;
|
||||
}
|
||||
} while (c != to);
|
||||
} catch (IOException exception) {
|
||||
throw new JSONException(exception);
|
||||
}
|
||||
this.back();
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make a JSONException to signal a syntax error.
|
||||
*
|
||||
* @param message The error message.
|
||||
* @return A JSONException object, suitable for throwing
|
||||
*/
|
||||
public JSONException syntaxError(String message) {
|
||||
return new JSONException(message + this.toString());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Make a printable string of this JSONTokener.
|
||||
*
|
||||
* @return " at {index} [character {character} line {line}]"
|
||||
*/
|
||||
public String toString() {
|
||||
return " at " + this.index + " [character " + this.character + " line " +
|
||||
this.line + "]";
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
package me.savvy.rixa.data.thunderbolt.utils;
|
||||
|
||||
public class Validator {
|
||||
|
||||
/**
|
||||
* Ensure that a file name doesn't contain an extension
|
||||
*
|
||||
* @param name : The name of the file
|
||||
* @return A file name without an extension
|
||||
*/
|
||||
public static String checkName(String name){
|
||||
return (name.contains(".")) ? name.split(".")[0] : name;
|
||||
}
|
||||
}
|
24
src/main/java/me/savvy/rixa/guild/user/UserData.java
Normal file
24
src/main/java/me/savvy/rixa/guild/user/UserData.java
Normal file
@ -0,0 +1,24 @@
|
||||
package me.savvy.rixa.guild.user;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.dv8tion.jda.core.entities.User;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by savit on 7/14/2017.
|
||||
*/
|
||||
public class UserData {
|
||||
|
||||
@Getter private static Map<String, UserData> userData = new HashMap<>();
|
||||
@Getter private User user;
|
||||
@Getter @Setter private String status;
|
||||
@Getter @Setter private int level;
|
||||
@Getter @Setter private int experience;
|
||||
|
||||
public UserData(User user) {
|
||||
this.user = user;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user