fabric ok

This commit is contained in:
Color_yr committed 2023-03-02 16:58:01 +08:00
1 parent 8f4b66a6a8
commit bda183823f
102 files changed
+8647 -2

No files matched your search

+40
View File
@@ -0,0 +1,40 @@
# gradle
.gradle/
build/
out/
classes/
# eclipse
*.launch
# idea
.idea/
*.iml
*.ipr
*.iws
# vscode
.settings/
.vscode/
bin/
.classpath
.project
# macos
*.DS_Store
# fabric
run/
# java
hs_err_*.log
replay_*.log
*.hprof
*.jfr
+121
View File
@@ -0,0 +1,121 @@
Creative Commons Legal Code
CC0 1.0 Universal
CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
HEREUNDER.
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator
and subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for
the purpose of contributing to a commons of creative, cultural and
scientific works ("Commons") that the public can reliably and without fear
of later claims of infringement build upon, modify, incorporate in other
works, reuse and redistribute as freely as possible in any form whatsoever
and for any purposes, including without limitation commercial purposes.
These owners may contribute to the Commons to promote the ideal of a free
culture and the further production of creative, cultural and scientific
works, or to gain reputation or greater distribution for their Work in
part through the use and efforts of others.
For these and/or other purposes and motivations, and without any
expectation of additional consideration or compensation, the person
associating CC0 with a Work (the "Affirmer"), to the extent that he or she
is an owner of Copyright and Related Rights in the Work, voluntarily
elects to apply CC0 to the Work and publicly distribute the Work under its
terms, with knowledge of his or her Copyright and Related Rights in the
Work and the meaning and intended legal effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not
limited to, the following:
i. the right to reproduce, adapt, distribute, perform, display,
communicate, and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or
likeness depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data
in a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation
thereof, including any amended or successor version of such
directive); and
vii. other similar, equivalent or corresponding rights throughout the
world based on applicable law or treaty, and any national
implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention
of, applicable law, Affirmer hereby overtly, fully, permanently,
irrevocably and unconditionally waives, abandons, and surrenders all of
Affirmer's Copyright and Related Rights and associated claims and causes
of action, whether now known or unknown (including existing as well as
future claims and causes of action), in the Work (i) in all territories
worldwide, (ii) for the maximum duration provided by applicable law or
treaty (including future time extensions), (iii) in any current or future
medium and for any number of copies, and (iv) for any purpose whatsoever,
including without limitation commercial, advertising or promotional
purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
member of the public at large and to the detriment of Affirmer's heirs and
successors, fully intending that such Waiver shall not be subject to
revocation, rescission, cancellation, termination, or any other legal or
equitable action to disrupt the quiet enjoyment of the Work by the public
as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason
be judged legally invalid or ineffective under applicable law, then the
Waiver shall be preserved to the maximum extent permitted taking into
account Affirmer's express Statement of Purpose. In addition, to the
extent the Waiver is so judged Affirmer hereby grants to each affected
person a royalty-free, non transferable, non sublicensable, non exclusive,
irrevocable and unconditional license to exercise Affirmer's Copyright and
Related Rights in the Work (i) in all territories worldwide, (ii) for the
maximum duration provided by applicable law or treaty (including future
time extensions), (iii) in any current or future medium and for any number
of copies, and (iv) for any purpose whatsoever, including without
limitation commercial, advertising or promotional purposes (the
"License"). The License shall be deemed effective as of the date CC0 was
applied by Affirmer to the Work. Should any part of the License for any
reason be judged legally invalid or ineffective under applicable law, such
partial invalidity or ineffectiveness shall not invalidate the remainder
of the License, and in such case Affirmer hereby affirms that he or she
will not (i) exercise any of his or her remaining Copyright and Related
Rights in the Work or (ii) assert any associated claims and causes of
action with respect to the Work, in either case contrary to Affirmer's
express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or
warranties of any kind concerning the Work, express, implied,
statutory or otherwise, including without limitation warranties of
title, merchantability, fitness for a particular purpose, non
infringement, or the absence of latent or other defects, accuracy, or
the present or absence of errors, whether or not discoverable, all to
the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without
limitation any person's Copyright and Related Rights in the Work.
Further, Affirmer disclaims responsibility for obtaining any necessary
consents, permissions or other rights required for any use of the
Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to
this CC0 or use of the Work.
+88
View File
@@ -0,0 +1,88 @@
plugins {
id 'fabric-loom' version '1.1-SNAPSHOT'
id 'maven-publish'
id "org.jetbrains.kotlin.jvm" version "1.8.10"
}
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
archivesBaseName = project.archives_base_name
version = project.mod_version
group = project.maven_group
repositories {
// Add repositories to retrieve artifacts from in here.
// You should only use this when depending on other mods because
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
// for more information about repositories.
}
dependencies {
// To change the versions see the gradle.properties file
minecraft "com.mojang:minecraft:${project.minecraft_version}"
mappings "net.fabricmc:yarn:${project.yarn_mappings}:v2"
modImplementation "net.fabricmc:fabric-loader:${project.loader_version}"
// Fabric API. This is technically optional, but you probably want it anyway.
modImplementation "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}"
modImplementation "net.fabricmc:fabric-language-kotlin:${project.fabric_kotlin_version}"
include modImplementation('com.squareup.okio:okio-jvm:3.0.0')
include modImplementation('com.squareup.okhttp3:okhttp:4.10.0')
include modImplementation('org.xerial:sqlite-jdbc:3.39.3.0')
// Uncomment the following line to enable the deprecated Fabric API modules.
// These are included in the Fabric API production distribution and allow you to update your mod to the latest modules at a later more convenient time.
// modImplementation "net.fabricmc.fabric-api:fabric-api-deprecated:${project.fabric_version}"
}
processResources {
inputs.property "version", project.version
filesMatching("fabric.mod.json") {
expand "version": project.version
}
}
tasks.withType(JavaCompile).configureEach {
it.options.release = 17
}
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = 17
}
}
java {
// Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task
// if it is present.
// If you remove this line, sources will not be generated.
withSourcesJar()
}
jar {
from("LICENSE") {
rename { "${it}_${project.archivesBaseName}"}
}
}
// configure the maven publication
publishing {
publications {
mavenJava(MavenPublication) {
from components.java
}
}
// See https://docs.gradle.org/current/userguide/publishing_maven.html for information on how to set up publishing.
repositories {
// Add repositories to publish to here.
// Notice: This block does NOT have the same function as the block in the top level.
// The repositories here will be used for publishing your artifact, not for
// retrieving dependencies.
}
}
+18
View File
@@ -0,0 +1,18 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
org.gradle.parallel=true
# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version=1.18.2
yarn_mappings=1.18.2+build.4
loader_version=0.14.14
fabric_kotlin_version=1.9.1+kotlin.1.8.10
# Mod Properties
mod_version=2.18.5
maven_group=coloryr.allmusic
archives_base_name=[Fabric1.18.2]AllMusic_Server
# Dependencies
fabric_version=0.75.1+1.18.2
Binary file not shown.
@@ -0,0 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
+244
View File
@@ -0,0 +1,244 @@
#!/bin/sh
#
# Copyright © 2015-2021 the original authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
##############################################################################
#
# Gradle start up script for POSIX generated by Gradle.
#
# Important for running:
#
# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
# noncompliant, but you have some other compliant shell such as ksh or
# bash, then to run this script, type that shell name before the whole
# command line, like:
#
# ksh Gradle
#
# Busybox and similar reduced shells will NOT work, because this script
# requires all of these POSIX shell features:
# * functions;
# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
# * compound commands having a testable exit status, especially «case»;
# * various built-in commands including «command», «set», and «ulimit».
#
# Important for patching:
#
# (2) This script targets any POSIX shell, so it avoids extensions provided
# by Bash, Ksh, etc; in particular arrays are avoided.
#
# The "traditional" practice of packing multiple parameters into a
# space-separated string is a well documented source of bugs and security
# problems, so this is (mostly) avoided, by progressively accumulating
# options in "$@", and eventually passing that to Java.
#
# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
# see the in-line comments for details.
#
# There are tweaks for specific operating systems such as AIX, CygWin,
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
#
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
app_path=$0
# Need this for daisy-chained symlinks.
while
APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
[ -h "$app_path" ]
do
ls=$( ls -ld "$app_path" )
link=${ls#*' -> '}
case $link in #(
/*) app_path=$link ;; #(
*) app_path=$APP_HOME$link ;;
esac
done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
warn () {
echo "$*"
} >&2
die () {
echo
echo "$*"
echo
exit 1
} >&2
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "$( uname )" in #(
CYGWIN* ) cygwin=true ;; #(
Darwin* ) darwin=true ;; #(
MSYS* | MINGW* ) msys=true ;; #(
NONSTOP* ) nonstop=true ;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD=$JAVA_HOME/jre/sh/java
else
JAVACMD=$JAVA_HOME/bin/java
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
fi
# Collect all arguments for the java command, stacking in reverse order:
# * args from the command line
# * the main class name
# * -classpath
# * -D...appname settings
# * --module-path (only if needed)
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
# For Cygwin or MSYS, switch paths to Windows format before running java
if "$cygwin" || "$msys" ; then
APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
JAVACMD=$( cygpath --unix "$JAVACMD" )
# Now convert the arguments - kludge to limit ourselves to /bin/sh
for arg do
if
case $arg in #(
-*) false ;; # don't mess with options #(
/?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
[ -e "$t" ] ;; #(
*) false ;;
esac
then
arg=$( cygpath --path --ignore --mixed "$arg" )
fi
# Roll the args list around exactly as many times as the number of
# args, so each arg winds up back in the position where it started, but
# possibly modified.
#
# NB: a `for` loop captures its iteration list before it begins, so
# changing the positional parameters here affects neither the number of
# iterations, nor the values presented in `arg`.
shift # remove old arg
set -- "$@" "$arg" # push replacement arg
done
fi
# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.
set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
-classpath "$CLASSPATH" \
org.gradle.wrapper.GradleWrapperMain \
"$@"
# Stop when "xargs" is not available.
if ! command -v xargs >/dev/null 2>&1
then
die "xargs is not available"
fi
# Use "xargs" to parse quoted args.
#
# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
#
# In Bash we could simply go:
#
# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
# set -- "${ARGS[@]}" "$@"
#
# but POSIX shell has neither arrays nor command substitution, so instead we
# post-process each arg (as a line of input to sed) to backslash-escape any
# character that might be a shell metacharacter, then use eval to reverse
# that process (while maintaining the separation between arguments), and wrap
# the whole thing up as a single "set" statement.
#
# This will of course break if any of these variables contains a newline or
# an unmatched quote.
#
eval "set -- $(
printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
xargs -n1 |
sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
tr '\n' ' '
)" '"$@"'
exec "$JAVACMD" "$@"
+92
View File
@@ -0,0 +1,92 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%"=="" set DIRNAME=.
@rem This is normally unused
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if %ERRORLEVEL% equ 0 goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
set EXIT_CODE=%ERRORLEVEL%
if %EXIT_CODE% equ 0 set EXIT_CODE=1
if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
exit /b %EXIT_CODE%
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+12
View File
@@ -0,0 +1,12 @@
pluginManagement {
repositories {
maven {
name = 'Fabric'
url = 'https://maven.fabricmc.net/'
}
mavenCentral()
gradlePluginPortal()
}
}
rootProject.name = 'AllMusic_Server'
@@ -0,0 +1,54 @@
package coloryr.allmusic;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.side.fabric.CommandFabric;
import coloryr.allmusic.side.fabric.LogFabric;
import coloryr.allmusic.side.fabric.SideFabric;
import coloryr.allmusic.side.fabric.event.MusicAddEvent;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.util.Identifier;
import okio.Buffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Locale;
public class AllMusicFabric implements ModInitializer {
public static MinecraftServer server;
public static final Logger LOGGER = LoggerFactory.getLogger("allmusic");
public static final Identifier ID = new Identifier("allmusic", "channel");
@Override
public void onInitialize() {
String path = "allmusic/";
AllMusic.log = new LogFabric();
AllMusic.side = new SideFabric();
new AllMusic().init(new File(path));
CommandRegistrationCallback.EVENT.register((dispatcher, registryAccess) -> CommandFabric.instance.register(dispatcher));
Buffer buffer = new Buffer();
buffer.close();
ServerLifecycleEvents.SERVER_STARTED.register((a)->{
server = a;
AllMusic.start();
Tasks.init();
});
ServerLifecycleEvents.SERVER_STOPPING.register((a)->{
AllMusic.stop();
});
}
}
@@ -0,0 +1,6 @@
package coloryr.allmusic;
public class TaskItem {
public int tick;
public Runnable run;
}
@@ -0,0 +1,24 @@
package coloryr.allmusic;
import java.util.ArrayList;
import java.util.List;
public class Tasks {
public static List<TaskItem> taskItems = new ArrayList<>();
public static void init() {
AllMusicFabric.server.addServerGuiTickable(Tasks::tick);
}
public static void tick() {
var li = taskItems.iterator();
while (li.hasNext()) {
var item = li.next();
item.tick--;
if (item.tick == 0) {
li.remove();
item.run.run();
}
}
}
}
@@ -0,0 +1,481 @@
package coloryr.allmusic.core;
import coloryr.allmusic.core.hud.DataSql;
import coloryr.allmusic.core.hud.HudUtils;
import coloryr.allmusic.core.music.api.APIMain;
import coloryr.allmusic.core.music.play.MusicSearch;
import coloryr.allmusic.core.music.play.PlayGo;
import coloryr.allmusic.core.music.play.PlayMusic;
import coloryr.allmusic.core.objs.ConfigObj;
import coloryr.allmusic.core.objs.CookieObj;
import coloryr.allmusic.core.objs.MessageObj;
import coloryr.allmusic.core.objs.hud.SaveObj;
import coloryr.allmusic.core.objs.music.SearchPageObj;
import coloryr.allmusic.core.side.IMyLogger;
import coloryr.allmusic.core.side.ISide;
import coloryr.allmusic.core.sql.IEconomy;
import coloryr.allmusic.core.utils.Logs;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.*;
public class AllMusic {
public static final Gson gson = new Gson();
/**
* 客户端插件信道名
*/
public static final String channel = "allmusic:channel";
/**
* BC插件信道名
*/
public static final String channelBC = "allmusic:channelbc";
/**
* 插件版本号
*/
public static final String version = "2.18.5";
/**
* 配置文件版本号
*/
public static final String configVersion = "103";
/**
* 语言文件配置版本号
*/
public static final String messageVersion = "103";
/**
* 搜歌结果
* 玩家名 结果
*/
private static final Map<String, SearchPageObj> searchSave = new HashMap<>();
/**
* 投票的玩家
*/
private static final List<String> votePlayer = new ArrayList<>();
/**
* 正在播放的玩家
*/
private static final List<String> nowPlayPlayer = new ArrayList<>();
/**
* 日志
*/
public static IMyLogger log;
/**
* 服务器端操作
*/
public static ISide side;
/**
* 是否在运行
*/
public static boolean isRun;
/**
* Cookie对象
*/
public static CookieObj cookie;
/**
* 经济插件对象
*/
public static IEconomy economy;
/**
* 网易API
*/
private static APIMain apiMusic;
/**
* 配置对象
*/
private static ConfigObj config;
/**
* 语言对象
*/
private static MessageObj message;
/**
* 配置文件
*/
private static File configFile;
/**
* Cookie文件
*/
private static File cookieFile;
/**
* 语言文件
*/
private static File messageFile;
/**
* 检查配置文件完整性
*/
public static void configCheck() {
if (config == null) {
config = ConfigObj.makeDefault();
log.warning("§d[AllMusic]§c配置文件config.json错误,已覆盖");
save();
} else if (config.check()) {
log.warning("§d[AllMusic]§c配置文件config.json错误,已覆盖");
save();
}
}
/**
* 检查语言文件完整性
*/
private static void messageCheck() {
if (message == null) {
message = new MessageObj();
log.warning("§d[AllMusic]§c配置文件message.json错误,已覆盖");
save();
} else if (message.check()) {
log.warning("§d[AllMusic]§c配置文件message.json错误,已覆盖");
save();
}
}
/**
* 检查是否需要
*
* @param name 用户名
* @param server 服务器名
* @param checkList 是否检查正在播放的列表
* @return 结果
*/
public static boolean isOK(String name, String server, boolean checkList) {
try {
if (AllMusic.getConfig().NoMusicServer
.contains(server))
return true;
if (server != null && AllMusic.getConfig().NoMusicPlayer.contains(name))
return true;
if (!checkList)
return false;
return AllMusic.containNowPlay(name);
} catch (NoSuchElementException e) {
return true;
}
}
/**
* 是否存在正在播放的玩家
*
* @param player 用户名
* @return 是否存在
*/
public static boolean containNowPlay(String player) {
return !nowPlayPlayer.contains(player);
}
/**
* 获取配置文件
*
* @return 配置对象
*/
public static ConfigObj getConfig() {
if (config == null) {
log.warning("§d[AllMusic]§c配置文件config.json错误,已使用默认配置文件");
config = ConfigObj.makeDefault();
}
return config;
}
/**
* 获取语言文件
*
* @return 语言对象
*/
public static MessageObj getMessage() {
if (message == null) {
log.warning("§d[AllMusic]§c配置文件message.json错误,已使用默认配置文件");
message = new MessageObj();
}
return message;
}
/**
* 添加搜歌结果
*
* @param player 用户名
* @param page 结果
*/
public static void addSearch(String player, SearchPageObj page) {
searchSave.put(player, page);
}
/**
* 获取搜歌结果
*
* @param player 用户名
* @return 结果
*/
public static SearchPageObj getSearch(String player) {
return searchSave.get(player);
}
/**
* 删除搜歌结果
*
* @param player 用户名
*/
public static void removeSearch(String player) {
searchSave.remove(player);
}
/**
* 添加投票的玩家
*
* @param player 用户名
*/
public static void addVote(String player) {
if (!votePlayer.contains(player))
votePlayer.add(player);
}
/**
* 获取投票数量
*
* @return 数量
*/
public static int getVoteCount() {
return votePlayer.size();
}
/**
* 清空投票
*/
public static void clearVote() {
votePlayer.clear();
}
/**
* 是否已经投票了
*
* @param player 用户名
* @return 结果
*/
public static boolean containVote(String player) {
return votePlayer.contains(player);
}
/**
* 添加正在播放的玩家
*
* @param player 用户名
*/
public static void addNowPlayPlayer(String player) {
if (!nowPlayPlayer.contains(player))
nowPlayPlayer.add(player);
}
/**
* 删除正在播放的玩家
*
* @param player 用户名
*/
public static void removeNowPlayPlayer(String player) {
nowPlayPlayer.remove(player);
}
/**
* 清空正在播放玩家的列表
*/
public static void clearNowPlayer() {
nowPlayPlayer.clear();
}
/**
* 保存配置文件
*/
public static void save() {
try {
String data = new GsonBuilder().setPrettyPrinting().create().toJson(config);
FileOutputStream out = new FileOutputStream(configFile);
OutputStreamWriter write = new OutputStreamWriter(
out, StandardCharsets.UTF_8);
write.write(data);
write.close();
data = new GsonBuilder().setPrettyPrinting().create().toJson(message);
out = new FileOutputStream(messageFile);
write = new OutputStreamWriter(
out, StandardCharsets.UTF_8);
write.write(data);
write.close();
} catch (Exception e) {
log.warning("§d[AllMusic]§c配置文件保存错误");
e.printStackTrace();
}
}
/**
* 保存Cookie
*/
public static void saveCookie() {
try {
String data = new GsonBuilder().setPrettyPrinting().create().toJson(cookie);
FileOutputStream out = new FileOutputStream(cookieFile);
OutputStreamWriter write = new OutputStreamWriter(
out, StandardCharsets.UTF_8);
write.write(data);
write.close();
} catch (Exception e) {
log.warning("§d[AllMusic]§c配置文件保存错误");
e.printStackTrace();
}
}
/**
* 启动插件
*/
public static void start() {
PlayMusic.start();
PlayGo.start();
MusicSearch.start();
DataSql.start();
log.info("§d[AllMusic]§e已启动-" + version);
}
/**
* 停止插件
*/
public static void stop() {
try {
clearVote();
Logs.stop();
side.sendStop();
MusicSearch.stop();
PlayMusic.stop();
PlayGo.stop();
DataSql.stop();
} catch (IOException e) {
e.printStackTrace();
}
log.info("§d[AllMusic]§2§e已停止,感谢使用");
}
/**
* 获取音乐API
*
* @return 音乐API
*/
public static APIMain getMusicApi() {
if (apiMusic == null) {
AllMusic.apiMusic = new APIMain();
}
return apiMusic;
}
/**
* 加载配置文件
*/
private static void loadConfig() {
try {
InputStreamReader reader = new InputStreamReader(
Files.newInputStream(configFile.toPath()), StandardCharsets.UTF_8);
BufferedReader bf = new BufferedReader(reader);
config = new Gson().fromJson(bf, ConfigObj.class);
bf.close();
reader.close();
configCheck();
reader = new InputStreamReader(Files.newInputStream(messageFile.toPath()), StandardCharsets.UTF_8);
bf = new BufferedReader(reader);
message = new Gson().fromJson(bf, MessageObj.class);
bf.close();
reader.close();
messageCheck();
log.info("§d[AllMusic]§e当前语言配置文件版本为:" + messageVersion
+ ",你的语言文件版本为:" + config.Version);
if (!message.Version.equalsIgnoreCase(messageVersion)) {
log.warning("§d[AllMusic]§c语言文件版本号错误,运行可能会发生问题,请删除后重载");
}
reader = new InputStreamReader(Files.newInputStream(cookieFile.toPath()), StandardCharsets.UTF_8);
bf = new BufferedReader(reader);
cookie = new Gson().fromJson(bf, CookieObj.class);
bf.close();
reader.close();
if (cookie == null) {
cookie = new CookieObj();
saveCookie();
}
log.info("§d[AllMusic]§e当前插件配置文件版本为:" + configVersion
+ ",你的配置文件版本为:" + config.Version);
if (!AllMusic.configVersion.equalsIgnoreCase(config.Version)) {
log.warning("§d[AllMusic]§c请及时更新配置文件");
}
} catch (Exception e) {
log.warning("§d[AllMusic]§c读取配置文件错误");
e.printStackTrace();
}
}
/**
* 加入时播放
*
* @param player 用户名
*/
public static void joinPlay(String player) {
if (getConfig().NoMusicPlayer.contains(player))
return;
AllMusic.side.runTask(() -> {
if (PlayMusic.nowPlayMusic != null) {
SaveObj obj = HudUtils.get(player);
String data = gson.toJson(obj);
AllMusic.side.send(data, player);
AllMusic.side.sendMusic(player, PlayGo.url);
if (!PlayMusic.nowPlayMusic.isUrl()) {
AllMusic.side.runTask(() ->
AllMusic.side.sendPic(player, PlayMusic.nowPlayMusic.getPicUrl()), 15);
}
AllMusic.side.runTask(() ->
AllMusic.side.sendPos(player, PlayMusic.musicNowTime + 1000), 40);
}
}, 40);
}
/**
* 读取配置文件
*
* @param file 配置文件文件夹
*/
public void init(File file) {
log.info("§d[AllMusic]§2§e正在启动,感谢使用,本插件交流群:571239090");
try {
if (!file.exists())
file.mkdir();
if (configFile == null)
configFile = new File(file, "config.json");
if (messageFile == null)
messageFile = new File(file, "message.json");
if (cookieFile == null)
cookieFile = new File(file, "cookie.json");
if (Logs.file == null)
Logs.file = new File(file, "logs.log");
if (DataSql.sqlFile == null)
DataSql.sqlFile = new File(file, "data.db");
if (!configFile.exists()) {
Files.copy(this.getClass().getResourceAsStream("/config.json"), configFile.toPath());
}
if (!messageFile.exists()) {
Files.copy(this.getClass().getResourceAsStream("/message.json"), messageFile.toPath());
}
if (!cookieFile.exists()) {
cookieFile.createNewFile();
}
if (!Logs.file.exists()) {
Logs.file.createNewFile();
}
loadConfig();
isRun = true;
} catch (IOException e) {
isRun = false;
log.warning("§d[AllMusic]§c启动失败");
e.printStackTrace();
}
}
}
@@ -0,0 +1,68 @@
package coloryr.allmusic.core;
import coloryr.allmusic.core.enums.HudPos;
import coloryr.allmusic.core.side.ComType;
public class AllMusicAPI {
/**
* 发送播放音乐
*
* @param name 用户名
* @param url 链接
*/
public static void playMusic(String name, String url) {
AllMusic.side.send(name, ComType.play + url);
}
/**
* 更新玩家Hud数据
*
* @param name 用户名
* @param pos 位置
* @param data 数据
*/
public static void sendHud(String name, HudPos pos, String data) {
String temp = getType(pos);
if (temp == null)
return;
AllMusic.side.send(name, temp + data);
}
/**
* 发送图片
*
* @param name 用户名
* @param url 图片地址
*/
public static void sendPic(String name, String url) {
AllMusic.side.send(name, ComType.img + url);
}
/**
* 停止播放
*
* @param name 用户名
*/
public static void sendStop(String name) {
AllMusic.side.sendStop(name);
}
/**
* 获取位置字符串
*
* @param pos 位置
* @return 字符串
*/
private static String getType(HudPos pos) {
switch (pos) {
case info:
return ComType.info;
case lyric:
return ComType.lyric;
case list:
return ComType.list;
}
return null;
}
}
@@ -0,0 +1,510 @@
package coloryr.allmusic.core.command;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.hud.HudUtils;
import coloryr.allmusic.core.music.play.MusicSearch;
import coloryr.allmusic.core.music.play.PlayMusic;
import coloryr.allmusic.core.objs.SearchMusicObj;
import coloryr.allmusic.core.objs.hud.PosObj;
import coloryr.allmusic.core.objs.music.MusicObj;
import coloryr.allmusic.core.objs.music.SearchPageObj;
import coloryr.allmusic.core.utils.Function;
import java.util.Locale;
public class CommandEX {
/**
* 搜索音乐
*
* @param sender 发送者
* @param name 用户名
* @param args 参数
* @param isDefault 是否是默认点歌方式
*/
private static void searchMusic(Object sender, String name, String[] args, boolean isDefault) {
MusicObj obj = new MusicObj();
obj.sender = sender;
obj.name = name;
obj.args = args;
obj.isDefault = isDefault;
if (AllMusic.side.onMusicAdd(sender, obj)) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.Cancel);
return;
}
MusicSearch.addSearch(obj);
}
/**
* 检查金额是否够
*
* @param sender 发送者
* @param name 用户名
* @param cost 金额
* @return 结果
*/
private static boolean checkMoney(Object sender, String name, int cost) {
if (!AllMusic.getConfig().UseCost || AllMusic.economy == null) {
return false;
}
if (!AllMusic.economy.check(name, cost)) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Cost.NoMoney);
return true;
}
return false;
}
/**
* 扣钱
*
* @param sender 发送者
* @param name 用户名
* @param cost 金额
* @param message 结果消息
* @return 结果
*/
private static boolean cost(Object sender, String name, int cost, String message) {
if (!AllMusic.getConfig().UseCost || AllMusic.economy == null) {
return false;
}
if (AllMusic.economy.cost(name, cost)) {
AllMusic.side.sendMessage(sender, message
.replace("%Cost%", "" + cost));
return false;
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Cost.CostFail);
return true;
}
}
/**
* 添加音乐
*
* @param sender 发送者
* @param name 用户名
* @param args 参数
*/
private static void addMusic(Object sender, String name, String[] args) {
String musicID;
if (args[0].contains("id=") && !args[0].contains("/?userid")) {
if (args[0].contains("&user"))
musicID = Function.getString(args[0], "id=", "&user");
else
musicID = Function.getString(args[0], "id=", null);
} else if (args[0].contains("song/")) {
if (args[0].contains("/?userid"))
musicID = Function.getString(args[0], "song/", "/?userid");
else
musicID = Function.getString(args[0], "song/", null);
} else
musicID = args[0];
if (Function.isInteger(musicID)) {
if (PlayMusic.getSize() >= AllMusic.getConfig().MaxList) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.ListFull);
} else if (AllMusic.getConfig().BanMusic.contains(musicID)) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.BanMusic);
} else if (PlayMusic.isHave(musicID)) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.ExistMusic);
} else {
if (checkMoney(sender, name, AllMusic.getConfig().AddMusicCost)) {
return;
}
if (cost(sender, name, AllMusic.getConfig().AddMusicCost,
AllMusic.getMessage().Cost.AddMusic)) {
return;
}
AllMusic.getConfig().RemoveNoMusicPlayer(name);
if (AllMusic.side.needPlay()) {
MusicObj obj = new MusicObj();
obj.sender = sender;
obj.id = musicID;
obj.name = name;
obj.isDefault = false;
if (AllMusic.side.onMusicAdd(sender, obj)) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.Cancel);
return;
}
PlayMusic.addTask(obj);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.Success);
} else
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.NoPlayer);
}
} else
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.NoID);
}
/**
* 展示搜歌结果
*
* @param sender 发送者
* @param search 搜歌结果
*/
public static void showSearch(Object sender, SearchPageObj search) {
int index = search.getIndex();
SearchMusicObj item;
String info;
AllMusic.side.sendMessage(sender, "");
if (search.haveLastPage()) {
AllMusic.side.sendMessageRun(sender, "§d[AllMusic]§2输入/music lastpage上一页",
AllMusic.getMessage().Page.Last, "/music lastpage");
}
for (int a = 0; a < index; a++) {
item = search.getRes(a + search.getPage() * 10);
info = AllMusic.getMessage().Page.Choice;
info = info.replace("%index%", "" + (a + 1))
.replace("%MusicName%", item.name)
.replace("%MusicAuthor%", item.author)
.replace("%MusicAl%", item.al);
AllMusic.side.sendMessageRun(sender, info,
AllMusic.getMessage().Click.This, "/music select " + (a + 1));
}
if (search.haveNextPage()) {
AllMusic.side.sendMessageRun(sender, "§d[AllMusic]§2输入/music nextpage下一页",
AllMusic.getMessage().Page.Next, "/music nextpage");
}
AllMusic.side.sendMessage(sender, "");
}
/**
* 执行命令
*
* @param sender 发送者
* @param name 用户名
* @param args 参数
*/
public static void ex(Object sender, String name, String[] args) {
if (args.length == 0) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
return;
} else if (args[0].equalsIgnoreCase("help")) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Help.Normal.Head);
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Base,
AllMusic.getMessage().Click.Check, "/music ");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Normal.Stop,
AllMusic.getMessage().Click.This, "/music stop");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Normal.List,
AllMusic.getMessage().Click.This, "/music list");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Normal.Vote,
AllMusic.getMessage().Click.This, "/music vote");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Normal.NoMusic,
AllMusic.getMessage().Click.This, "/music nomusic");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Search,
AllMusic.getMessage().Click.Check, "/music search ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Select,
AllMusic.getMessage().Click.Check, "/music select ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Hud1,
AllMusic.getMessage().Click.Check, "/music hud enable ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Hud2,
AllMusic.getMessage().Click.Check, "/music hud ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Hud3,
AllMusic.getMessage().Click.Check, "/music hud picsize ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Hud4,
AllMusic.getMessage().Click.Check, "/music hud picrotate ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Normal.Hud5,
AllMusic.getMessage().Click.Check, "/music hud picrotatespeed ");
if (AllMusic.getConfig().Admin.contains(name)) {
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Admin.Reload,
AllMusic.getMessage().Click.This, "/music reload");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Admin.Next,
AllMusic.getMessage().Click.This, "/music next");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Admin.Ban,
AllMusic.getMessage().Click.Check, "/music ban ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Admin.Url,
AllMusic.getMessage().Click.Check, "/music url ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Admin.Delete,
AllMusic.getMessage().Click.Check, "/music delete ");
AllMusic.side.sendMessageSuggest(sender, AllMusic.getMessage().Help.Admin.AddList,
AllMusic.getMessage().Click.Check, "/music addlist ");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Admin.ClearList,
AllMusic.getMessage().Click.This, "/music clearlist");
AllMusic.side.sendMessageRun(sender, AllMusic.getMessage().Help.Admin.Login,
AllMusic.getMessage().Click.This, "/music login");
}
return;
} else if (args[0].equalsIgnoreCase("stop")) {
AllMusic.side.clearHud(name);
AllMusic.side.sendStop(name);
HudUtils.clearHud(name);
AllMusic.removeNowPlayPlayer(name);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().MusicPlay.StopPlay);
return;
} else if (args[0].equalsIgnoreCase("list")) {
if (PlayMusic.nowPlayMusic == null || PlayMusic.nowPlayMusic.isNull()) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().MusicPlay.NoMusic);
} else {
String info = AllMusic.getMessage().MusicPlay.Play;
info = info.replace("%MusicName%", PlayMusic.nowPlayMusic.getName())
.replace("%MusicAuthor%", PlayMusic.nowPlayMusic.getAuthor())
.replace("%MusicAl%", PlayMusic.nowPlayMusic.getAl())
.replace("%MusicAlia%", PlayMusic.nowPlayMusic.getAlia())
.replace("%PlayerName%", PlayMusic.nowPlayMusic.getCall());
AllMusic.side.sendMessage(sender, info);
}
if (PlayMusic.getSize() == 0) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().MusicPlay.NoPlay);
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().MusicPlay.ListMusic.Head
.replace("&Count&", "" + PlayMusic.getSize()));
AllMusic.side.sendMessage(sender, PlayMusic.getAllList());
}
return;
} else if (args[0].equalsIgnoreCase("vote")) {
if (AllMusic.getConfig().NeedPermission &&
AllMusic.side.checkPermission(name, "allmusic.vote")) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Vote.NoPermission);
return;
}
if (PlayMusic.getSize() == 0 && AllMusic.getConfig().PlayList.size() == 0) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().MusicPlay.NoPlay);
} else if (PlayMusic.voteTime == 0) {
PlayMusic.voteTime = 30;
AllMusic.addVote(name);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Vote.DoVote);
String data = AllMusic.getMessage().Vote.BQ;
AllMusic.side.bq(data.replace("%PlayerName%", name));
} else if (PlayMusic.voteTime > 0) {
if (!AllMusic.containVote(name)) {
AllMusic.addVote(name);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Vote.Agree);
String data = AllMusic.getMessage().Vote.BQAgree;
data = data.replace("%PlayerName%", name)
.replace("%Count%", "" + AllMusic.getVoteCount());
AllMusic.side.bq(data);
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Vote.ARAgree);
}
}
AllMusic.getConfig().RemoveNoMusicPlayer(name);
return;
} else if (args[0].equalsIgnoreCase("nomusic")) {
AllMusic.side.sendStop(name);
AllMusic.side.clearHud(name);
AllMusic.getConfig().AddNoMusicPlayer(name);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().MusicPlay.NoPlayMusic);
return;
} else if (args[0].equalsIgnoreCase("search") && args.length >= 2) {
if (AllMusic.getConfig().NeedPermission &&
AllMusic.side.checkPermission(name, "allmusic.search")) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoPer);
return;
}
if (checkMoney(sender, name, AllMusic.getConfig().SearchCost)) {
return;
}
if (cost(sender, name, AllMusic.getConfig().SearchCost,
AllMusic.getMessage().Cost.Search)) {
return;
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.StartSearch);
searchMusic(sender, name, args, false);
return;
} else if (args[0].equalsIgnoreCase("select") && args.length == 2) {
if (AllMusic.getConfig().NeedPermission &&
AllMusic.side.checkPermission(name, "allmusic.search")) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoPer);
return;
}
SearchPageObj obj = AllMusic.getSearch(name);
if (obj == null) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoSearch);
} else if (!args[1].isEmpty() && Function.isInteger(args[1])) {
int a = Integer.parseInt(args[1]);
if (a == 0) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.ErrorNum);
return;
}
String[] ID = new String[1];
ID[0] = obj.getSong((obj.getPage() * 10) + (a - 1));
AllMusic.side.sendMessage(sender,
AllMusic.getMessage().Search.Chose.replace("%Num%", "" + a));
addMusic(sender, name, ID);
AllMusic.removeSearch(name);
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.ErrorNum);
}
return;
} else if (args[0].equalsIgnoreCase("nextpage")) {
if (AllMusic.getConfig().NeedPermission &&
AllMusic.side.checkPermission(name, "allmusic.search")) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoPer);
return;
}
SearchPageObj obj = AllMusic.getSearch(name);
if (obj == null) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoSearch);
} else if (obj.nextPage()) {
showSearch(sender, obj);
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.CantNext);
}
return;
} else if (args[0].equalsIgnoreCase("lastpage")) {
if (AllMusic.getConfig().NeedPermission &&
AllMusic.side.checkPermission(name, "allmusic.search")) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoPer);
return;
}
SearchPageObj obj = AllMusic.getSearch(name);
if (obj == null) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.NoSearch);
} else if (obj.lastPage()) {
showSearch(sender, obj);
} else {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Search.CantLast);
}
return;
} else if (args[0].equalsIgnoreCase("hud")) {
if (args.length == 1) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
} else {
if (args[1].equalsIgnoreCase("enable")) {
if (args.length == 3) {
try {
String pos = args[2].toLowerCase(Locale.ROOT);
boolean temp = HudUtils.setHudEnable(name, pos);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Hud.State
.replace("%State%", temp ? "启用" : "关闭")
.replace("%Hud%", AllMusic.getMessage().HudList.Get(pos)));
} catch (Exception e) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
}
} else {
boolean temp = HudUtils.setHudEnable(name, null);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Hud.State
.replace("%State%", temp ? "启用" : "关闭")
.replace("%Hud%", AllMusic.getMessage().HudList.All));
}
} else if (args[1].equalsIgnoreCase("reset")) {
HudUtils.reset(name);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Hud.Reset);
} else if (args[1].equalsIgnoreCase("picsize")) {
if (args.length != 3 || !HudUtils.setPicSize(name, args[2])) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
return;
}
AllMusic.side.sendMessage(sender,
AllMusic.getMessage().Hud.PicSize.replace("%Size%", args[2]));
} else if (args[1].equalsIgnoreCase("picrotate")) {
if (args.length != 3) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
return;
}
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Hud.PicRotate
.replace("%State%", String.valueOf(HudUtils.setPicRotate(name, args[2]))));
} else if (args[1].equalsIgnoreCase("picrotatespeed")) {
if (args.length != 3 || !HudUtils.setPicRotateSpeed(name, args[2])) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
return;
}
AllMusic.side.sendMessage(sender,
AllMusic.getMessage().Hud.PicRotateSpeed.replace("%Size%", args[2]));
} else if (args.length != 4) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
} else {
try {
PosObj obj = HudUtils.setHudPos(name, args[1], args[2], args[3]);
if (obj == null) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
} else {
String temp = AllMusic.getMessage().Hud.Set
.replace("%Hud%", args[1])
.replace("%x%", args[2])
.replace("%y%", args[3]);
AllMusic.side.sendMessage(sender, temp);
}
} catch (Exception e) {
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.Error);
}
}
}
return;
} else if (args[0].equalsIgnoreCase("reload")) {
AllMusic.side.reload();
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2已重读配置文件");
return;
} else if (AllMusic.getConfig().Admin.contains(name)) {
if (args[0].equalsIgnoreCase("next")) {
PlayMusic.musicLessTime = 1;
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2已强制切歌");
AllMusic.getConfig().RemoveNoMusicPlayer(name);
return;
} else if (args[0].equalsIgnoreCase("ban") && args.length == 2) {
if (Function.isInteger(args[1])) {
AllMusic.getConfig().addBanID(args[1]);
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2已禁止" + args[1]);
} else {
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2请输入有效的ID");
}
return;
} else if (args[0].equalsIgnoreCase("url") && args.length == 2) {
MusicObj obj = new MusicObj();
obj.sender = sender;
obj.isUrl = true;
obj.url = args[1];
PlayMusic.addTask(obj);
AllMusic.side.sendMessage(sender, AllMusic.getMessage().AddMusic.Success);
return;
} else if (args[0].equalsIgnoreCase("delete") && args.length == 2) {
if (!args[1].isEmpty() && Function.isInteger(args[1])) {
int music = Integer.parseInt(args[1]);
if (music == 0) {
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2请输入有效的序列ID");
return;
}
if (music > PlayMusic.getSize()) {
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2序列号过大");
return;
}
PlayMusic.remove(music - 1);
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2已删除序列" + music);
} else {
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2请输入有效的序列ID");
}
return;
} else if (args[0].equalsIgnoreCase("addlist") && args.length == 2) {
if (Function.isInteger(args[1])) {
AllMusic.getMusicApi().setList(args[1], sender);
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2添加空闲音乐列表" + args[1]);
} else {
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2请输入有效的音乐列表ID");
}
return;
} else if (args[0].equalsIgnoreCase("clearlist")) {
AllMusic.getConfig().PlayList.clear();
AllMusic.save();
AllMusic.side.sendMessage(sender, "§d[AllMusic]§2添加空闲音乐列表已清空");
return;
} else if (args[0].equalsIgnoreCase("code")) {
AllMusic.getMusicApi().sendCode(sender);
return;
} else if (args[0].equalsIgnoreCase("login")) {
if (args.length != 2) {
AllMusic.side.sendMessage(sender, "§d[AllMusic]§c没有手机验证码");
return;
}
AllMusic.side.sendMessage(sender, "§d[AllMusic]§d重新登录网易云账户");
AllMusic.getMusicApi().login(sender, args[1]);
return;
}
}
if (AllMusic.getConfig().NeedPermission &&
AllMusic.side.checkPermission(name, "allmusic.addmusic"))
AllMusic.side.sendMessage(sender, AllMusic.getMessage().Command.NoPer);
else {
switch (AllMusic.getConfig().DefaultAddMusic) {
case 1:
searchMusic(sender, name, args, true);
break;
case 0:
default:
addMusic(sender, name, args);
}
}
}
}
@@ -0,0 +1,101 @@
package coloryr.allmusic.core.command;
import coloryr.allmusic.core.AllMusic;
import java.util.ArrayList;
import java.util.List;
public class TabCommand {
/**
* 个人的指令
*/
private static final List<String> normal = new ArrayList<String>() {{
this.add("stop");
this.add("list");
this.add("vote");
this.add("nomusic");
this.add("search");
this.add("hud");
}};
/**
* 搜歌的指令
*/
private static final List<String> search = new ArrayList<String>() {{
this.add("select");
this.add("nextpage");
this.add("lastpage");
}};
/**
* 管理员的指令
*/
private static final List<String> admin = new ArrayList<String>() {{
this.add("reload");
this.add("next");
this.add("ban");
this.add("delete");
this.add("addlist");
this.add("clearlist");
this.add("login");
}};
/**
* Hud的指令
*/
private static final List<String> hudlist = new ArrayList<String>() {{
this.add("info");
this.add("list");
this.add("lyric");
this.add("pic");
}};
/**
* Hud的指令
*/
private static final List<String> hud = new ArrayList<String>() {{
this.add("info");
this.add("list");
this.add("lyric");
this.add("pic");
this.add("picsize");
this.add("picrotate");
this.add("picrotatespeed");
this.add("enable");
this.add("reset");
}};
/**
* 获取Tab指令列表
*
* @param name 用户名
* @param arg 参数
* @return 指令列表
*/
public static List<String> getTabList(String name, String[] arg) {
List<String> arguments = new ArrayList<>();
if (arg.length == 0 || arg.length == 1) {
arguments.addAll(normal);
if (AllMusic.getSearch(name) != null) {
arguments.addAll(search);
}
if (AllMusic.getConfig().Admin.contains(name)) {
arguments.addAll(admin);
}
} else if (arg.length == 2) {
if ("hud".equalsIgnoreCase(arg[0]) &&
"enable".equalsIgnoreCase(arg[1])) {
arguments.addAll(hudlist);
}
else if ("hud".equalsIgnoreCase(arg[0])) {
arguments.addAll(hud);
}
} else if (arg.length == 3) {
if ("hud".equalsIgnoreCase(arg[0]) &&
"enable".equalsIgnoreCase(arg[1])) {
arguments.addAll(hudlist);
}
}
return arguments;
}
}
@@ -0,0 +1,536 @@
/*
* 11/19/04 1.0 moved to LGPL.
*
* 11/17/04 Uncomplete frames discarded. E.B, [email protected]
*
* 12/05/03 ID3v2 tag returned. E.B, [email protected]
*
* 12/12/99 Based on Ibitstream. Exceptions thrown on errors,
* Temporary removed seek functionality. [email protected]
*
* 02/12/99 : Java Conversion by E.B , [email protected]
*
* 04/14/97 : Added function prototypes for new syncing and seeking
* mechanisms. Also made this file portable. Changes made by Jeff Tsay
*
* @(#) ibitstream.h 1.5, last edit: 6/15/94 16:55:34
* @(#) Copyright (C) 1993, 1994 Tobias Bading ([email protected])
* @(#) Berlin University of Technology
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
import java.io.*;
/**
* The <code>Bistream</code> class is responsible for parsing
* an MPEG audio bitstream.
*
* <b>REVIEW:</b> much of the parsing currently occurs in the
* various decoders. This should be moved into this class and associated
* inner classes.
*/
public final class Bitstream implements BitstreamErrors {
/**
* Maximum size of the frame buffer.
*/
private static final int BUFFER_INT_SIZE = 433;
/**
* Synchronization control constant for the initial
* synchronization to the start of a frame.
*/
static byte INITIAL_SYNC = 0;
// max. 1730 bytes per frame: 144 * 384kbit/s / 32000 Hz + 2 Bytes CRC
/**
* Synchronization control constant for non-initial frame
* synchronizations.
*/
static byte STRICT_SYNC = 1;
/**
* The frame buffer that holds the data for the current frame.
*/
private final int[] framebuffer = new int[BUFFER_INT_SIZE];
private final int[] bitmask = {0, // dummy
0x00000001, 0x00000003, 0x00000007, 0x0000000F,
0x0000001F, 0x0000003F, 0x0000007F, 0x000000FF,
0x000001FF, 0x000003FF, 0x000007FF, 0x00000FFF,
0x00001FFF, 0x00003FFF, 0x00007FFF, 0x0000FFFF,
0x0001FFFF};
private final PushbackInputStream source;
private final Header header = new Header();
private final byte[] syncbuf = new byte[4];
/**
* The bytes read from the stream.
*/
private final byte[] frame_bytes = new byte[BUFFER_INT_SIZE * 4];
private final Crc16[] crc = new Crc16[1];
/**
* Number of valid bytes in the frame buffer.
*/
private int framesize;
//private int current_frame_number;
//private int last_frame_number;
/**
* Index into <code>framebuffer</code> where the next bits are
* retrieved.
*/
private int wordpointer;
/**
* Number (0-31, from MSB to LSB) of next bit for get_bits()
*/
private int bitindex;
/**
* The current specified syncword
*/
private int syncword;
/**
* Audio header position in stream.
*/
private int header_pos = 0;
/**
*
*/
private boolean single_ch_mode;
private byte[] rawid3v2 = null;
private boolean firstframe = true;
/**
* Construct a IBitstream that reads data from a
* given InputStream.
*
* @param in The InputStream to read from.
*/
public Bitstream(InputStream in) {
if (in == null) throw new NullPointerException("in");
in = new BufferedInputStream(in);
loadID3v2(in);
firstframe = true;
//source = new PushbackInputStream(in, 1024);
source = new PushbackInputStream(in, BUFFER_INT_SIZE * 4);
closeFrame();
//current_frame_number = -1;
//last_frame_number = -1;
}
/**
* Return position of the first audio header.
*
* @return size of ID3v2 tag frames.
*/
public int header_pos() {
return header_pos;
}
/**
* Load ID3v2 frames.
*
* @param in MP3 InputStream.
* @author JavaZOOM
*/
private void loadID3v2(InputStream in) {
int size = -1;
try {
// Read ID3v2 header (10 bytes).
in.mark(10);
size = readID3v2Header(in);
header_pos = size;
} catch (IOException e) {
} finally {
try {
// Unread ID3v2 header (10 bytes).
in.reset();
} catch (IOException e) {
}
}
// Load ID3v2 tags.
try {
if (size > 0) {
rawid3v2 = new byte[size];
in.read(rawid3v2, 0, rawid3v2.length);
}
} catch (IOException e) {
}
}
/**
* Parse ID3v2 tag header to find out size of ID3v2 frames.
*
* @param in MP3 InputStream
* @return size of ID3v2 frames + header
* @throws IOException
* @author JavaZOOM
*/
private int readID3v2Header(InputStream in) throws IOException {
byte[] id3header = new byte[4];
int size = -10;
in.read(id3header, 0, 3);
// Look for ID3v2
if ((id3header[0] == 'I') && (id3header[1] == 'D') && (id3header[2] == '3')) {
in.read(id3header, 0, 3);
int majorVersion = id3header[0];
int revision = id3header[1];
in.read(id3header, 0, 4);
size = (id3header[0] << 21) + (id3header[1] << 14) + (id3header[2] << 7) + (id3header[3]);
}
return (size + 10);
}
/**
* Return raw ID3v2 frames + header.
*
* @return ID3v2 InputStream or null if ID3v2 frames are not available.
*/
public InputStream getRawID3v2() {
if (rawid3v2 == null) return null;
else {
return new ByteArrayInputStream(rawid3v2);
}
}
/**
* Close the Bitstream.
*
* @throws BitstreamException
*/
public void close() throws BitstreamException {
try {
source.close();
} catch (IOException ex) {
throw newBitstreamException(STREAM_ERROR, ex);
}
}
/**
* Reads and parses the next frame from the input source.
*
* @return the Header describing details of the frame read,
* or null if the end of the stream has been reached.
*/
public Header readFrame() throws BitstreamException {
Header result = null;
try {
result = readNextFrame();
// E.B, Parse VBR (if any) first frame.
if (firstframe) {
result.parseVBR(frame_bytes);
firstframe = false;
}
} catch (BitstreamException ex) {
if ((ex.getErrorCode() == INVALIDFRAME)) {
// Try to skip this frame.
//System.out.println("INVALIDFRAME");
try {
closeFrame();
result = readNextFrame();
} catch (BitstreamException e) {
if ((e.getErrorCode() != STREAM_EOF)) {
// wrap original exception so stack trace is maintained.
throw newBitstreamException(e.getErrorCode(), e);
}
}
} else if ((ex.getErrorCode() != STREAM_EOF)) {
// wrap original exception so stack trace is maintained.
throw newBitstreamException(ex.getErrorCode(), ex);
}
}
return result;
}
/**
* Read next MP3 frame.
*
* @return MP3 frame header.
* @throws BitstreamException
*/
private Header readNextFrame() throws BitstreamException {
if (framesize == -1) {
nextFrame();
}
return header;
}
/**
* Read next MP3 frame.
*
* @throws BitstreamException
*/
private void nextFrame() throws BitstreamException {
// entire frame is read by the header class.
header.read_header(this, crc);
}
/**
* Unreads the bytes read from the frame.
*
* @throws BitstreamException
*/
// REVIEW: add new error codes for this.
public void unreadFrame() throws BitstreamException {
if (wordpointer == -1 && bitindex == -1 && (framesize > 0)) {
try {
source.unread(frame_bytes, 0, framesize);
} catch (IOException ex) {
throw newBitstreamException(STREAM_ERROR);
}
}
}
/**
* Close MP3 frame.
*/
public void closeFrame() {
framesize = -1;
wordpointer = -1;
bitindex = -1;
}
/**
* Determines if the next 4 bytes of the stream represent a
* frame header.
*/
public boolean isSyncCurrentPosition(int syncmode) throws BitstreamException {
int read = readBytes(syncbuf, 0, 4);
int headerstring = ((syncbuf[0] << 24) & 0xFF000000) | ((syncbuf[1] << 16) & 0x00FF0000) | ((syncbuf[2] << 8) & 0x0000FF00) | ((syncbuf[3] << 0) & 0x000000FF);
try {
source.unread(syncbuf, 0, read);
} catch (IOException ex) {
}
boolean sync = false;
switch (read) {
case 0:
sync = true;
break;
case 4:
sync = isSyncMark(headerstring, syncmode, syncword);
break;
}
return sync;
}
BitstreamException newBitstreamException(int errorcode) {
return new BitstreamException(errorcode, null);
}
private BitstreamException newBitstreamException(int errorcode, Throwable throwable) {
return new BitstreamException(errorcode, throwable);
}
/**
* Get next 32 bits from bitstream.
* They are stored in the headerstring.
* syncmod allows Synchro flag ID
* The returned value is False at the end of stream.
*/
int syncHeader(byte syncmode) throws BitstreamException {
boolean sync;
int headerstring;
// read additional 2 bytes
int bytesRead = readBytes(syncbuf, 0, 3);
if (bytesRead != 3) throw newBitstreamException(STREAM_EOF, null);
headerstring = ((syncbuf[0] << 16) & 0x00FF0000) | ((syncbuf[1] << 8) & 0x0000FF00) | ((syncbuf[2]) & 0x000000FF);
do {
headerstring <<= 8;
if (readBytes(syncbuf, 3, 1) != 1)
throw newBitstreamException(STREAM_EOF, null);
headerstring |= (syncbuf[3] & 0x000000FF);
sync = isSyncMark(headerstring, syncmode, syncword);
}
while (!sync);
return headerstring;
}
public boolean isSyncMark(int headerstring, int syncmode, int word) {
boolean sync = false;
if (syncmode == INITIAL_SYNC) {
sync = ((headerstring & 0xFFE00000) == 0xFFE00000); // SZD: MPEG 2.5
} else {
sync = ((headerstring & 0xFFF80C00) == word) &&
(((headerstring & 0x000000C0) == 0x000000C0) == single_ch_mode);
}
// filter out invalid sample rate
if (sync)
sync = (((headerstring >>> 10) & 3) != 3);
// filter out invalid layer
if (sync)
sync = (((headerstring >>> 17) & 3) != 0);
// filter out invalid version
if (sync)
sync = (((headerstring >>> 19) & 3) != 1);
return sync;
}
/**
* Reads the data for the next frame. The frame is not parsed
* until parse frame is called.
*/
int read_frame_data(int bytesize) throws BitstreamException {
int numread = readFully(frame_bytes, 0, bytesize);
framesize = bytesize;
wordpointer = -1;
bitindex = -1;
return numread;
}
/**
* Parses the data previously read with read_frame_data().
*/
void parse_frame() throws BitstreamException {
// Convert Bytes read to int
int b = 0;
byte[] byteread = frame_bytes;
int bytesize = framesize;
for (int k = 0; k < bytesize; k = k + 4) {
int convert = 0;
byte b0 = 0;
byte b1 = 0;
byte b2 = 0;
byte b3 = 0;
b0 = byteread[k];
if (k + 1 < bytesize) b1 = byteread[k + 1];
if (k + 2 < bytesize) b2 = byteread[k + 2];
if (k + 3 < bytesize) b3 = byteread[k + 3];
framebuffer[b++] = ((b0 << 24) & 0xFF000000) | ((b1 << 16) & 0x00FF0000) | ((b2 << 8) & 0x0000FF00) | (b3 & 0x000000FF);
}
wordpointer = 0;
bitindex = 0;
}
/**
* Read bits from buffer into the lower bits of an unsigned int.
* The LSB contains the latest read bit of the stream.
* (1 <= number_of_bits <= 16)
*/
public int get_bits(int number_of_bits) {
int returnvalue = 0;
int sum = bitindex + number_of_bits;
// E.B
// There is a problem here, wordpointer could be -1 ?!
if (wordpointer < 0) wordpointer = 0;
// E.B : End.
if (sum <= 32) {
// all bits contained in *wordpointer
returnvalue = (framebuffer[wordpointer] >>> (32 - sum)) & bitmask[number_of_bits];
// returnvalue = (wordpointer[0] >> (32 - sum)) & bitmask[number_of_bits];
if ((bitindex += number_of_bits) == 32) {
bitindex = 0;
wordpointer++; // added by me!
}
return returnvalue;
}
int Right = (framebuffer[wordpointer] & 0x0000FFFF);
wordpointer++;
int Left = (framebuffer[wordpointer] & 0xFFFF0000);
returnvalue = ((Right << 16) & 0xFFFF0000) | ((Left >>> 16) & 0x0000FFFF);
returnvalue >>>= 48 - sum; // returnvalue >>= 16 - (number_of_bits - (32 - bitindex))
returnvalue &= bitmask[number_of_bits];
bitindex = sum - 32;
return returnvalue;
}
/**
* Set the word we want to sync the header to.
* In Big-Endian byte order
*/
void set_syncword(int syncword0) {
syncword = syncword0 & 0xFFFFFF3F;
single_ch_mode = ((syncword0 & 0x000000C0) == 0x000000C0);
}
/**
* Reads the exact number of bytes from the source
* input stream into a byte array.
*
* @param b The byte array to read the specified number
* of bytes into.
* @param offs The index in the array where the first byte
* read should be stored.
* @param len the number of bytes to read.
* @throws BitstreamException is thrown if the specified
* number of bytes could not be read from the stream.
*/
private int readFully(byte[] b, int offs, int len)
throws BitstreamException {
int nRead = 0;
try {
while (len > 0) {
int bytesread = source.read(b, offs, len);
if (bytesread == -1) {
while (len-- > 0) {
b[offs++] = 0;
}
break;
//throw newBitstreamException(UNEXPECTED_EOF, new EOFException());
}
nRead = nRead + bytesread;
offs += bytesread;
len -= bytesread;
}
} catch (IOException ex) {
throw newBitstreamException(STREAM_ERROR, ex);
}
return nRead;
}
/**
* Simlar to readFully, but doesn't throw exception when
* EOF is reached.
*/
private int readBytes(byte[] b, int offs, int len)
throws BitstreamException {
int totalBytesRead = 0;
try {
while (len > 0) {
int bytesread = source.read(b, offs, len);
if (bytesread == -1) {
break;
}
totalBytesRead += bytesread;
offs += bytesread;
len -= bytesread;
}
} catch (IOException ex) {
throw newBitstreamException(STREAM_ERROR, ex);
}
return totalBytesRead;
}
}
@@ -0,0 +1,55 @@
/*
* 11/19/04 1.0 moved to LGPL.
* 11/17/04 INVALIDFRAME code added. [email protected]
* 12/12/99 Initial version. [email protected]
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
/**
* This interface describes all error codes that can be thrown
* in <code>BistreamException</code>s.
*
* @author MDM 12/12/99
* @see BitstreamException
* @since 0.0.6
*/
public interface BitstreamErrors extends JavaLayerErrors {
/**
* An undeterminable error occurred.
*/
int UNKNOWN_ERROR = BITSTREAM_ERROR;
/**
* A problem occurred reading from the stream.
*/
int STREAM_ERROR = BITSTREAM_ERROR + 2;
/**
* The end of the stream was reached.
*/
int STREAM_EOF = BITSTREAM_ERROR + 4;
/**
* Frame data are missing.
*/
int INVALIDFRAME = BITSTREAM_ERROR + 5;
}
@@ -0,0 +1,65 @@
/*
* 11/19/04 1.0 moved to LGPL.
* 12/12/99 Initial version. [email protected]
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
/**
* Instances of <code>BitstreamException</code> are thrown
* when operations on a <code>Bitstream</code> fail.
* <p>
* The exception provides details of the exception condition
* in two ways:
* <ol><li>
* as an error-code describing the nature of the error
* </li><br></br><li>
* as the <code>Throwable</code> instance, if any, that was thrown
* indicating that an exceptional condition has occurred.
* </li></ol></p>
*
* @author MDM 12/12/99
* @since 0.0.6
*/
public class BitstreamException extends JavaLayerException
implements BitstreamErrors {
private int errorcode = UNKNOWN_ERROR;
public BitstreamException(String msg, Throwable t) {
super(msg, t);
}
public BitstreamException(int errorcode, Throwable t) {
this(getErrorString(errorcode), t);
this.errorcode = errorcode;
}
static public String getErrorString(int errorcode) {
// REVIEW: use resource bundle to map error codes
// to locale-sensitive strings.
return "Bitstream errorcode " + Integer.toHexString(errorcode);
}
public int getErrorCode() {
return errorcode;
}
}
@@ -0,0 +1,64 @@
/*
* 11/19/04 : 1.0 moved to LGPL.
*
* 02/12/99 : Java Conversion by E.B , [email protected]
*
* @(#) crc.h 1.5, last edit: 6/15/94 16:55:32
* @(#) Copyright (C) 1993, 1994 Tobias Bading ([email protected])
* @(#) Berlin University of Technology
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
/**
* 16-Bit CRC checksum
*/
public final class Crc16 {
private short crc;
/**
* Dummy Constructor
*/
public Crc16() {
crc = (short) 0xFFFF;
}
/**
* Feed a bitstring to the crc calculation (0 < length <= 32).
*/
public void add_bits(int bitstring, int length) {
int bitmask = 1 << (length - 1);
do
if (((crc & 0x8000) == 0) ^ ((bitstring & bitmask) == 0)) {
crc <<= 1;
short polynomial = (short) 0x8005;
crc ^= polynomial;
} else
crc <<= 1;
while ((bitmask >>>= 1) != 0);
}
/**
* Return the calculated checksum.
* Erase it for next calls to add_bits().
*/
public short checksum() {
short sum = crc;
crc = (short) 0xFFFF;
return sum;
}
}
@@ -0,0 +1,618 @@
/*
* 11/19/04 : 1.0 moved to LGPL.
* VBRI header support added, E.B [email protected]
*
* 12/04/03 : VBR (XING) header support added, E.B [email protected]
*
* 02/13/99 : Java Conversion by JavaZOOM , E.B [email protected]
*
* Declarations for MPEG header class
* A few layer III, MPEG-2 LSF, and seeking modifications made by Jeff Tsay.
* Last modified : 04/19/97
*
* @(#) header.h 1.7, last edit: 6/15/94 16:55:33
* @(#) Copyright (C) 1993, 1994 Tobias Bading ([email protected])
* @(#) Berlin University of Technology
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
/**
* Class for extracting information from a frame header.
*/
public final class Header {
public static final int[][] frequencies =
{{22050, 24000, 16000, 1},
{44100, 48000, 32000, 1},
{11025, 12000, 8000, 1}}; // SZD: MPEG25
/**
* Constant for MPEG-2 LSF version
*/
public static final int MPEG2_LSF = 0;
public static final int MPEG25_LSF = 2; // SZD
/**
* Constant for MPEG-1 version
*/
public static final int MPEG1 = 1;
public static final int STEREO = 0;
public static final int JOINT_STEREO = 1;
public static final int DUAL_CHANNEL = 2;
public static final int SINGLE_CHANNEL = 3;
public static final int FOURTYFOUR_POINT_ONE = 0;
public static final int FOURTYEIGHT = 1;
public static final int THIRTYTWO = 2;
// E.B -> private to public
public static final int[][][] bitrates = {
{{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,
112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000, 0},
{0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0},
{0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0}},
{{0 /*free format*/, 32000, 64000, 96000, 128000, 160000, 192000,
224000, 256000, 288000, 320000, 352000, 384000, 416000, 448000, 0},
{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,
112000, 128000, 160000, 192000, 224000, 256000, 320000, 384000, 0},
{0 /*free format*/, 32000, 40000, 48000, 56000, 64000, 80000,
96000, 112000, 128000, 160000, 192000, 224000, 256000, 320000, 0}},
// SZD: MPEG2.5
{{0 /*free format*/, 32000, 48000, 56000, 64000, 80000, 96000,
112000, 128000, 144000, 160000, 176000, 192000, 224000, 256000, 0},
{0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0},
{0 /*free format*/, 8000, 16000, 24000, 32000, 40000, 48000,
56000, 64000, 80000, 96000, 112000, 128000, 144000, 160000, 0}},
};
// E.B -> private to public
public static final String[][][] bitrate_str = {
{{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",
"80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s",
"160 kbit/s", "176 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s",
"forbidden"},
{"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
"40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
"96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
"forbidden"},
{"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
"40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
"96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
"forbidden"}},
{{"free format", "32 kbit/s", "64 kbit/s", "96 kbit/s", "128 kbit/s",
"160 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s", "288 kbit/s",
"320 kbit/s", "352 kbit/s", "384 kbit/s", "416 kbit/s", "448 kbit/s",
"forbidden"},
{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",
"80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "160 kbit/s",
"192 kbit/s", "224 kbit/s", "256 kbit/s", "320 kbit/s", "384 kbit/s",
"forbidden"},
{"free format", "32 kbit/s", "40 kbit/s", "48 kbit/s", "56 kbit/s",
"64 kbit/s", "80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s",
"160 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s", "320 kbit/s",
"forbidden"}},
// SZD: MPEG2.5
{{"free format", "32 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s",
"80 kbit/s", "96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s",
"160 kbit/s", "176 kbit/s", "192 kbit/s", "224 kbit/s", "256 kbit/s",
"forbidden"},
{"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
"40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
"96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
"forbidden"},
{"free format", "8 kbit/s", "16 kbit/s", "24 kbit/s", "32 kbit/s",
"40 kbit/s", "48 kbit/s", "56 kbit/s", "64 kbit/s", "80 kbit/s",
"96 kbit/s", "112 kbit/s", "128 kbit/s", "144 kbit/s", "160 kbit/s",
"forbidden"}},
};
// VBR support added by E.B
private final double[] h_vbr_time_per_frame = {-1, 384, 1152, 1152};
public short checksum;
public int framesize;
public int nSlots;
private int h_layer, h_protection_bit, h_bitrate_index,
h_padding_bit, h_mode_extension;
private int h_version;
private int h_mode;
private int h_sample_frequency;
private int h_number_of_subbands, h_intensity_stereo_bound;
private boolean h_vbr;
private int h_vbr_frames;
private int h_vbr_bytes;
private byte syncmode = Bitstream.INITIAL_SYNC;
private Crc16 crc;
Header() {
}
/**
* Returns total ms.
*
* @param streamsize
* @return total milliseconds
*/
public float total_ms(int streamsize) {
return (max_number_of_frames(streamsize) * ms_per_frame());
}
public String toString() {
StringBuilder buffer = new StringBuilder(200);
buffer.append("Layer ");
buffer.append(layer_string());
buffer.append(" frame ");
buffer.append(mode_string());
buffer.append(' ');
buffer.append(version_string());
if (!checksums())
buffer.append(" no");
buffer.append(" checksums");
buffer.append(' ');
buffer.append(sample_frequency_string());
buffer.append(',');
buffer.append(' ');
buffer.append(bitrate_string());
return buffer.toString();
}
// Functions to query header contents:
/**
* Read a 32-bit header from the bitstream.
*/
void read_header(Bitstream stream, Crc16[] crcp) throws BitstreamException {
int headerstring;
int channel_bitrate;
boolean sync = false;
do {
headerstring = stream.syncHeader(syncmode);
if (syncmode == Bitstream.INITIAL_SYNC) {
h_version = ((headerstring >>> 19) & 1);
if (((headerstring >>> 20) & 1) == 0) // SZD: MPEG2.5 detection
if (h_version == MPEG2_LSF)
h_version = MPEG25_LSF;
else
throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);
if ((h_sample_frequency = ((headerstring >>> 10) & 3)) == 3) {
throw stream.newBitstreamException(Bitstream.UNKNOWN_ERROR);
}
}
h_layer = 4 - (headerstring >>> 17) & 3;
h_protection_bit = (headerstring >>> 16) & 1;
h_bitrate_index = (headerstring >>> 12) & 0xF;
h_padding_bit = (headerstring >>> 9) & 1;
h_mode = ((headerstring >>> 6) & 3);
h_mode_extension = (headerstring >>> 4) & 3;
if (h_mode == JOINT_STEREO)
h_intensity_stereo_bound = (h_mode_extension << 2) + 4;
else
h_intensity_stereo_bound = 0; // should never be used
// calculate number of subbands:
if (h_layer == 1)
h_number_of_subbands = 32;
else {
channel_bitrate = h_bitrate_index;
// calculate bitrate per channel:
if (h_mode != SINGLE_CHANNEL)
if (channel_bitrate == 4)
channel_bitrate = 1;
else
channel_bitrate -= 4;
if ((channel_bitrate == 1) || (channel_bitrate == 2))
if (h_sample_frequency == THIRTYTWO)
h_number_of_subbands = 12;
else
h_number_of_subbands = 8;
else if ((h_sample_frequency == FOURTYEIGHT) || ((channel_bitrate >= 3) && (channel_bitrate <= 5)))
h_number_of_subbands = 27;
else
h_number_of_subbands = 30;
}
if (h_intensity_stereo_bound > h_number_of_subbands)
h_intensity_stereo_bound = h_number_of_subbands;
// calculate framesize and nSlots
calculate_framesize();
// read framedata:
int framesizeloaded = stream.read_frame_data(framesize);
if ((framesize >= 0) && (framesizeloaded != framesize)) {
// Data loaded does not match to expected framesize,
// it might be an ID3v1 TAG. (Fix 11/17/04).
throw stream.newBitstreamException(Bitstream.INVALIDFRAME);
}
if (stream.isSyncCurrentPosition(syncmode)) {
if (syncmode == Bitstream.INITIAL_SYNC) {
syncmode = Bitstream.STRICT_SYNC;
stream.set_syncword(headerstring & 0xFFF80CC0);
}
sync = true;
} else {
stream.unreadFrame();
}
}
while (!sync);
stream.parse_frame();
if (h_protection_bit == 0) {
// frame contains a crc checksum
checksum = (short) stream.get_bits(16);
if (crc == null)
crc = new Crc16();
crc.add_bits(headerstring, 16);
crcp[0] = crc;
} else
crcp[0] = null;
}
/**
* Parse frame to extract optionnal VBR frame.
*
* @param firstframe
* @author E.B ([email protected])
*/
void parseVBR(byte[] firstframe) throws BitstreamException {
// Trying Xing header.
String xing = "Xing";
byte[] tmp = new byte[4];
int offset = 0;
// Compute "Xing" offset depending on MPEG version and channels.
if (h_version == MPEG1) {
if (h_mode == SINGLE_CHANNEL) offset = 21 - 4;
else offset = 36 - 4;
} else {
if (h_mode == SINGLE_CHANNEL) offset = 13 - 4;
else offset = 21 - 4;
}
byte[] h_vbr_toc;
try {
System.arraycopy(firstframe, offset, tmp, 0, 4);
// Is "Xing" ?
if (xing.equals(new String(tmp))) {
//Yes.
h_vbr = true;
h_vbr_frames = -1;
h_vbr_bytes = -1;
h_vbr_toc = new byte[100];
int length = 4;
// Read flags.
byte[] flags = new byte[4];
System.arraycopy(firstframe, offset + length, flags, 0, flags.length);
length += flags.length;
// Read number of frames (if available).
if ((flags[3] & (byte) (1)) != 0) {
System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
h_vbr_frames = (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) & 0x0000FF00 | tmp[3] & 0x000000FF;
length += 4;
}
// Read size (if available).
if ((flags[3] & (byte) (1 << 1)) != 0) {
System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
h_vbr_bytes = (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) & 0x0000FF00 | tmp[3] & 0x000000FF;
length += 4;
}
// Read TOC (if available).
if ((flags[3] & (byte) (1 << 2)) != 0) {
System.arraycopy(firstframe, offset + length, h_vbr_toc, 0, h_vbr_toc.length);
length += h_vbr_toc.length;
}
// Read scale (if available).
if ((flags[3] & (byte) (1 << 3)) != 0) {
System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
}
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new BitstreamException("XingVBRHeader Corrupted", e);
}
// Trying VBRI header.
String vbri = "VBRI";
offset = 36 - 4;
try {
System.arraycopy(firstframe, offset, tmp, 0, 4);
// Is "VBRI" ?
if (vbri.equals(new String(tmp))) {
//Yes.
h_vbr = true;
h_vbr_frames = -1;
h_vbr_bytes = -1;
// Bytes.
int length = 4 + 6;
System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
h_vbr_bytes = (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) & 0x0000FF00 | tmp[3] & 0x000000FF;
length += 4;
// Frames.
System.arraycopy(firstframe, offset + length, tmp, 0, tmp.length);
h_vbr_frames = (tmp[0] << 24) & 0xFF000000 | (tmp[1] << 16) & 0x00FF0000 | (tmp[2] << 8) & 0x0000FF00 | tmp[3] & 0x000000FF;
}
} catch (ArrayIndexOutOfBoundsException e) {
throw new BitstreamException("VBRIVBRHeader Corrupted", e);
}
}
/**
* Returns version.
*/
public int version() {
return h_version;
}
/**
* Returns Layer ID.
*/
public int layer() {
return h_layer;
}
/**
* Returns bitrate index.
*/
public int bitrate_index() {
return h_bitrate_index;
}
/**
* Returns Sample Frequency.
*/
public int sample_frequency() {
return h_sample_frequency;
}
/**
* Returns Frequency.
*/
public int frequency() {
return frequencies[h_version][h_sample_frequency];
}
/**
* Returns Mode.
*/
public int mode() {
return h_mode;
}
/**
* Returns Protection bit.
*/
public boolean checksums() {
return h_protection_bit == 0;
}
// Seeking and layer III stuff
/**
* Returns Checksum flag.
* Compares computed checksum with stream checksum.
*/
public boolean checksum_ok() {
return (checksum == crc.checksum());
}
/**
* Returns Slots.
*/
public int slots() {
return nSlots;
}
// E.B -> private to public
/**
* Returns Mode Extension.
*/
public int mode_extension() {
return h_mode_extension;
}
/**
* Calculate Frame size.
* Calculates framesize in bytes excluding header size.
*/
public void calculate_framesize() {
if (h_layer == 1) {
framesize = (12 * bitrates[h_version][0][h_bitrate_index]) /
frequencies[h_version][h_sample_frequency];
if (h_padding_bit != 0) framesize++;
framesize <<= 2; // one slot is 4 bytes long
nSlots = 0;
} else {
framesize = (144 * bitrates[h_version][h_layer - 1][h_bitrate_index]) /
frequencies[h_version][h_sample_frequency];
if (h_version == MPEG2_LSF || h_version == MPEG25_LSF) framesize >>= 1; // SZD
if (h_padding_bit != 0) framesize++;
// Layer III slots
if (h_layer == 3) {
if (h_version == MPEG1) {
nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 17 : 32) // side info size
- ((h_protection_bit != 0) ? 0 : 2) // CRC size
- 4; // header size
} else { // MPEG-2 LSF, SZD: MPEG-2.5 LSF
nSlots = framesize - ((h_mode == SINGLE_CHANNEL) ? 9 : 17) // side info size
- ((h_protection_bit != 0) ? 0 : 2) // CRC size
- 4; // header size
}
} else {
nSlots = 0;
}
}
framesize -= 4; // subtract header size
}
/**
* Returns the maximum number of frames in the stream.
*
* @param streamsize
* @return number of frames
*/
public int max_number_of_frames(int streamsize) // E.B
{
if (h_vbr) return h_vbr_frames;
else {
if ((framesize + 4 - h_padding_bit) == 0) return 0;
else return (streamsize / (framesize + 4 - h_padding_bit));
}
}
/**
* Returns ms/frame.
*
* @return milliseconds per frame
*/
public float ms_per_frame() // E.B
{
if (h_vbr) {
double tpf = h_vbr_time_per_frame[layer()] / frequency();
if ((h_version == MPEG2_LSF) || (h_version == MPEG25_LSF)) tpf /= 2;
return ((float) (tpf * 1000));
} else {
float[][] ms_per_frame_array = {{8.707483f, 8.0f, 12.0f},
{26.12245f, 24.0f, 36.0f},
{26.12245f, 24.0f, 36.0f}};
return (ms_per_frame_array[h_layer - 1][h_sample_frequency]);
}
}
// functions which return header informations as strings:
/**
* Return Layer version.
*/
public String layer_string() {
switch (h_layer) {
case 1:
return "I";
case 2:
return "II";
case 3:
return "III";
}
return null;
}
/**
* Return Bitrate.
*
* @return bitrate in bps
*/
public String bitrate_string() {
if (h_vbr) {
return bitrate() / 1000 + " kb/s";
} else return bitrate_str[h_version][h_layer - 1][h_bitrate_index];
}
/**
* Return Bitrate.
*
* @return bitrate in bps and average bitrate for VBR header
*/
public int bitrate() {
if (h_vbr) {
return ((int) ((h_vbr_bytes * 8) / (ms_per_frame() * h_vbr_frames))) * 1000;
} else return bitrates[h_version][h_layer - 1][h_bitrate_index];
}
/**
* Returns Frequency
*
* @return frequency string in kHz
*/
public String sample_frequency_string() {
switch (h_sample_frequency) {
case THIRTYTWO:
if (h_version == MPEG1)
return "32 kHz";
else if (h_version == MPEG2_LSF)
return "16 kHz";
else // SZD
return "8 kHz";
case FOURTYFOUR_POINT_ONE:
if (h_version == MPEG1)
return "44.1 kHz";
else if (h_version == MPEG2_LSF)
return "22.05 kHz";
else // SZD
return "11.025 kHz";
case FOURTYEIGHT:
if (h_version == MPEG1)
return "48 kHz";
else if (h_version == MPEG2_LSF)
return "24 kHz";
else // SZD
return "12 kHz";
}
return (null);
}
/**
* Returns Mode.
*/
public String mode_string() {
switch (h_mode) {
case STEREO:
return "Stereo";
case JOINT_STEREO:
return "Joint stereo";
case DUAL_CHANNEL:
return "Dual channel";
case SINGLE_CHANNEL:
return "Single channel";
}
return null;
}
/**
* Returns Version.
*
* @return MPEG-1 or MPEG-2 LSF or MPEG-2.5 LSF
*/
public String version_string() {
switch (h_version) {
case MPEG1:
return "MPEG-1";
case MPEG2_LSF:
return "MPEG-2 LSF";
case MPEG25_LSF: // SZD
return "MPEG-2.5 LSF";
}
return (null);
}
/**
* Returns the number of subbands in the current frame.
*
* @return number of subbands
*/
public int number_of_subbands() {
return h_number_of_subbands;
}
/**
* Returns Intensity Stereo.
* (Layer II joint stereo only).
* Returns the number of subbands which are in stereo mode,
* subbands above that limit are in intensity stereo mode.
*
* @return intensity
*/
public int intensity_stereo_bound() {
return h_intensity_stereo_bound;
}
}
@@ -0,0 +1,39 @@
/*
* 11/19/04 1.0 moved to LGPL.
* 12/12/99 Initial version. [email protected]
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
/**
* Exception erorr codes for components of the JavaLayer API.
*/
public interface JavaLayerErrors {
/**
* The first bitstream error code. See the {@link DecoderErrors DecoderErrors}
* interface for other bitstream error codes.
*/
int BITSTREAM_ERROR = 0x100;
/**
* The first decoder error code. See the {@link DecoderErrors DecoderErrors}
* interface for other decoder error codes.
*/
int DECODER_ERROR = 0x200;
}
@@ -0,0 +1,61 @@
/*
* 11/19/04 1.0 moved to LGPL.
* 12/12/99 Initial version. [email protected]
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package coloryr.allmusic.core.decoder;
import java.io.PrintStream;
/**
* The JavaLayerException is the base class for all API-level
* exceptions thrown by JavaLayer. To facilitate conversion and
* common handling of exceptions from other domains, the class
* can delegate some functionality to a contained Throwable instance.
* <p>
*
* @author MDM
*/
public class JavaLayerException extends Exception {
private Throwable exception;
public JavaLayerException(String msg) {
super(msg);
}
public JavaLayerException(String msg, Throwable t) {
super(msg);
exception = t;
}
public void printStackTrace() {
printStackTrace(System.err);
}
public void printStackTrace(PrintStream ps) {
if (this.exception == null) {
super.printStackTrace(ps);
} else {
exception.printStackTrace();
}
}
}
@@ -0,0 +1,5 @@
package coloryr.allmusic.core.enums;
public enum EncryptType {
WEAPI, EAPI, API
}
@@ -0,0 +1,5 @@
package coloryr.allmusic.core.enums;
public enum HudPos {
info, list, lyric, pic
}
@@ -0,0 +1,255 @@
package coloryr.allmusic.core.hud;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.hud.PosObj;
import coloryr.allmusic.core.objs.hud.SaveObj;
import java.io.File;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.text.MessageFormat;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Semaphore;
public class DataSql {
private static final Queue<Runnable> tasks = new ConcurrentLinkedQueue<>();
private static final Semaphore semaphore = new Semaphore(0);
/**
* 创建表用
*/
private static final String table = "CREATE TABLE \"allmusic\" (\n" +
" \"id\" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n" +
" \"name\" TEXT(20),\n" +
" \"info_x\" integer(6),\n" +
" \"info_y\" integer(6),\n" +
" \"info_enable\" integer(1),\n" +
" \"lyric_x\" integer(6),\n" +
" \"lyric_y\" integer(6),\n" +
" \"lyric_enable\" integer(1),\n" +
" \"list_x\" integer(6),\n" +
" \"list_y\" integer(6),\n" +
" \"list_enable\" integer(1),\n" +
" \"pic_x\" integer(6),\n" +
" \"pic_y\" integer(6),\n" +
" \"pic_size\" integer(6),\n" +
" \"pic_enable\" integer(1),\n" +
" \"pic_rotate\" integer(1),\n" +
" \"pic_rotate_speed\" integer(6)\n" +
");";
/**
* 数据库文件
*/
public static File sqlFile;
private static boolean isRun;
/**
* 数据库链接对象
*/
private static Connection connection;
/**
* 初始化数据库
*/
public static void init() {
try {
AllMusic.log.info("正在初始化数据库");
if (connection != null)
connection.close();
Class.forName("org.sqlite.JDBC");
connection = DriverManager.getConnection("jdbc:sqlite:" + sqlFile.getPath());
Statement stat = connection.createStatement();
ResultSet set = stat.executeQuery("SELECT name FROM sqlite_master WHERE type='table' AND name='allmusic';");
if (!set.next()) {
set.close();
stat.execute(table);
}
stat.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 检查玩家是否在数据库
*
* @param name 用户名
* @return 结果
*/
public static boolean check(String name) {
try {
boolean have = false;
if (connection.isReadOnly() || connection.isClosed()) {
init();
}
Statement stat = connection.createStatement();
ResultSet set = stat.executeQuery("SELECT allmusic.id FROM allmusic WHERE allmusic.name ='" + name + "'");
if (set.next()) {
have = true;
}
set.close();
stat.close();
return have;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 更新玩家Hud数据
*
* @param name 用户名
* @param hud Hud数据
*/
private static void update(String name, SaveObj hud) {
String sql = "";
try {
if (connection.isReadOnly() || connection.isClosed()) {
init();
}
Statement stat = connection.createStatement();
sql = MessageFormat.format("UPDATE allmusic SET info_x={0},info_y={1},info_enable={2},lyric_x={3},lyric_y={4},lyric_enable={5},list_x={6},list_y={7}, list_enable={8},pic_x={9},pic_y={10},pic_enable={11},pic_size={12},pic_rotate={13},pic_rotate_speed={14} WHERE name=@name",
hud.Info.x, hud.Info.y, hud.EnableInfo ? 1 : 0,
hud.Lyric.x, hud.Lyric.y, hud.EnableLyric ? 1 : 0,
hud.List.x, hud.List.y, hud.EnableList ? 1 : 0,
hud.Pic.x, hud.Pic.y, hud.EnablePic ? 1 : 0,
hud.PicSize, hud.EnablePicRotate ? 1: 0,
hud.PicRotateSpeed);
sql = sql.replace("@name", "'" + name + "'");
stat.execute(sql);
stat.close();
} catch (Exception e) {
AllMusic.log.info(sql);
e.printStackTrace();
}
}
/**
* 添加用户Hud数据
*
* @param name 用户名
* @param hud 数据
*/
public static void addUser(String name, SaveObj hud) {
String sql = "";
try {
if (connection.isReadOnly() || connection.isClosed()) {
init();
}
if (check(name)) {
update(name, hud);
} else {
Statement stat = connection.createStatement();
sql = MessageFormat.format("INSERT INTO allmusic (name,info_x,info_y," +
"info_enable,lyric_x,lyric_y,lyric_enable,list_x,list_y,list_enable," +
"pic_x,pic_y,pic_enable,pic_size,pic_rotate,pic_rotate_speed)" +
"VALUES (@name,{0},{1},{2},{3},{4},{5},{6},{7},{8},{9},{10},{11},{12},{13},{14})",
hud.Info.x, hud.Info.y, hud.EnableInfo ? 1 : 0,
hud.Lyric.x, hud.Lyric.y, hud.EnableLyric ? 1 : 0,
hud.List.x, hud.List.y, hud.EnableList ? 1 : 0,
hud.Pic.x, hud.Pic.y, hud.EnablePic ? 1 : 0,
hud.PicSize, hud.EnablePicRotate ? 1: 0,
hud.PicRotateSpeed);
sql = sql.replace("@name", "'" + name + "'");
stat.execute(sql);
stat.close();
}
} catch (Exception e) {
AllMusic.log.info(sql);
e.printStackTrace();
}
}
/**
* 读取所有数据
*/
private static void readAll() {
try {
AllMusic.log.info("正在读取数据库所有内容");
if (connection.isReadOnly() || connection.isClosed()) {
init();
}
Statement stat = connection.createStatement();
ResultSet set = stat.executeQuery("SELECT name,info_x,info_y,info_enable,lyric_x,lyric_y,lyric_enable,list_x,list_y,list_enable,pic_x,pic_y,pic_enable,pic_size,pic_rotate,pic_rotate_speed FROM allmusic");
while (set.next()) {
String name = set.getString(1);
SaveObj obj = new SaveObj();
PosObj pos1 = new PosObj();
pos1.x = set.getInt(2);
pos1.y = set.getInt(3);
obj.Info = pos1;
obj.EnableInfo = set.getInt(4) == 1;
PosObj pos2 = new PosObj();
pos2.x = set.getInt(5);
pos2.y = set.getInt(6);
obj.Lyric = pos2;
obj.EnableLyric = set.getInt(7) == 1;
PosObj pos3 = new PosObj();
pos3.x = set.getInt(8);
pos3.y = set.getInt(9);
obj.List = pos3;
obj.EnableList = set.getInt(10) == 1;
PosObj pos4 = new PosObj();
pos4.x = set.getInt(11);
pos4.y = set.getInt(12);
obj.Pic = pos4;
obj.EnablePic = set.getInt(13) == 1;
obj.PicSize = set.getInt(14);
obj.EnablePicRotate = set.getInt(15) == 1;
obj.PicRotateSpeed = set.getInt(16);
HudUtils.add(name, obj);
}
stat.close();
} catch (Exception e) {
AllMusic.log.warning("数据库读取错误,请删除关闭服务器删除数据库,在启动服务器");
e.printStackTrace();
}
}
public static void task(Runnable runnable) {
tasks.add(runnable);
semaphore.release();
}
/**
* 启用Hud数据库
*/
public static void start() {
init();
readAll();
Thread thread = new Thread(DataSql::run);
isRun = true;
thread.start();
}
/**
* 停止数据库
*/
public static void stop() {
isRun = false;
semaphore.release();
HudUtils.save();
}
private static void run() {
Runnable runnable;
while (isRun) {
try {
semaphore.acquire();
if (!isRun)
return;
do {
runnable = tasks.poll();
if (runnable != null) {
runnable.run();
}
}
while (runnable != null);
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
@@ -0,0 +1,348 @@
package coloryr.allmusic.core.hud;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.enums.HudPos;
import coloryr.allmusic.core.music.play.LyricSave;
import coloryr.allmusic.core.music.play.PlayMusic;
import coloryr.allmusic.core.objs.hud.PosObj;
import coloryr.allmusic.core.objs.hud.SaveObj;
import coloryr.allmusic.core.objs.music.SongInfoObj;
import coloryr.allmusic.core.utils.Function;
import com.google.gson.Gson;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
public class HudUtils {
private static final Map<String, SaveObj> huds = new ConcurrentHashMap<>();
public static SaveObj get(String name) {
if (!huds.containsKey(name)) {
SaveObj obj = AllMusic.getConfig().DefaultHud.copy();
huds.put(name, obj);
DataSql.task(() -> DataSql.addUser(name, obj));
return obj;
}
return huds.get(name);
}
public static void add(String name, SaveObj hud) {
huds.put(name, hud);
}
public static void addAndSave(String name, SaveObj hud) {
huds.put(name, hud);
DataSql.task(() -> DataSql.addUser(name, hud));
}
public static void save() {
for (Map.Entry<String, SaveObj> item : huds.entrySet()) {
DataSql.addUser(item.getKey(), item.getValue());
}
}
/**
* 设置玩家Hud位置
*
* @param player 用户名
* @param pos 位置
* @param x x
* @param y y
* @return 位置数据
*/
public static PosObj setHudPos(String player, String pos, String x, String y) {
SaveObj obj = get(player);
if (obj == null)
obj = AllMusic.getConfig().DefaultHud.copy();
HudPos pos1 = HudPos.valueOf(pos);
PosObj posOBJ = new PosObj(0, 0);
if (!Function.isInteger(x) && !Function.isInteger(y))
return null;
int x1 = Integer.parseInt(x);
int y1 = Integer.parseInt(y);
switch (pos1) {
case lyric:
posOBJ = obj.Lyric;
break;
case list:
posOBJ = obj.List;
break;
case info:
posOBJ = obj.Info;
break;
case pic:
posOBJ = obj.Pic;
}
posOBJ.x = x1;
posOBJ.y = y1;
addAndSave(player, obj);
AllMusic.save();
HudUtils.sendHudPos(player);
return posOBJ;
}
/**
* 更新Hud的List数据
*/
public static void sendHudListData() {
String info;
if (PlayMusic.getSize() == 0) {
info = AllMusic.getMessage().Hud.NoList;
} else {
String now;
StringBuilder list = new StringBuilder();
for (SongInfoObj info1 : PlayMusic.getList()) {
if (info1 == null)
continue;
now = info1.getInfo();
if (now.length() > AllMusic.getConfig().MessageLimitSize)
now = now.substring(0, AllMusic.getConfig().MessageLimitSize - 1) + "...";
list.append(now).append("\n");
}
info = AllMusic.getMessage().Hud.List
.replace("%Size%", String.valueOf(PlayMusic.getList().size()))
.replace("%List%", list.toString());
}
AllMusic.side.sendHudList(info);
}
/**
* 时间转换
*
* @param time 时间
* @return 结果
*/
private static String tranTime(int time) {
int m = time / 60;
int s = time - m * 60;
return (m < 10 ? "0" : "") + m + ":" + (s < 10 ? "0" : "") + s;
}
/**
* 更新Hud的信息数据
*/
public static void sendHudNowData() {
String info;
if (PlayMusic.nowPlayMusic == null) {
info = AllMusic.getMessage().Hud.NoMusic;
} else {
info = AllMusic.getMessage().Hud.Music
.replace("%Name%", PlayMusic.nowPlayMusic.getName())
.replace("%AllTime%", tranTime(PlayMusic.musicAllTime))
.replace("%NowTime%", tranTime(PlayMusic.musicNowTime / 1000))
.replace("%Author%", PlayMusic.nowPlayMusic.getAuthor())
.replace("%Alia%", PlayMusic.nowPlayMusic.getAlia())
.replace("%Al%", PlayMusic.nowPlayMusic.getAl())
.replace("%Player%", PlayMusic.nowPlayMusic.getCall());
}
AllMusic.side.sendHudInfo(info);
}
/**
* 更新Hud的歌词数据
*/
public static void sendHudLyricData() {
String info;
LyricSave obj = PlayMusic.lyric;
if (obj == null) {
info = AllMusic.getMessage().Hud.NoLyric;
} else {
String lyric = obj.getLyric();
String tLyric = obj.getTlyric();
String kLyric = obj.getKly();
if (!AllMusic.getConfig().KtvMode) {
info = AllMusic.getMessage().Hud.Lyric
.replace("%Lyric%", lyric == null ? "" : lyric)
.replace("%Tlyric%", tLyric != null ? tLyric : "");
} else {
info = AllMusic.getMessage().Hud.Ktv
.replace("%Lyric%", lyric != null ? lyric : "")
.replace("%KLyric%", kLyric != null ? kLyric : "")
.replace("%Tlyric%", tLyric != null ? tLyric : "");
}
}
AllMusic.side.sendHudLyric(info);
}
/**
* 更新Hud的开启关闭数据
*
* @param player 用户名
* @param pos 输入数据
* @return 设置结果
*/
public static boolean setHudEnable(String player, String pos) {
SaveObj obj = get(player);
boolean res = false;
if (obj == null) {
obj = AllMusic.getConfig().DefaultHud.copy();
res = obj.EnableInfo && obj.EnableList && obj.EnableLyric;
} else {
if (pos == null) {
if (obj.EnableInfo && obj.EnableList && obj.EnableLyric) {
obj.EnableInfo = false;
obj.EnableList = false;
obj.EnableLyric = false;
obj.EnablePic = false;
} else {
obj.EnableInfo = true;
obj.EnableList = true;
obj.EnableLyric = true;
obj.EnablePic = true;
res = true;
}
} else {
HudPos pos1 = HudPos.valueOf(pos);
switch (pos1) {
case info:
obj.EnableInfo = !obj.EnableInfo;
break;
case list:
obj.EnableList = !obj.EnableList;
break;
case lyric:
obj.EnableLyric = !obj.EnableLyric;
break;
case pic:
obj.EnablePic = !obj.EnablePic;
break;
}
}
}
clearHud(player);
addAndSave(player, obj);
AllMusic.save();
HudUtils.sendHudPos(player);
if (pos == null) {
return res;
} else {
HudPos pos1 = HudPos.valueOf(pos);
switch (pos1) {
case info:
return obj.EnableInfo;
case list:
return obj.EnableList;
case lyric:
return obj.EnableLyric;
case pic:
return obj.EnablePic;
}
}
return false;
}
/**
* 清空Hud数据
*/
public static void clearHud() {
AllMusic.side.clearHud();
}
/**
* 清空Hud数
*
* @param player 用户名
*/
public static void clearHud(String player) {
AllMusic.side.clearHud(player);
}
/**
* 发送Hud位置信息
*
* @param player 用户名
*/
public static void sendHudPos(String player) {
AllMusic.side.runTask(() -> {
try {
SaveObj obj = get(player);
if (obj == null) {
obj = AllMusic.getConfig().DefaultHud.copy();
addAndSave(player, obj);
AllMusic.save();
}
String data = new Gson().toJson(obj);
AllMusic.side.send(data, player);
} catch (Exception e1) {
AllMusic.log.warning("§d[AllMusic]§c数据发送发生错误");
e1.printStackTrace();
}
});
}
/**
* 重置Hud位置
*
* @param player 用户名
*/
public static void reset(String player) {
SaveObj obj = AllMusic.getConfig().DefaultHud.copy();
clearHud(player);
addAndSave(player, obj);
HudUtils.sendHudPos(player);
}
/**
* 设置Hud的图片大小
*
* @param player 用户名
* @param size 大小
* @return 结果
*/
public static boolean setPicSize(String player, String size) {
SaveObj obj = get(player);
if (obj == null)
obj = AllMusic.getConfig().DefaultHud.copy();
if (!Function.isInteger(size))
return false;
obj.PicSize = Integer.parseInt(size);
addAndSave(player, obj);
HudUtils.sendHudPos(player);
return true;
}
/**
* 图片旋转开关
* @param player 用户名
* @param open 开关
* @return 结果
*/
public static boolean setPicRotate(String player, String open) {
SaveObj obj = get(player);
if (obj == null)
obj = AllMusic.getConfig().DefaultHud.copy();
obj.EnablePicRotate = Boolean.parseBoolean(open);
addAndSave(player, obj);
HudUtils.sendHudPos(player);
return obj.EnablePicRotate;
}
/**
* 图片旋转速度设置
* @param player 用户名
* @param size 大小
* @return 结果
*/
public static boolean setPicRotateSpeed(String player, String size){
SaveObj obj = get(player);
if (obj == null)
obj = AllMusic.getConfig().DefaultHud.copy();
if (!Function.isInteger(size))
return false;
obj.PicRotateSpeed = Integer.parseInt(size);
addAndSave(player, obj);
HudUtils.sendHudPos(player);
return true;
}
}
@@ -0,0 +1,342 @@
package coloryr.allmusic.core.music.api;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.enums.EncryptType;
import coloryr.allmusic.core.music.play.LyricDo;
import coloryr.allmusic.core.music.play.LyricSave;
import coloryr.allmusic.core.music.play.PlayMusic;
import coloryr.allmusic.core.objs.HttpResObj;
import coloryr.allmusic.core.objs.SearchMusicObj;
import coloryr.allmusic.core.objs.api.music.info.InfoObj;
import coloryr.allmusic.core.objs.api.music.list.DataObj;
import coloryr.allmusic.core.objs.api.music.lyric.WLyricObj;
import coloryr.allmusic.core.objs.api.music.search.SearchDataObj;
import coloryr.allmusic.core.objs.api.music.search.songs;
import coloryr.allmusic.core.objs.api.music.trialinfo.TrialInfoObj;
import coloryr.allmusic.core.objs.api.program.info.PrInfoObj;
import coloryr.allmusic.core.objs.music.SearchPageObj;
import coloryr.allmusic.core.objs.music.SongInfoObj;
import coloryr.allmusic.core.utils.Logs;
import com.google.gson.JsonObject;
import okhttp3.Cookie;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.concurrent.CopyOnWriteArrayList;
public class APIMain {
public int PlayNow = 0;
public boolean isUpdata;
public APIMain() {
AllMusic.log.info("§d[AllMusic]§e正在初始化网络爬虫");
HttpClientUtil.init();
HttpResObj res = HttpClientUtil.get("https://music.163.com", "");
if (res == null || !res.ok) {
AllMusic.log.info("§d[AllMusic]§c初始化网络爬虫连接失败");
}
}
/**
* 获取手机验证码
*
* @param sender 发送者
*/
public void sendCode(Object sender) {
JsonObject params = new JsonObject();
params.addProperty("ctcode", "86");
params.addProperty("cellphone", AllMusic.getConfig().LoginUser);
HttpResObj res = HttpClientUtil.post("https://music.163.com/api/sms/captcha/sent", params, EncryptType.WEAPI, null);
AllMusic.side.sendMessage(sender, "§d[AllMusic]§d已发送验证码\n" + res.data);
}
/**
* 登录
*
* @param sender 发送者
* @param code 手机验证码
*/
public void login(Object sender, String code) {
JsonObject params = new JsonObject();
params.addProperty("rememberLogin", "true");
if (AllMusic.cookie.cookieStore.containsKey("music.163.com")) {
List<Cookie> cookies = AllMusic.cookie.cookieStore.get("music.163.com");
for (Cookie item : cookies) {
if (item.name().equalsIgnoreCase("os")) {
cookies.remove(item);
break;
}
}
for (Cookie item : cookies) {
if (item.name().equalsIgnoreCase("appver")) {
cookies.remove(item);
break;
}
}
List<Cookie> cookies1 = new CopyOnWriteArrayList<>();
cookies1.addAll(cookies);
cookies1.add(new Cookie.Builder().name("os").value("pc").domain("music.163.com").build());
cookies1.add(new Cookie.Builder().name("appver").value("2.10.6").domain("music.163.com").build());
AllMusic.cookie.cookieStore.put("music.163.com", cookies1);
AllMusic.saveCookie();
}
params.addProperty("countrycode", "86");
params.addProperty("phone", AllMusic.getConfig().LoginUser);
params.addProperty("captcha", code);
HttpResObj res = HttpClientUtil.post("https://music.163.com/eapi/w/login/cellphone", params, EncryptType.WEAPI, null);
if (res == null || !res.ok) {
if (sender == null)
AllMusic.log.info("§d[AllMusic]§c登录失败");
else
AllMusic.side.sendMessage(sender, "§d[AllMusic]§c登录失败");
return;
}
if (res.data.contains("200")) {
if (sender == null)
AllMusic.log.info("§d[AllMusic]§d已登录");
else
AllMusic.side.sendMessage(sender, "§d[AllMusic]§d已登录");
} else {
if (sender == null)
AllMusic.log.info("§d[AllMusic]§c登录失败:账号或密码错误\n" + res.data);
else
AllMusic.side.sendMessage(sender, "§d[AllMusic]§c登录失败:账号或密码错误\n" + res.data);
}
}
/**
* 获取音乐详情
*
* @param id 音乐ID
* @param player 用户名
* @param isList 是否是空闲列表
* @return 结果
*/
private SongInfoObj getMusicDetail(String id, String player, boolean isList) {
JsonObject params = new JsonObject();
params.addProperty("c", "[{\"id\":" + id + "}]");
HttpResObj res = HttpClientUtil.post("https://music.163.com/api/v3/song/detail", params, EncryptType.WEAPI, null);
if (res != null && res.ok) {
InfoObj temp = AllMusic.gson.fromJson(res.data, InfoObj.class);
if (temp.isOk()) {
params = new JsonObject();
params.addProperty("ids", "[" + id + "]");
params.addProperty("br", "320000");
res = HttpClientUtil.post("https://music.163.com/weapi/song/enhance/player/url", params, EncryptType.WEAPI, null);
if (res == null || !res.ok) {
AllMusic.log.warning("§d[AllMusic]§c版权检索失败");
return null;
}
TrialInfoObj obj = AllMusic.gson.fromJson(res.data, TrialInfoObj.class);
return new SongInfoObj(temp.getAuthor(), temp.getName(),
id, temp.getAlia(), player, temp.getAl(), isList, temp.getLength(),
temp.getPicUrl(), obj.isTrial(), obj.getFreeTrialInfo());
}
}
return null;
}
/**
* 获取音乐数据
*
* @param id 音乐ID
* @param player 用户名
* @param isList 是否是空闲列表
* @return 结果
*/
public SongInfoObj getMusic(String id, String player, boolean isList) {
SongInfoObj info = getMusicDetail(id, player, isList);
if (info != null)
return info;
JsonObject params = new JsonObject();
params.addProperty("id", id);
HttpResObj res = HttpClientUtil.post("https://music.163.com/api/dj/program/detail", params, EncryptType.WEAPI, null);
if (res != null && res.ok) {
PrInfoObj temp = AllMusic.gson.fromJson(res.data, PrInfoObj.class);
if (temp.isOk()) {
return new SongInfoObj(temp.getAuthor(), temp.getName(),
temp.getId(), temp.getAlia(), player, "电台", isList, temp.getLength(),
null, false, null);
} else {
AllMusic.log.warning("§d[AllMusic]§c歌曲信息获取为空");
}
}
return info;
}
/**
* 获取播放链接
*
* @param id 音乐ID
* @return 结果
*/
public String getPlayUrl(String id) {
JsonObject params = new JsonObject();
params.addProperty("ids", "[" + id + "]");
params.addProperty("br", AllMusic.getConfig().MusicBR);
HttpResObj res = HttpClientUtil.post("https://music.163.com/weapi/song/enhance/player/url", params, EncryptType.WEAPI, null);
if (res != null && res.ok) {
try {
TrialInfoObj obj = AllMusic.gson.fromJson(res.data, TrialInfoObj.class);
return obj.getUrl();
} catch (Exception e) {
Logs.logWrite(res.data);
AllMusic.log.warning("§d[AllMusic]§c播放连接解析错误");
e.printStackTrace();
}
}
return null;
}
/**
* 添加空闲歌单
*
* @param id 歌单id
* @param sender 发送者
*/
public void setList(String id, Object sender) {
final Thread thread = new Thread(() -> {
JsonObject params = new JsonObject();
params.addProperty("id", id);
params.addProperty("n", 100000);
params.addProperty("s", 8);
HttpResObj res = HttpClientUtil.post("https://music.163.com/api/v6/playlist/detail", params, EncryptType.API, null);
if (res != null && res.ok)
try {
isUpdata = true;
DataObj obj = AllMusic.gson.fromJson(res.data, DataObj.class);
AllMusic.getConfig().PlayList.addAll(obj.getPlaylist());
AllMusic.save();
AllMusic.side.sendMessaget(sender, AllMusic.getMessage().MusicPlay.ListMusic.Get.replace("%ListName%", obj.getName()));
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌曲列表获取错误");
e.printStackTrace();
}
isUpdata = false;
}, "AllMusic_setList");
thread.start();
}
/**
* 获取歌词
*
* @param id 歌曲id
* @return 结果
*/
public LyricSave getLyric(String id) {
LyricSave lyric = new LyricSave();
JsonObject params = new JsonObject();
params.addProperty("id", id);
params.addProperty("cp", false);
params.addProperty("tv", 0);
params.addProperty("lv", 0);
params.addProperty("rv", 0);
params.addProperty("kv", 0);
params.addProperty("yv", 0);
params.addProperty("ytv", 0);
params.addProperty("rtv", 0);
HttpResObj res = HttpClientUtil.post("https://interface3.music.163.com/eapi/song/lyric/v1",
params, EncryptType.EAPI, "/api/song/lyric/v1");
if (res != null && res.ok) {
try {
WLyricObj obj = AllMusic.gson.fromJson(res.data, WLyricObj.class);
LyricDo temp = new LyricDo();
for (int times = 0; times < 3; times++) {
if (temp.check(obj)) {
AllMusic.log.warning("§d[AllMusic]§c歌词解析错误,正在进行第" + times + "重试");
} else {
if (temp.isHave) {
lyric.setHaveLyric(AllMusic.getConfig().SendLyric);
lyric.setLyric(temp.getTemp());
if (temp.isHaveK) {
lyric.setKlyric(temp.getKLyric());
}
}
return lyric;
}
Thread.sleep(1000);
}
AllMusic.log.warning("§d[AllMusic]§c歌词解析失败");
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌词解析错误");
e.printStackTrace();
}
}
return lyric;
}
/**
* 搜歌
*
* @param name 关键字
* @param isDefault 是否是默认方式
* @return 结果
*/
public SearchPageObj search(String[] name, boolean isDefault) {
List<SearchMusicObj> resData = new ArrayList<>();
int maxpage;
StringBuilder name1 = new StringBuilder();
for (int a = isDefault ? 0 : 1; a < name.length; a++) {
name1.append(name[a]).append(" ");
}
String MusicName = name1.toString();
MusicName = MusicName.substring(0, MusicName.length() - 1);
JsonObject params = new JsonObject();
params.addProperty("s", MusicName);
params.addProperty("type", 1);
params.addProperty("limit", 30);
params.addProperty("offset", 0);
HttpResObj res = HttpClientUtil.post("https://music.163.com/weapi/search/get", params, EncryptType.WEAPI, null);
if (res != null && res.ok) {
SearchDataObj obj = AllMusic.gson.fromJson(res.data, SearchDataObj.class);
if (obj != null && obj.isOk()) {
List<songs> res1 = obj.getResult();
SearchMusicObj item;
for (songs temp : res1) {
item = new SearchMusicObj(String.valueOf(temp.getId()), temp.getName(), temp.getArtists(), temp.getAlbum());
resData.add(item);
}
maxpage = res1.size() / 10;
return new SearchPageObj(resData, maxpage);
} else {
AllMusic.log.warning("§d[AllMusic]§c歌曲搜索出现错误");
}
}
return null;
}
/**
* 获取空闲歌单的一首歌
*
* @return 结果
*/
public String getListMusic() {
if (PlayMusic.error >= 10)
return null;
if (!isUpdata && AllMusic.getConfig().PlayList.size() != 0) {
String ID;
if (AllMusic.getConfig().PlayListRandom) {
if (AllMusic.getConfig().PlayList.size() == 0)
return null;
else if (AllMusic.getConfig().PlayList.size() == 1)
return AllMusic.getConfig().PlayList.get(0);
ID = AllMusic.getConfig().PlayList.get(new Random().nextInt(AllMusic.getConfig().PlayList.size()));
} else {
ID = AllMusic.getConfig().PlayList.get(PlayNow);
if (PlayNow == AllMusic.getConfig().PlayList.size() - 1)
PlayNow = 0;
else
PlayNow++;
}
return ID;
}
return null;
}
}
@@ -0,0 +1,137 @@
package coloryr.allmusic.core.music.api;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.api.EncResObj;
import com.google.gson.JsonObject;
import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
public class CryptoUtil {
private static final String presetKey = "0CoJUm6Qyw8W8jud";
private static final String iv = "0102030405060708";
private static final String base62 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
private final static char[] hexArray = "0123456789ABCDEF".toCharArray();
private static final String eapiKey = "e82ckenh8dichen8";
private static String createSecretKey(int size) {
StringBuilder key = new StringBuilder();
for (int i = 0; i < size; i++) {
double index = Math.floor(Math.random() * base62.length());
key.append(base62.charAt((int) index));
}
return key.toString();
}
public static String byteArrToHex(byte[] bytes) {
char[] hexChars = new char[bytes.length * 2];
for (int j = 0; j < bytes.length; j++) {
int v = bytes[j] & 0xFF;
hexChars[j * 2] = hexArray[v >>> 4];
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
}
return new String(hexChars);
}
private static String aesEncrypt(String content, String key, String iv) {
String result = null;
if (content == null || key == null)
return result;
try {
Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
byte[] keys = key.getBytes(StandardCharsets.UTF_8);
byte[] ivs = iv.getBytes(StandardCharsets.UTF_8);
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(keys, "AES"),
new IvParameterSpec(ivs));
bytes = cipher.doFinal(bytes);
result = Base64.getEncoder().encodeToString(bytes);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private static String aesEncrypt(String content, String key) {
String result = null;
if (content == null || key == null)
return result;
try {
Cipher cipher = Cipher.getInstance("AES/ECB/PKCS5Padding");
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
byte[] keys = key.getBytes(StandardCharsets.UTF_8);
cipher.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(keys, "AES"));
bytes = cipher.doFinal(bytes);
result = byteArrToHex(bytes).toUpperCase();
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
private static String zFill(String str) {
StringBuilder strBuilder = new StringBuilder(str);
while (strBuilder.length() < 256) {
strBuilder.insert(0, "0");
}
str = strBuilder.toString();
return str;
}
private static String rsaEncrypt(String text) {
text = new StringBuffer(text).reverse().toString();
BigInteger biText = new BigInteger(strToHex(text), 16);
BigInteger biEx = new BigInteger("010001", 16);
BigInteger biMod = new BigInteger("00e0b509f6259df8642dbc35662901477df22677ec152b5ff68ace615bb7b725152b3ab17a876aea8a5aa76d2e417629ec4ee341f56135fccf695280104e0312ecbda92557c93870114af6c9d05c4f7f0c3685b7a46bee255932575cce10b424d813cfe4875d3e82047b97ddef52741d546b8e289dc6935b3ece0462db0a22b8e7", 16);
BigInteger biRet = biText.modPow(biEx, biMod);
return zFill(biRet.toString(16));
}
private static String strToHex(String s) {
StringBuilder str = new StringBuilder();
for (int i = 0; i < s.length(); i++) {
int ch = s.charAt(i);
String s4 = Integer.toHexString(ch);
str.append(s4);
}
return str.toString();
}
public static EncResObj weapiEncrypt(String content) {
String key = createSecretKey(16);
String encText = aesEncrypt(aesEncrypt(content, presetKey, iv), key, iv);
String encSecKey = rsaEncrypt(key);
return new EncResObj(encText, encSecKey);
}
public static EncResObj eapi(String url, JsonObject object) {
String text = AllMusic.gson.toJson(object);
String message = "nobody" + url + "use" + text + "md5forencrypt";
String digest = getMd5(message);
String data = url + "-36cd479b6b5-" + text + "-36cd479b6b5-" + digest;
return new EncResObj(aesEncrypt(data, eapiKey), "");
}
public static String getMd5(String plainText) {
byte[] secretBytes;
try {
MessageDigest digest = MessageDigest.getInstance("md5");
digest.update(plainText.getBytes(StandardCharsets.UTF_8));
secretBytes = digest.digest();
} catch (NoSuchAlgorithmException e) {
throw new RuntimeException("没有这个md5算法!");
}
return byteArrToHex(secretBytes);
}
}
@@ -0,0 +1,171 @@
package coloryr.allmusic.core.music.api;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.enums.EncryptType;
import coloryr.allmusic.core.objs.HttpResObj;
import coloryr.allmusic.core.objs.api.EncResObj;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import okhttp3.*;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
public class HttpClientUtil {
private static final int CONNECT_TIMEOUT = 5;
private static final int READ_TIMEOUT = 7;
private static OkHttpClient client;
public static void init() {
try {
synchronized (OkHttpClient.class) {
client = new OkHttpClient.Builder().cookieJar(new MyCookieJar())
.connectTimeout(CONNECT_TIMEOUT, TimeUnit.SECONDS)
.readTimeout(READ_TIMEOUT, TimeUnit.SECONDS)
.build();
}
} catch (Exception e) {
e.printStackTrace();
}
}
public static HttpResObj get(String path, String data) {
try {
data = URLEncoder.encode(data, "UTF-8");
Request request = new Request.Builder().url(path + data)
.addHeader("referer", "https://music.163.com")
.addHeader("content-type", "application/json;charset=UTF-8")
.addHeader("user-agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 Edg/91.0.864.41")
.get()
.build();
Response response = client.newCall(request).execute();
int httpCode = response.code();
ResponseBody body = response.body();
if (body == null) {
AllMusic.log.warning("§d[AllMusic]§c获取网页错误");
return null;
}
InputStream inputStream = body.byteStream();
boolean ok = httpCode == 200;
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int length;
while ((length = inputStream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
String data1 = result.toString(StandardCharsets.UTF_8.name());
if (!ok) {
AllMusic.log.warning("§d[AllMusic]§c服务器返回错误:" + data1);
}
return new HttpResObj(data1, ok);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c获取网页错误");
e.printStackTrace();
}
return null;
}
public static HttpResObj post(String url, JsonObject data, EncryptType type, String ourl) {
try {
RequestBody formBody;
Request.Builder request = new Request.Builder();
request = request.addHeader("Content-Type", "application/x-www-form-urlencoded");
request = request.addHeader("Referer", "https://music.163.com");
EncResObj res;
List<Cookie> cookies = new ArrayList<>();
if (AllMusic.cookie.cookieStore.containsKey("music.163.com")) {
cookies = AllMusic.cookie.cookieStore.get("music.163.com");
}
if (type == EncryptType.WEAPI) {
request = request.addHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/13.10586");
String csrfToken = "";
for (Cookie item : cookies) {
if (item.name().equalsIgnoreCase("__csrf")) {
csrfToken = item.value();
}
}
data.addProperty("csrf_token", csrfToken);
res = CryptoUtil.weapiEncrypt(AllMusic.gson.toJson(data));
url = url.replaceFirst("\\w*api", "weapi");
request = request.url(url);
formBody = new FormBody.Builder()
.add("params", res.params)
.add("encSecKey", res.encSecKey)
.build();
} else if (type == EncryptType.EAPI) {
request = request.addHeader("User-Agent", "Mozilla/5.0 (Linux; Android 9; PCT-AL10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.64 HuaweiBrowser/10.0.3.311 Mobile Safari/537.36");
JsonObject header = new JsonObject();
header.addProperty("appver", "8.0.0");
header.addProperty("versioncode", "140");
header.addProperty("buildver", new Date().toString().substring(0, 10));
header.addProperty("resolution", "1920x1080");
header.addProperty("os", "android");
String requestId = "0000" + (new Date() + "_" + Math.floor(Math.random() * 1000));
header.addProperty("requestId", requestId);
for (Cookie item : cookies) {
if (item.name().equalsIgnoreCase("MUSIC_U")) {
header.addProperty("MUSIC_U", item.value());
} else if (item.name().equalsIgnoreCase("MUSIC_A")) {
header.addProperty("MUSIC_A", item.value());
} else if (item.name().equalsIgnoreCase("channel")) {
header.addProperty("channel", item.value());
} else if (item.name().equalsIgnoreCase("mobilename")) {
header.addProperty("mobilename", item.value());
} else if (item.name().equalsIgnoreCase("osver")) {
header.addProperty("osver", item.value());
} else if (item.name().equalsIgnoreCase("__csrf")) {
header.addProperty("__csrf", item.value());
}
}
data.add("header", header);
res = CryptoUtil.eapi(ourl, data);
url = url.replaceFirst("\\w*api", "eapi");
request = request.url(url);
formBody = new FormBody.Builder()
.add("params", res.params)
.build();
} else {
request = request.url(url);
FormBody.Builder builder = new FormBody.Builder();
for (Map.Entry<String, JsonElement> item : data.entrySet()) {
builder = builder.add(item.getKey(), item.getValue().getAsString());
}
formBody = builder.build();
}
request = request.post(formBody);
Response response = client.newCall(request.build()).execute();
int httpCode = response.code();
ResponseBody body = response.body();
if (body == null) {
AllMusic.log.warning("§d[AllMusic]§c获取网页错误");
return null;
}
InputStream inputStream = body.byteStream();
boolean ok = httpCode == 200;
ByteArrayOutputStream result = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int length;
while ((length = inputStream.read(buffer)) != -1) {
result.write(buffer, 0, length);
}
String data1 = result.toString(StandardCharsets.UTF_8.name());
if (!ok) {
AllMusic.log.warning("§d[AllMusic]§c服务器返回错误:" + data1);
}
return new HttpResObj(data1, ok);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c获取网页错误");
e.printStackTrace();
}
return null;
}
}
@@ -0,0 +1,38 @@
package coloryr.allmusic.core.music.api;
import coloryr.allmusic.core.AllMusic;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
public class MyCookieJar implements CookieJar {
@Override
public void saveFromResponse(HttpUrl httpUrl, @NotNull List<Cookie> list) {
if (AllMusic.cookie.cookieStore.containsKey(httpUrl.host())) {
List<Cookie> cookies = AllMusic.cookie.cookieStore.get(httpUrl.host());
for (Cookie item : list) {
for (Cookie item1 : cookies) {
if (item.name().equalsIgnoreCase(item1.name())) {
cookies.remove(item1);
break;
}
}
cookies.add(item);
}
AllMusic.cookie.cookieStore.put(httpUrl.host(), cookies);
} else {
AllMusic.cookie.cookieStore.put(httpUrl.host(), list);
}
AllMusic.saveCookie();
}
@Override
public @NotNull List<Cookie> loadForRequest(HttpUrl httpUrl) {
List<Cookie> cookies = AllMusic.cookie.cookieStore.get(httpUrl.host());
return cookies != null ? cookies : new CopyOnWriteArrayList<>();
}
}
@@ -0,0 +1,171 @@
package coloryr.allmusic.core.music.play;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.api.music.lyric.WLyricObj;
import coloryr.allmusic.core.objs.music.LyricItemObj;
import coloryr.allmusic.core.utils.Function;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LyricDo {
private static final Pattern p = Pattern.compile("\\(([0-9]+),[0-9]+.[0-9]\\)");
private final Map<Integer, LyricItemObj> temp = new LinkedHashMap<>();
public boolean isHave = false;
public boolean isHaveK = false;
public Map<Integer, String> kly = new LinkedHashMap<>();
public Map<Integer, LyricItemObj> getTemp() {
return temp;
}
public Map<Integer, String> getKLyric() {
return kly;
}
/**
* 检查歌词
*
* @param obj 歌词
* @return 结果
*/
public boolean check(WLyricObj obj) {
String[] lyric;
boolean haveT = false;
if (!obj.isOk())
return true;
else if (obj.isNone())
return false;
lyric = obj.getLyric().split("\n");
Map<Integer, String> temp = getTime(Arrays.asList(lyric));
Map<Integer, String> temp1 = new HashMap<>();
if (obj.getTlyric() != null) {
List<String> tlyric = Arrays.asList(obj.getTlyric().split("\n"));
haveT = true;
temp1 = getTime(tlyric);
}
String temp2 = obj.getYrc() == null ? obj.getKlyric() : obj.getYrc();
if (temp2 != null && !temp2.isEmpty()) {
String[] klyric = temp2.split("\n");
for (String item : klyric) {
Map<Integer, String> temp4 = getKTime(item, obj.getVersion());
if (temp4 != null) {
kly.putAll(temp4);
}
}
isHaveK = true;
}
for (Map.Entry<Integer, String> item : temp.entrySet()) {
this.temp.put(item.getKey(), new LyricItemObj(item.getValue(),
haveT ? temp1.get(item.getKey()) : null));
}
isHave = true;
return false;
}
/**
* 将歌词转换成时间 字
*
* @param lyric 歌词
* @return 结果
*/
private Map<Integer, String> getTime(List<String> lyric) {
Map<Integer, String> res = new LinkedHashMap<>();
String min;
String sec;
String mil;
int time;
int milt;
for (String s : lyric) {
if (!s.startsWith("["))
continue;
String temp = Function.getString(s, "[", "]");
if (!temp.contains(".") || !temp.contains(":"))
continue;
if (Function.countChar(temp, ':') > 1) {
String[] a = s.split(":");
min = a[0].substring(1);
sec = a[1];
mil = a[2];
} else {
min = Function.getString(s, "[", ":");
sec = Function.getString(s, ":", ".");
mil = Function.getString(s, ".", "]");
}
if (!Function.isInteger(min))
continue;
if (!Function.isInteger(sec))
continue;
if (!Function.isInteger(mil))
continue;
if (min.isEmpty() || sec.isEmpty() || mil.isEmpty())
continue;
milt = Integer.parseInt(mil);
if (mil.length() == 3) {
milt /= 10;
}
time = Integer.parseInt(min) * 60 * 1000 + Integer.parseInt(sec) * 1000 + milt * 10;
if (time > 0 && time + AllMusic.getConfig().Delay > 0)
time += AllMusic.getConfig().Delay / 10 * 10;
res.put(time, Function.getString(s, "]", null));
}
return res;
}
private Map<Integer, String> getKTime(String lyric, boolean yrc) {
Map<Integer, String> res = new LinkedHashMap<>();
if (!lyric.startsWith("[") || !lyric.contains("]("))
return null;
String[] datas = lyric.split("\\(([0-9]+),[0-9]+.[0-9]\\)");
Matcher m = p.matcher(lyric);
List<String> temp1111 = new ArrayList<>();
while (m.find()) {
temp1111.add(m.group()
.replace("(", "")
.replace(")", ""));
}
if (datas.length == 1)
return null;
String temp = Function.getString(lyric, "[", "]");
String[] temp11 = temp.split(",");
int now = Integer.parseInt(temp11[0]) / 10 * 10;
for (int a = 1; a < datas.length; a++) {
String data = datas[a];
String temp3 = temp1111.get(a - 1);
String[] temp8 = temp3.split(",");
int temp5;
if (yrc) {
temp5 = (Integer.parseInt(temp8[0]) / 10 * 10);
if (temp5 > 0 && temp5 + AllMusic.getConfig().KDelay > 0)
temp5 += (AllMusic.getConfig().KDelay / 10 * 10);
res.put(temp5, data);
} else {
try {
temp5 = (Integer.parseInt(temp8[1]) / 10 * 10);
} catch (Exception e) {
AllMusic.log.warning("不支持的Ktv歌词");
AllMusic.log.warning("请带上音乐ID联系开发者");
return null;
}
if (temp5 > 0 && temp5 + AllMusic.getConfig().KDelay > 0)
temp5 += (AllMusic.getConfig().KDelay / 10 * 10);
res.put(now, data);
now += temp5;
}
}
return res;
}
}
@@ -0,0 +1,110 @@
package coloryr.allmusic.core.music.play;
import coloryr.allmusic.core.objs.music.LyricItemObj;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public class LyricSave {
public int lastIndex = 0;
protected boolean haveLyric;
protected String lly;
protected String kly;
protected String tly;
private Map<Integer, LyricItemObj> lyric;
private Map<Integer, String> klyric;
private LyricItemObj now;
private int last;
private String kNow;
public LyricSave() {
haveLyric = false;
lyric = new HashMap<>();
}
public void setKlyric(Map<Integer, String> klyric) {
this.klyric = klyric;
}
public boolean isHaveLyric() {
return haveLyric;
}
public void setHaveLyric(boolean haveLyric) {
this.haveLyric = haveLyric;
}
public String getLyric() {
return lly;
}
public void setLyric(Map<Integer, LyricItemObj> lyric) {
this.lyric = lyric;
}
public String getTlyric() {
return tly;
}
public String getKly() {
return kly;
}
public boolean kUpdate() {
if (lastIndex >= now.lyric.length()) {
kly = now.lyric;
lly = "";
} else if (kNow != null) {
int index = now.lyric.toLowerCase(Locale.ROOT).indexOf(kNow, lastIndex);
if (index != -1) {
lastIndex = index + kNow.length();
kly = now.lyric.substring(0, lastIndex);
lly = now.lyric.substring(lastIndex);
return true;
}
} else {
kly = "";
}
return false;
}
public boolean ktv(int time) {
if (last == time || klyric == null)
return false;
String temp = klyric.get(time);
if (temp != null) {
kNow = temp.toLowerCase(Locale.ROOT);
last = time;
return kUpdate();
}
return false;
}
public boolean checkTime(int playNow, boolean ktv) {
if (lyric == null)
return false;
boolean res = false;
LyricItemObj temp = lyric.get(playNow);
if (temp != null) {
now = temp;
lly = now.lyric;
tly = now.tlyric;
kly = null;
lastIndex = 0;
kUpdate();
return true;
}
if (ktv && now != null) {
res = ktv(playNow);
}
return res;
}
}
@@ -0,0 +1,51 @@
package coloryr.allmusic.core.music.play;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.command.CommandEX;
import coloryr.allmusic.core.objs.music.MusicObj;
import coloryr.allmusic.core.objs.music.SearchPageObj;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
public class MusicSearch {
private static final Queue<MusicObj> tasks = new ConcurrentLinkedQueue<>();
private static boolean isRun;
private static void task() {
while (isRun) {
try {
MusicObj obj = tasks.poll();
if (obj != null) {
SearchPageObj search = AllMusic.getMusicApi().search(obj.args, obj.isDefault);
if (search == null)
AllMusic.side.sendMessaget(obj.sender, AllMusic.getMessage().Search
.CantSearch.replace("%Music%", obj.isDefault ? obj.args[0] : obj.args[1]));
else {
AllMusic.side.sendMessaget(obj.sender, AllMusic.getMessage().Search.Res);
AllMusic.addSearch(obj.name, search);
AllMusic.side.runTask(() -> CommandEX.showSearch(obj.sender, search));
}
}
Thread.sleep(100);
} catch (Exception e) {
AllMusic.log.warning("搜歌出现问题");
e.printStackTrace();
}
}
}
public static void start() {
Thread taskT = new Thread(MusicSearch::task, "AllMusic_search");
isRun = true;
taskT.start();
}
public static void stop() {
isRun = false;
}
public static void addSearch(MusicObj obj) {
tasks.add(obj);
}
}
@@ -0,0 +1,230 @@
package coloryr.allmusic.core.music.play;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.hud.HudUtils;
import coloryr.allmusic.core.objs.music.MusicObj;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
public class PlayGo {
/**
* 播放链接
*/
public static String url;
/**
* 倒数计数器
*/
private static int count = 0;
private static boolean isRun;
/**
* 歌曲更新计数器
*/
private static int times = 0;
private static ScheduledExecutorService service;
private static ScheduledExecutorService service1;
private static ScheduledExecutorService service2;
/**
* 启动歌曲工作
*/
public static void start() {
Thread taskT = new Thread(PlayGo::task, "AllMusic_Play");
isRun = true;
taskT.start();
service2 = Executors.newSingleThreadScheduledExecutor();
service2.scheduleAtFixedRate(PlayGo::time3, 0, 10, TimeUnit.SECONDS);
}
/**
* 停止歌曲工作
*/
public static void stop() {
closeTimer();
isRun = false;
PlayMusic.musicLessTime = 0;
}
private static void closeTimer() {
if (service != null) {
service.shutdown();
service = null;
}
if (service1 != null) {
service1.shutdown();
service1 = null;
}
if (service2 != null) {
service2.shutdown();
service2 = null;
}
}
private static void startTimer() {
service = Executors.newSingleThreadScheduledExecutor();
service.scheduleAtFixedRate(PlayGo::time1, 0, 10, TimeUnit.MILLISECONDS);
if (PlayMusic.lyric != null && PlayMusic.lyric.isHaveLyric()) {
service1 = Executors.newSingleThreadScheduledExecutor();
service1.scheduleAtFixedRate(PlayGo::time2, 0, 2, TimeUnit.MILLISECONDS);
}
}
/**
* 清空歌曲数据
*/
private static void clear() {
closeTimer();
PlayMusic.musicNowTime = 0;
PlayMusic.musicAllTime = 0;
PlayMusic.musicLessTime = 0;
PlayMusic.lyric = null;
PlayMusic.nowPlayMusic = null;
AllMusic.side.updateInfo();
HudUtils.clearHud();
}
private static void time1() {
PlayMusic.musicNowTime += 10;
count++;
if (count == 100) {
PlayMusic.musicLessTime--;
count = 0;
}
}
private static void time2() {
try {
if (PlayMusic.lyric == null)
return;
boolean res = PlayMusic.lyric
.checkTime(PlayMusic.musicNowTime, AllMusic.getConfig().KtvMode);
if (res) {
times = 0;
HudUtils.sendHudLyricData();
AllMusic.side.updateLyric();
} else {
times++;
if (times == 500 && PlayMusic.lyric != null) {
times = 0;
HudUtils.sendHudLyricData();
AllMusic.side.updateLyric();
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
private static void time3() {
AllMusic.side.ping();
}
private static void task() {
while (isRun) {
try {
if (PlayMusic.getSize() == 0) {
HudUtils.sendHudNowData();
HudUtils.sendHudLyricData();
HudUtils.sendHudListData();
if (AllMusic.side.needPlay()) {
String ID = AllMusic.getMusicApi().getListMusic();
if (ID != null) {
MusicObj obj = new MusicObj();
obj.sender = ID;
obj.name = "空闲列表";
obj.isDefault = true;
PlayMusic.addMusic(null, ID, "空闲列表", true);
}
}
Thread.sleep(50);
} else {
AllMusic.side.sendHudUtilsAll();
PlayMusic.nowPlayMusic = PlayMusic.remove(0);
if (AllMusic.side.onMusicPlay(PlayMusic.nowPlayMusic)) {
AllMusic.side.bqt(AllMusic.getMessage().MusicPlay.Cancel);
continue;
}
url = PlayMusic.nowPlayMusic.getPlayerUrl() == null ?
AllMusic.getMusicApi().getPlayUrl(PlayMusic.nowPlayMusic.getID()) :
PlayMusic.nowPlayMusic.getPlayerUrl();
if (url == null) {
String data = AllMusic.getMessage().MusicPlay.NoCanPlay;
AllMusic.side.bqt(data.replace("%MusicID%", PlayMusic.nowPlayMusic.getID()));
PlayMusic.nowPlayMusic = null;
continue;
}
if (PlayMusic.nowPlayMusic.getPlayerUrl() == null)
PlayMusic.lyric = AllMusic.getMusicApi().getLyric(PlayMusic.nowPlayMusic.getID());
else
PlayMusic.lyric = new LyricSave();
if (PlayMusic.nowPlayMusic.getLength() != 0) {
PlayMusic.musicAllTime = PlayMusic.musicLessTime = (PlayMusic.nowPlayMusic.getLength() / 1000) + 3;
if (!AllMusic.getConfig().MutePlayMessage) {
String info = AllMusic.getMessage().MusicPlay.Play;
info = info.replace("%MusicName%", PlayMusic.nowPlayMusic.getName())
.replace("%MusicAuthor%", PlayMusic.nowPlayMusic.getAuthor())
.replace("%MusicAl%", PlayMusic.nowPlayMusic.getAl())
.replace("%MusicAlia%", PlayMusic.nowPlayMusic.getAlia())
.replace("%PlayerName%", PlayMusic.nowPlayMusic.getCall());
if (AllMusic.getConfig().ShowInBar)
AllMusic.side.sendBar(info);
else
AllMusic.side.bqt(info);
}
startTimer();
AllMusic.side.sendMusic(url);
if (!PlayMusic.nowPlayMusic.isUrl() && PlayMusic.nowPlayMusic.getPicUrl() != null) {
AllMusic.side.sendPic(PlayMusic.nowPlayMusic.getPicUrl());
}
if (PlayMusic.nowPlayMusic.isTrial()) {
AllMusic.side.bqt(AllMusic.getMessage().MusicPlay.Trail);
PlayMusic.musicLessTime = PlayMusic.nowPlayMusic.getTrialInfo().getEnd();
PlayMusic.musicNowTime = PlayMusic.nowPlayMusic.getTrialInfo().getStart();
}
AllMusic.side.updateInfo();
while (PlayMusic.musicLessTime > 0) {
HudUtils.sendHudNowData();
HudUtils.sendHudListData();
if (!AllMusic.side.needPlay()) {
PlayMusic.musicLessTime = 1;
}
if (PlayMusic.voteTime > 0) {
PlayMusic.voteTime--;
if (PlayMusic.voteTime == 0) {
AllMusic.clearVote();
AllMusic.side.bqt(AllMusic.getMessage().Vote.TimeOut);
} else {
int players = AllMusic.side.getAllPlayer();
if (AllMusic.getVoteCount() >= AllMusic.getConfig().MinVote
|| (players <= AllMusic.getConfig().MinVote
&& players <= AllMusic.getVoteCount())) {
AllMusic.side.bqt(AllMusic.getMessage().Vote.Do);
AllMusic.clearVote();
PlayMusic.voteTime = 0;
break;
}
}
}
Thread.sleep(1000);
}
AllMusic.side.sendStop();
} else {
String data = AllMusic.getMessage().MusicPlay.NoCanPlay;
AllMusic.side.bqt(data.replace("%MusicID%", PlayMusic.nowPlayMusic.getID()));
}
clear();
}
} catch (InterruptedException e) {
AllMusic.log.warning("§c歌曲播放出现错误");
e.printStackTrace();
}
}
}
}
@@ -0,0 +1,263 @@
package coloryr.allmusic.core.music.play;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.decoder.Bitstream;
import coloryr.allmusic.core.decoder.Header;
import coloryr.allmusic.core.objs.music.MusicObj;
import coloryr.allmusic.core.objs.music.SongInfoObj;
import coloryr.allmusic.core.utils.Logs;
import java.io.BufferedInputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.CopyOnWriteArrayList;
public class PlayMusic {
/**
* 播放列表
*/
private static final List<SongInfoObj> playList = new CopyOnWriteArrayList<>();
private static final Queue<MusicObj> tasks = new ConcurrentLinkedQueue<>();
/**
* 投票时间
*/
public static int voteTime = 0;
/**
* 总歌曲长度
*/
public static int musicAllTime = 0;
/**
* 剩余歌曲长度
*/
public static int musicLessTime = 0;
/**
* 歌曲现在位置
*/
public static int musicNowTime = 0;
/**
* 当前歌曲信息
*/
public static SongInfoObj nowPlayMusic;
/**
* 当前歌词信息
*/
public static LyricSave lyric;
/**
* 错误次数
*/
public static int error;
private static boolean isRun;
/**
* 停止歌曲逻辑
*/
public static void stop() {
PlayMusic.clear();
isRun = false;
}
/**
* 开始歌曲逻辑
*/
public static void start() {
Thread addT = new Thread(PlayMusic::task, "AllMusic_list");
isRun = true;
addT.start();
}
/**
* 添加点歌任务
*
* @param obj 歌曲
*/
public static void addTask(MusicObj obj) {
tasks.add(obj);
}
private static void task() {
while (isRun) {
try {
MusicObj obj = tasks.poll();
if (obj != null) {
if (obj.isUrl) {
addUrl(obj.url);
} else {
addMusic(obj.sender, obj.id, obj.name, obj.isDefault);
}
}
Thread.sleep(10);
} catch (Exception e) {
AllMusic.log.warning("歌曲处理出现问题");
e.printStackTrace();
}
}
}
/**
* 添加歌曲
*
* @param sender 发送者
* @param id 歌曲ID
* @param player 用户名
* @param isList 是否是空闲歌单
*/
public static void addMusic(Object sender, String id, String player, boolean isList) {
if (isHave(id))
return;
if (sender != null) {
String text = AllMusic.getMessage().MusicPlay.CheckMusic;
text = text.replace("%MusicID%", id);
AllMusic.side.sendMessaget(sender, text);
}
Logs.logWrite("玩家:" + player + " 点歌:" + id);
try {
SongInfoObj info = AllMusic.getMusicApi().getMusic(id, player, isList);
if (info == null) {
if (sender != null) {
String data = AllMusic.getMessage().MusicPlay.NoCanPlay;
AllMusic.side.sendMessaget(sender, data.replace("%MusicID%", id));
}
return;
}
if (info.getLength() / 1000 > AllMusic.getConfig().MaxMusicTime) {
AllMusic.side.sendMessaget(sender, AllMusic.getMessage().AddMusic.TimeOut);
return;
}
playList.add(info);
if (!AllMusic.getConfig().MuteAddMessage) {
String data = AllMusic.getMessage().MusicPlay.AddMusic;
data = data.replace("%MusicName%", info.getName())
.replace("%MusicAuthor%", info.getAuthor())
.replace("%MusicAl%", info.getAl())
.replace("%MusicAlia%", info.getAlia());
if (AllMusic.getConfig().ShowInBar) {
AllMusic.side.sendBar(data);
} else {
AllMusic.side.bqt(data);
}
}
if (AllMusic.getConfig().PlayListSwitch
&& (PlayMusic.nowPlayMusic != null && PlayMusic.nowPlayMusic.isList())) {
PlayMusic.musicLessTime = 1;
if (!isList)
AllMusic.side.bqt(AllMusic.getMessage().MusicPlay.Switch);
}
error = 0;
} catch (Exception e) {
if (isList) {
error++;
}
AllMusic.log.warning("§d[AllMusic]§c歌曲信息解析错误");
e.printStackTrace();
}
}
/**
* 获取播放列表长度
*
* @return 长度
*/
public static int getSize() {
return playList.size();
}
/**
* 获取当前播放列表
*
* @return 播放列表
*/
public static List<SongInfoObj> getList() {
return new ArrayList<>(playList);
}
/**
* 清理播放列表
*/
public static void clear() {
playList.clear();
}
/**
* 从播放列表删除
*
* @param index 标号
* @return 结果
*/
public static SongInfoObj remove(int index) {
return playList.remove(index);
}
/**
* 获取播放列表所有信息
*
* @return 信息
*/
public static String getAllList() {
StringBuilder list = new StringBuilder();
String a;
SongInfoObj info;
for (int i = 0; i < playList.size(); i++) {
info = playList.get(i);
a = AllMusic.getMessage().MusicPlay.ListMusic.Item;
a = a.replace("%index%", "" + (i + 1))
.replace("%MusicName%", info.getName())
.replace("%MusicAuthor%", info.getAuthor())
.replace("%MusicAl%", info.getAl())
.replace("%MusicAlia%", info.getAlia());
list.append(a).append("\n");
}
String temp = list.toString();
if (temp.isEmpty())
return "";
return temp.substring(0, temp.length() - 1);
}
/**
* 是否在播放列表中
*
* @param id 音乐ID
* @return 结果
*/
public static boolean isHave(String id) {
if (nowPlayMusic != null && nowPlayMusic.getID().equalsIgnoreCase(id))
return true;
for (SongInfoObj item : playList) {
if (item.getID().equalsIgnoreCase(id))
return true;
}
return false;
}
/**
* 添加Url歌曲
*
* @param url 链接
*/
private static void addUrl(String url) {
try {
URL urlfile = new URL(url);
URLConnection con = urlfile.openConnection();
int b = con.getContentLength();// 得到音乐文件的总长度
BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
Bitstream bt = new Bitstream(bis);
Header h = bt.readFrame();
int le = 6000000;
if (h == null) {
AllMusic.side.bqt("§d[AllMusic]§c未知音乐类型");
} else {
le = (int) h.total_ms(b);
}
SongInfoObj info = new SongInfoObj(AllMusic.getMessage().Custom.Info, url, le);
playList.add(info);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌曲信息解析错误");
e.printStackTrace();
}
}
}
@@ -0,0 +1,28 @@
package coloryr.allmusic.core.music.play;
public class TopLyricSave extends LyricSave {
public void setTlyric(String data) {
tly = data;
}
public void setLyric(String data) {
lly = data;
}
public void setKly(String data) {
kly = data;
}
public void setHaveK(boolean data) {
if (!data) {
kly = null;
}
}
public void setHaveT(boolean data) {
if (!data) {
tly = null;
}
}
}
@@ -0,0 +1,248 @@
package coloryr.allmusic.core.objs;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.config.EconomyObj;
import coloryr.allmusic.core.objs.config.FunConfigObj;
import coloryr.allmusic.core.objs.hud.SaveObj;
import java.util.ArrayList;
import java.util.List;
/**
* 配置文件对象
*/
public class ConfigObj {
/**
* 最大歌曲数
*/
public int MaxList;
/**
* 最小通过投票数
*/
public int MinVote;
/**
* 歌曲延迟
*/
public int Delay;
/**
* 搜歌花费
*/
public int SearchCost;
/**
* 点歌花费
*/
public int AddMusicCost;
/**
* 默认添加歌曲方式
*/
public int DefaultAddMusic;
/**
* 消息限制长度
*/
public int MessageLimitSize;
/**
* 最长音乐长度
*/
public int MaxMusicTime;
/**
* KTV模式歌词加时
*/
public int KDelay;
/**
* 管理员ID列表
*/
public List<String> Admin;
/**
* 不参与点歌的服务器列表
*/
public List<String> NoMusicServer;
/**
* 不参与点歌的玩家列表
*/
public List<String> NoMusicPlayer;
/**
* 禁止点歌ID列表
*/
public List<String> BanMusic;
/**
* 空闲歌单列表
*/
public List<String> PlayList;
/**
* 玩家点歌后是否直接从空闲歌单切换至玩家歌曲
*/
public boolean PlayListSwitch;
/**
* 空闲歌单随机播放
*/
public boolean PlayListRandom;
/**
* 显示歌词
*/
public boolean SendLyric;
/**
* 指令需要权限
*/
public boolean NeedPermission;
/**
* 开启花钱点歌
*/
public boolean UseCost;
/**
* 顶层模式,用于和BC交换数据
*/
public boolean TopPAPI;
/**
* 开启信息长度限制
*/
public boolean MessageLimit;
/**
* 不发送播放信息
*/
public boolean MutePlayMessage;
/**
* 不发送点歌信息
*/
public boolean MuteAddMessage;
/**
* 将信息限制在bar处
*/
public boolean ShowInBar;
/**
* K歌歌词
*/
public boolean KtvMode;
/**
* 登录的用户
*/
public String LoginUser;
/**
* 歌曲音质
*/
public String MusicBR;
/**
* 配置文件版本号
*/
public String Version;
/**
* 默认的Hud配置
*/
public SaveObj DefaultHud;
/**
* 经济插件挂钩
*/
public EconomyObj Economy;
/**
* 娱乐选项
*/
public FunConfigObj FunConfig;
public static ConfigObj makeDefault(){
return new ConfigObj(){{
MaxList = 10;
MinVote = 3;
Delay = 0;
Admin = new ArrayList<String>() {{
this.add("CONSOLE");
}};
NoMusicServer = new ArrayList<>();
NoMusicPlayer = new ArrayList<>();
BanMusic = new ArrayList<>();
PlayList = new ArrayList<>();
PlayListSwitch = true;
PlayListRandom = true;
SendLyric = true;
NeedPermission = false;
DefaultHud = new SaveObj();
UseCost = false;
SearchCost = 20;
MutePlayMessage = false;
MuteAddMessage = false;
ShowInBar = false;
AddMusicCost = 10;
DefaultAddMusic = 0;
LoginUser = "";
MusicBR = "320000";
MaxMusicTime = 600;
TopPAPI = false;
MessageLimit = false;
MessageLimitSize = 40;
Economy = new EconomyObj();
FunConfig = new FunConfigObj();
KtvMode = true;
KDelay = 0;
Version = AllMusic.version;
}};
}
public void addBanID(String ID) {
if (!BanMusic.contains(ID))
BanMusic.add(ID);
AllMusic.save();
}
public void AddNoMusicPlayer(String ID) {
if (!NoMusicPlayer.contains(ID))
NoMusicPlayer.add(ID);
AllMusic.save();
}
public void RemoveNoMusicPlayer(String ID) {
NoMusicPlayer.remove(ID);
AllMusic.save();
}
public boolean check() {
boolean saveConfig = false;
if (PlayList == null) {
saveConfig = true;
PlayList = new ArrayList<>();
}
if (Admin == null) {
saveConfig = true;
Admin = new ArrayList<>();
}
if (BanMusic == null) {
saveConfig = true;
BanMusic = new ArrayList<>();
}
if (DefaultHud == null) {
saveConfig = true;
DefaultHud = new SaveObj();
}
if (NoMusicPlayer == null) {
saveConfig = true;
NoMusicPlayer = new ArrayList<>();
}
if (NoMusicServer == null) {
saveConfig = true;
NoMusicServer = new ArrayList<>();
}
if (Economy == null) {
saveConfig = true;
Economy = new EconomyObj();
} else if (Economy.check()) {
saveConfig = true;
Economy = new EconomyObj();
}
if (FunConfig == null) {
saveConfig = true;
FunConfig = new FunConfigObj();
}
return saveConfig;
}
}
@@ -0,0 +1,10 @@
package coloryr.allmusic.core.objs;
import okhttp3.Cookie;
import java.util.HashMap;
import java.util.List;
public class CookieObj {
public HashMap<String, List<Cookie>> cookieStore = new HashMap<>();
}
@@ -0,0 +1,11 @@
package coloryr.allmusic.core.objs;
public class HttpResObj {
public final String data;
public final boolean ok;
public HttpResObj(String data, boolean ok) {
this.data = data;
this.ok = ok;
}
}
@@ -0,0 +1,108 @@
package coloryr.allmusic.core.objs;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.message.SearchObj;
import coloryr.allmusic.core.objs.message.*;
public class MessageObj {
public MusicPlayObj MusicPlay;
public AddMusicObj AddMusic;
public PageObj Page;
public LyricObj Lyric;
public VoteObj Vote;
public SearchObj Search;
public HudObj Hud;
public HudListObj HudList;
public CommandObj Command;
public CustomObj Custom;
public PAPIObj PAPI;
public CostObj Cost;
public ClickObj Click;
public HelpObj Help;
public FunObj Fun;
public String Version;
public MessageObj() {
MusicPlay = new MusicPlayObj();
AddMusic = new AddMusicObj();
Page = new PageObj();
Lyric = new LyricObj();
Vote = new VoteObj();
Search = new SearchObj();
Hud = new HudObj();
Command = new CommandObj();
HudList = new HudListObj();
Custom = new CustomObj();
PAPI = new PAPIObj();
Cost = new CostObj();
Click = new ClickObj();
Help = new HelpObj();
Fun = new FunObj();
Version = AllMusic.configVersion;
}
public boolean check() {
boolean saveConfig = false;
if (MusicPlay == null || MusicPlay.check()) {
saveConfig = true;
MusicPlay = new MusicPlayObj();
}
if (AddMusic == null || AddMusic.check()) {
saveConfig = true;
AddMusic = new AddMusicObj();
}
if (Page == null || Page.check()) {
saveConfig = true;
Page = new PageObj();
}
if (Lyric == null || Lyric.check()) {
saveConfig = true;
Lyric = new LyricObj();
}
if (Vote == null || Vote.check()) {
saveConfig = true;
Vote = new VoteObj();
}
if (Search == null || Search.check()) {
saveConfig = true;
Search = new SearchObj();
}
if (Hud == null || Hud.check()) {
saveConfig = true;
Hud = new HudObj();
}
if (HudList == null || HudList.check()) {
saveConfig = true;
HudList = new HudListObj();
}
if (Command == null || Command.check()) {
saveConfig = true;
Command = new CommandObj();
}
if (Custom == null || Custom.check()) {
saveConfig = true;
Custom = new CustomObj();
}
if (PAPI == null || PAPI.check()) {
saveConfig = true;
PAPI = new PAPIObj();
}
if (Cost == null || Cost.check()) {
saveConfig = true;
Cost = new CostObj();
}
if (Click == null || Click.check()) {
saveConfig = true;
Click = new ClickObj();
}
if (Help == null || Help.check()) {
saveConfig = true;
Help = new HelpObj();
}
if (Fun == null || Fun.check()) {
saveConfig = true;
Fun = new FunObj();
}
return saveConfig;
}
}
@@ -0,0 +1,15 @@
package coloryr.allmusic.core.objs;
public class SearchMusicObj {
public final String id;
public final String name;
public final String author;
public final String al;
public SearchMusicObj(String ID, String Name, String Author, String Al) {
this.id = ID;
this.name = Name;
this.author = Author;
this.al = Al;
}
}
@@ -0,0 +1,11 @@
package coloryr.allmusic.core.objs.api;
public class EncResObj {
public String params;
public String encSecKey;
public EncResObj(String params, String encSecKey) {
this.encSecKey = encSecKey;
this.params = params;
}
}
@@ -0,0 +1,127 @@
package coloryr.allmusic.core.objs.api.music.info;
import java.util.List;
public class InfoObj {
private List<Songs> songs;
public boolean isOk() {
return (songs != null && songs.size() != 0);
}
public String getName() {
if (songs == null || songs.size() == 0)
return "";
return songs.get(0).getName();
}
public String getAuthor() {
StringBuilder Author = new StringBuilder();
if (songs.size() == 0)
return "";
for (ar ar : songs.get(0).getAr()) {
Author.append(ar.getName()).append(",");
}
if (Author.length() != 0) {
Author = new StringBuilder(Author.substring(0, Author.length() - 1));
}
return Author.toString();
}
public String getAlia() {
StringBuilder Alia = new StringBuilder();
for (String alia : songs.get(0).getAlia()) {
Alia.append(alia).append(",");
}
if (Alia.length() != 0) {
Alia = new StringBuilder(Alia.substring(0, Alia.length() - 1));
}
return Alia.toString();
}
public String getAl() {
return songs.get(0).getAl();
}
public int getLength() {
if (songs == null)
return 0;
return songs.get(0).getLength();
}
public String getPicUrl() {
if (songs == null)
return null;
return songs.get(0).getPicUrl();
}
}
class Songs {
private String name;
private List<ar> ar;
private List<String> alia;
private al al;
private h l;
private h m;
private h h;
public int getLength() {
if (l != null)
return l.getLength();
if (m != null)
return m.getLength();
if (h != null)
return h.getLength();
return 0;
}
public String getName() {
return name == null ? "" : name;
}
public List<ar> getAr() {
return ar;
}
public List<String> getAlia() {
return alia;
}
public String getAl() {
return al.getName() == null ? "" : al.getName();
}
public String getPicUrl() {
return al.getPicUrl();
}
}
class ar {
private String name;
public String getName() {
return name == null ? "" : name;
}
}
class al {
private String name;
private String picUrl;
public String getName() {
return name == null ? "" : name;
}
public String getPicUrl() {
return picUrl == null ? "" : picUrl;
}
}
class h {
private int br;
private int size;
public int getLength() {
return size / br * 8000;
}
}
@@ -0,0 +1,30 @@
package coloryr.allmusic.core.objs.api.music.info;
import java.util.List;
public class PlayObj {
private List<obj> data;
private int code;
public String getData() {
if (data == null)
return null;
if (data.size() == 0)
return null;
obj obj = data.get(0);
return obj.getUrl();
}
public int getCode() {
return code;
}
}
class obj {
private String url;
public String getUrl() {
return url;
}
}
@@ -0,0 +1,41 @@
package coloryr.allmusic.core.objs.api.music.list;
import java.util.ArrayList;
import java.util.List;
public class DataObj {
private playlist playlist;
public List<String> getPlaylist() {
List<String> list = new ArrayList<>();
for (track item : playlist.getTracks()) {
list.add(item.getId());
}
return list;
}
public String getName() {
return playlist.getName();
}
}
class track {
private int id;
public String getId() {
return String.valueOf(id);
}
}
class playlist {
private List<track> trackIds;
private String name;
public List<track> getTracks() {
return trackIds;
}
public String getName() {
return name;
}
}
@@ -0,0 +1,86 @@
package coloryr.allmusic.core.objs.api.music.lyric;
public class WLyricObj {
private lrc lrc;
private tlyric tlyric;
private klyric klyric;
private yrc yrc;
private boolean nolyric;
private boolean uncollected;
public boolean isOk() {
return lrc != null || isNone();
}
public String getLyric() {
return lrc.getLyric();
}
public String getTlyric() {
if (tlyric == null)
return null;
return tlyric.getLyric();
}
public String getKlyric() {
if (klyric == null)
return null;
return klyric.getLyric();
}
public String getYrc() {
if (yrc == null)
return null;
return yrc.getLyric();
}
public boolean getVersion() {
return yrc != null;
}
public boolean isNone() {
return nolyric || uncollected;
}
}
class lrc {
private String lyric;
public String getLyric() {
return lyric == null ? "" : lyric;
}
}
class tlyric {
private String lyric;
public String getLyric() {
return lyric;
}
}
class klyric {
private String lyric;
private int version;
public int getVersion() {
return version;
}
public String getLyric() {
return lyric == null ? "" : lyric;
}
}
class yrc {
private int version;
private String lyric;
public int getVersion() {
return version;
}
public String getLyric() {
return lyric == null ? "" : lyric;
}
}
@@ -0,0 +1,40 @@
package coloryr.allmusic.core.objs.api.music.search;
import java.util.List;
public class SearchDataObj {
private result result;
public boolean isOk() {
return result != null && result.getSongs() != null;
}
public List<songs> getResult() {
return result.getSongs();
}
}
class result {
private List<songs> songs;
public List<songs> getSongs() {
return songs;
}
}
class artists {
private String name;
public String getName() {
return name;
}
}
class album {
private String name;
public String getName() {
return name;
}
}
@@ -0,0 +1,30 @@
package coloryr.allmusic.core.objs.api.music.search;
import java.util.List;
public class songs {
private int id;
private String name;
private List<artists> artists;
private album album;
public int getId() {
return id;
}
public String getName() {
return name;
}
public String getAlbum() {
return album.getName();
}
public String getArtists() {
StringBuilder a = new StringBuilder();
for (artists temp : artists) {
a.append(temp.getName()).append(",");
}
return a.substring(0, a.length() - 1);
}
}
@@ -0,0 +1,46 @@
package coloryr.allmusic.core.objs.api.music.trialinfo;
import java.util.List;
public class TrialInfoObj {
private List<song> data;
public boolean isTrial() {
if (data.size() == 0)
return false;
song song = data.get(0);
return song.getCode() != 200;
}
public freeTrialInfo getFreeTrialInfo() {
song song = data.get(0);
return song.getFreeTrialInfo() == null ? new freeTrialInfo() {{
this.setEnd(30);
}} : song.getFreeTrialInfo();
}
public String getUrl() {
if (data.size() == 0)
return null;
song song = data.get(0);
return song.getUrl();
}
}
class song {
private freeTrialInfo freeTrialInfo;
private int code;
private String url;
public String getUrl() {
return url;
}
public int getCode() {
return code;
}
public freeTrialInfo getFreeTrialInfo() {
return freeTrialInfo;
}
}
@@ -0,0 +1,18 @@
package coloryr.allmusic.core.objs.api.music.trialinfo;
public class freeTrialInfo {
private int start;
private int end;
public int getEnd() {
return end;
}
public void setEnd(int end) {
this.end = end;
}
public int getStart() {
return start;
}
}
@@ -0,0 +1,99 @@
package coloryr.allmusic.core.objs.api.program.info;
public class PrInfoObj {
private program program;
public boolean isOk() {
return (program != null && program.getMainSong().getName() != null);
}
public String getId() {
return String.valueOf(program.getMainSong().getId());
}
public String getName() {
return program.getMainSong().getName();
}
public String getAlia() {
if (program.getDj() == null)
return null;
return program.getDj().getBrand();
}
public int getLength() {
return program.getMainSong().getLength();
}
public String getAuthor() {
return program.getDj().getNickname();
}
}
class mainSong {
private String name;
private int id;
private hMusic hMusic;
private hMusic mMusic;
private hMusic lMusic;
private hMusic bMusic;
public int getLength() {
if (hMusic != null)
return hMusic.getLength();
else if (mMusic != null)
return mMusic.getLength();
else if (lMusic != null)
return lMusic.getLength();
else if (bMusic != null)
return bMusic.getLength();
return 0;
}
public int getId() {
return id;
}
public String getName() {
return name;
}
}
class program {
private dj dj;
private mainSong mainSong;
public dj getDj() {
return dj;
}
public mainSong getMainSong() {
return mainSong;
}
}
class dj {
private String brand;
private String nickname;
public String getNickname() {
return nickname;
}
public String getBrand() {
return brand;
}
}
class hMusic {
private int size;
private int bitrate;
public int getLength() {
return size / bitrate * 8000;
}
}
@@ -0,0 +1,18 @@
package coloryr.allmusic.core.objs.config;
public class EconomyObj {
public String MysqlUrl;
public boolean Vault;
public EconomyObj() {
MysqlUrl = "jdbc:mysql://localhost:3306/minecraft?autoReconnect=true&autoReconnectForPools=true";
Vault = true;
}
public boolean check() {
boolean res = MysqlUrl == null;
return res;
}
}
@@ -0,0 +1,11 @@
package coloryr.allmusic.core.objs.config;
public class FunConfigObj {
public boolean Rain;
public int RainRate;
public FunConfigObj(){
Rain = true;
RainRate = 10;
}
}
@@ -0,0 +1,19 @@
package coloryr.allmusic.core.objs.hud;
public class PosObj {
public int x;
public int y;
public PosObj() {
}
public PosObj(int x, int y) {
this.x = x;
this.y = y;
}
public PosObj copy() {
return new PosObj(this.x, this.y);
}
}
@@ -0,0 +1,45 @@
package coloryr.allmusic.core.objs.hud;
public class SaveObj {
public PosObj List;
public PosObj Lyric;
public PosObj Info;
public PosObj Pic;
public int PicSize;
public int PicRotateSpeed;
public boolean EnablePicRotate;
public boolean EnableList;
public boolean EnableLyric;
public boolean EnableInfo;
public boolean EnablePic;
public SaveObj() {
EnableList = true;
EnableLyric = true;
EnableInfo = true;
EnablePic = true;
EnablePicRotate = true;
PicRotateSpeed = 10;
List = new PosObj();
Lyric = new PosObj();
Info = new PosObj();
Pic = new PosObj();
PicSize = 70;
}
public SaveObj copy() {
SaveObj obj1 = new SaveObj();
obj1.EnableInfo = this.EnableInfo;
obj1.EnableList = this.EnableList;
obj1.EnableLyric = this.EnableLyric;
obj1.EnablePic = this.EnablePic;
obj1.Info = this.Info.copy();
obj1.List = this.List.copy();
obj1.Lyric = this.Lyric.copy();
obj1.Pic = this.Pic.copy();
obj1.PicSize = this.PicSize;
obj1.EnablePicRotate = this.EnablePicRotate;
obj1.PicRotateSpeed = this.PicRotateSpeed;
return obj1;
}
}
@@ -0,0 +1,41 @@
package coloryr.allmusic.core.objs.message;
public class AddMusicObj {
public String ListFull;
public String BanMusic;
public String ExistMusic;
public String Success;
public String NoPlayer;
public String NoID;
public String Cancel;
public String TimeOut;
public AddMusicObj() {
ListFull = "§d[AllMusic]§c错误,队列已满";
BanMusic = "§d[AllMusic]§c错误,这首歌被禁点了";
ExistMusic = "§d[AllMusic]§c错误,这首歌已经存在了";
Success = "§d[AllMusic]§2点歌成功";
NoPlayer = "§d[AllMusic]§c没有播放的玩家";
NoID = "§d[AllMusic]§c错误,请输入歌曲数字ID";
Cancel = "§d[AllMusic]§e点歌被取消";
TimeOut = "§d[AllMusic]§e点歌被取消,音乐长度过长";
}
public boolean check() {
if (ListFull == null)
return true;
if (BanMusic == null)
return true;
if (ExistMusic == null)
return true;
if (Success == null)
return true;
if (NoPlayer == null)
return true;
if (NoID == null)
return true;
if (Cancel == null)
return true;
return TimeOut == null;
}
}
@@ -0,0 +1,17 @@
package coloryr.allmusic.core.objs.message;
public class ClickObj {
public String This;
public String Check;
public ClickObj() {
This = "§b[§n点我选择§r§b]";
Check = "§b[§n点我查看§r§b]";
}
public boolean check() {
if (This == null)
return true;
return Check == null;
}
}
@@ -0,0 +1,17 @@
package coloryr.allmusic.core.objs.message;
public class CommandObj {
public String Error;
public String NoPer;
public CommandObj() {
Error = "§d[AllMusic]§c参数错误,请输入/music help获取帮助";
NoPer = "§d[AllMusic]§c你没有权限点歌";
}
public boolean check() {
if (Error == null)
return true;
return NoPer == null;
}
}
@@ -0,0 +1,25 @@
package coloryr.allmusic.core.objs.message;
public class CostObj {
public String Search;
public String AddMusic;
public String NoMoney;
public String CostFail;
public CostObj() {
Search = "§d[ALLMusic]§2你搜歌花费了%Cost%";
AddMusic = "§d[ALLMusic]§2你点歌花费了%Cost%";
NoMoney = "§d[ALLMusic]§c你没有足够的钱";
CostFail = "§d[ALLMusic]§c扣钱过程中错误";
}
public boolean check() {
if (Search == null)
return true;
if (AddMusic == null)
return true;
if (NoMoney == null)
return true;
return CostFail == null;
}
}
@@ -0,0 +1,13 @@
package coloryr.allmusic.core.objs.message;
public class CustomObj {
public String Info;
public CustomObj() {
Info = "自定义音乐";
}
public boolean check() {
return Info == null;
}
}
@@ -0,0 +1,20 @@
package coloryr.allmusic.core.objs.message;
public class FunObj {
public String Rain;
public FunObj()
{
Rain = "§d[AllMusic]§e天空开始变得湿润";
}
public boolean check(){
boolean res =false;
if(Rain == null)
{
res = true;
}
return res;
}
}
@@ -0,0 +1,41 @@
package coloryr.allmusic.core.objs.message;
public class HelpAdminObj {
public String Reload;
public String Next;
public String Ban;
public String Url;
public String Delete;
public String AddList;
public String ClearList;
public String Login;
public HelpAdminObj() {
Reload = "§d[AllMusic]§2使用/music reload 重读配置文件";
Next = "§d[AllMusic]§2使用/music next 强制切歌";
Ban = "§d[AllMusic]§2使用/music ban [ID] 禁止点这首歌";
Url = "§d[AllMusic]§2使用/music url [url] 播放一首自定义歌曲";
Delete = "§d[AllMusic]§2使用/music delete [序号] 删除队列中的歌曲";
AddList = "§d[AllMusic]§2使用/music addlist [歌单ID] 添加歌单到空闲列表";
ClearList = "§d[AllMusic]§2使用/music clearlist 清空空闲歌单";
Login = "§d[AllMusic]§2使用/music login 重新登录账户";
}
public boolean check() {
if (Reload == null)
return true;
if (Next == null)
return true;
if (Ban == null)
return true;
if (Url == null)
return true;
if (Delete == null)
return true;
if (AddList == null)
return true;
if (ClearList == null)
return true;
return Login == null;
}
}
@@ -0,0 +1,61 @@
package coloryr.allmusic.core.objs.message;
public class HelpNormalObj {
public String Head;
public String Base;
public String Stop;
public String List;
public String Vote;
public String NoMusic;
public String Search;
public String Select;
public String Hud1;
public String Hud2;
public String Hud3;
public String Hud4;
public String Hud5;
public HelpNormalObj() {
Head = "§d[AllMusic]§2帮助手册";
Base = "§d[AllMusic]§2使用/music [音乐ID] 来点歌";
Stop = "§d[AllMusic]§2使用/music stop 停止播放歌曲";
List = "§d[AllMusic]§2使用/music list 查看歌曲队列";
Vote = "§d[AllMusic]§2使用/music vote 投票切歌";
NoMusic = "§d[AllMusic]§2使用/music nomusic 不再参与点歌";
Search = "§d[AllMusic]§2使用/music search [歌名] 搜索歌曲";
Select = "§d[AllMusic]§2使用/music select [序列] 选择歌曲";
Hud1 = "§d[AllMusic]§2使用/music hud enable [位置] 启用关闭Hud";
Hud2 = "§d[AllMusic]§2使用/music hud [位置] [x] [y] 设置某个Hud的位置";
Hud3 = "§d[AllMusic]§2使用/music hud picsize [尺寸] 设置图片尺寸";
Hud4 = "§d[AllMusic]§e使用/music hud picrotate [开关] 设置图片旋转模式";
Hud5 = "§d[AllMusic]§e使用/music hud picrotatespeed [数值] 设置图片旋转速度";
}
public boolean check() {
if (Head == null)
return true;
if (Base == null)
return true;
if (Stop == null)
return true;
if (List == null)
return true;
if (Vote == null)
return true;
if (NoMusic == null)
return true;
if (Search == null)
return true;
if (Select == null)
return true;
if (Hud1 == null)
return true;
if (Hud2 == null)
return true;
if (Hud3 == null)
return true;
if (Hud4 == null)
return true;
return Hud5 == null;
}
}
@@ -0,0 +1,24 @@
package coloryr.allmusic.core.objs.message;
public class HelpObj {
public HelpNormalObj Normal;
public HelpAdminObj Admin;
public HelpObj() {
Normal = new HelpNormalObj();
Admin = new HelpAdminObj();
}
public boolean check() {
boolean save = false;
if (Normal == null) {
save = true;
Normal = new HelpNormalObj();
}
if (Admin == null) {
save = true;
Admin = new HelpAdminObj();
}
return save;
}
}
@@ -0,0 +1,50 @@
package coloryr.allmusic.core.objs.message;
public class HudListObj {
public String List;
public String Lyric;
public String Info;
public String All;
public String Pic;
public String PicRoute;
public String PicRouteSpeed;
public HudListObj() {
List = "待播放列表";
Lyric = "歌词";
Info = "歌曲信息";
Pic = "图片";
All = "所有位置";
PicRoute = "图片旋转";
PicRouteSpeed = "图片旋转速度";
}
public boolean check() {
if (List == null)
return true;
if (Lyric == null)
return true;
if (Info == null)
return true;
if (All == null)
return true;
if (PicRoute == null)
return true;
if (PicRouteSpeed == null)
return true;
return Pic == null;
}
public String Get(String data) {
if (data.equalsIgnoreCase("List")) {
return List;
} else if (data.equalsIgnoreCase("Lyric")) {
return Lyric;
} else if (data.equalsIgnoreCase("Info")) {
return Info;
} else if (data.equalsIgnoreCase("Pic")) {
return Pic;
}
return null;
}
}
@@ -0,0 +1,61 @@
package coloryr.allmusic.core.objs.message;
public class HudObj {
public String State;
public String Set;
public String Reset;
public String NoMusic;
public String NoList;
public String NoLyric;
public String PicSize;
public String PicRotate;
public String PicRotateSpeed;
public String Music;
public String Lyric;
public String List;
public String Ktv;
public HudObj() {
State = "§d[AllMusic]§2设置信息位置:%Hud%,状态:%State%";
Set = "§d[AllMusic]§2已设置%Hud%的坐标为%x%, %y%";
Reset = "§d[AllMusic]§2Hud恢复至默认位置";
NoMusic = "没有播放的音乐";
NoList = "队列中无歌曲";
NoLyric = "无歌词";
PicSize = "§d[AllMusic]§2设置图片尺寸为%Size%";
PicRotate = "§d[AllMusic]§2设置图片旋转为%State%";
PicRotateSpeed = "§d[AllMusic]§2设置图片旋转速度为%Size%";
Music = "%Name% %AllTime%/%NowTime%\n%Author%\n%Alia%\n%Al%\nby: %Player%";
Lyric = "%Lyric%\n%Tlyric%";
Ktv = "§e%KLyric%§f%Lyric%§r\n%Tlyric%";
List = "播放列表里面有%Size%首歌\n%List%";
}
public boolean check() {
if (State == null)
return true;
if (Set == null)
return true;
if (Reset == null)
return true;
if (NoMusic == null)
return true;
if (NoList == null)
return true;
if (NoLyric == null)
return true;
if (PicSize == null)
return true;
if (Music == null)
return true;
if (Lyric == null)
return true;
if (List == null)
return true;
if (PicRotate == null)
return true;
if (PicRotateSpeed == null)
return true;
return Ktv == null;
}
}
@@ -0,0 +1,23 @@
package coloryr.allmusic.core.objs.message;
public class ListMusicObj {
public String Head;
public String Item;
public String Get;
public ListMusicObj() {
Head = "§d[AllMusic]§2队列中有歌曲数:&Count&";
Item = "§2%index%->%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia%";
Get = "§d[AllMusic]§2歌曲列表%ListName%获取成功";
}
public boolean check() {
boolean res = Head == null;
if (Item == null)
res = true;
if (Get == null)
res = true;
return res;
}
}
@@ -0,0 +1,17 @@
package coloryr.allmusic.core.objs.message;
public class LyricObj {
public String Data;
public String TData;
public LyricObj() {
Data = "%Lyric%";
TData = "%Lyric%(%TLyric%)";
}
public boolean check() {
if (Data == null)
return true;
return TData == null;
}
}
@@ -0,0 +1,63 @@
package coloryr.allmusic.core.objs.message;
public class MusicPlayObj {
public String StopPlay;
public String NoMusic;
public String Play;
public String NoPlay;
public ListMusicObj ListMusic;
public String NoCanPlay;
public String NoPlayMusic;
public String Switch;
public String AddMusic;
public String CheckMusic;
public String MusicInfo;
public String Trail;
public String Cancel;
public MusicPlayObj() {
StopPlay = "§d[AllMusic]§2已停止你的音乐播放";
NoMusic = "§d[AllMusic]§2无正在播放的歌曲";
Play = "§d[AllMusic]§2正在播放:%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia% | by: %PlayerName%";
NoPlay = "§d[AllMusic]§2队列中无歌曲";
ListMusic = new ListMusicObj();
NoCanPlay = "§d[AllMusic]§c无法播放歌曲%MusicID%可能该歌曲为VIP歌曲";
NoPlayMusic = "§d[AllMusic]§2你不会再收到点歌了!想要再次参与点歌就点一首歌吧!";
Switch = "§d[AllMusic]§2切换到玩家歌曲";
AddMusic = "§d[AllMusic]§2音乐列表添加%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia%";
CheckMusic = "§d[AllMusic]§2正在解析歌曲%MusicID%";
MusicInfo = "%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia% | by: %PlayerName%";
Trail = "§d[AllMusic]§2该音乐为试听音乐";
Cancel = "§d[AllMusic]§e播放被取消";
}
public boolean check() {
boolean res = StopPlay == null;
if (NoMusic == null)
res = true;
if (Play == null)
res = true;
if (NoPlay == null)
res = true;
if (ListMusic == null || ListMusic.check())
res = true;
if (NoCanPlay == null)
res = true;
if (NoPlayMusic == null)
res = true;
if (Switch == null)
res = true;
if (AddMusic == null)
res = true;
if (CheckMusic == null)
res = true;
if (MusicInfo == null)
res = true;
if (Trail == null)
res = true;
if (Cancel == null)
res = true;
return res;
}
}
@@ -0,0 +1,13 @@
package coloryr.allmusic.core.objs.message;
public class PAPIObj {
public String NoMusic;
public PAPIObj() {
NoMusic = "没有播放的音乐";
}
public boolean check() {
return NoMusic == null;
}
}
@@ -0,0 +1,23 @@
package coloryr.allmusic.core.objs.message;
public class PageObj {
public String Choice;
public String Next;
public String Last;
public PageObj() {
Choice = "§e[§n点我选择§r§e]§2%index%->%MusicName% | %MusicAuthor% | %MusicAl%";
Next = "§d[AllMusic]§e[§n点我下一页§r§e]";
Last = "§d[AllMusic]§e[§n点我上一页§r§e]";
}
public boolean check() {
boolean res = Choice == null;
if (Next == null)
res = true;
if (Last == null)
res = true;
return res;
}
}
@@ -0,0 +1,45 @@
package coloryr.allmusic.core.objs.message;
public class SearchObj {
public String NoPer;
public String CantSearch;
public String Res;
public String NoSearch;
public String ErrorNum;
public String Chose;
public String CantNext;
public String CantLast;
public String StartSearch;
public SearchObj() {
StartSearch = "§d[AllMusic]§2正在排队搜歌";
NoPer = "§d[AllMusic]§c你没有权限搜歌";
CantSearch = "§d[AllMusic]§c无法搜索歌曲:%Music%";
Res = "§d[AllMusic]§2搜索结果";
NoSearch = "§d[AllMusic]§c你没有搜索音乐";
ErrorNum = "§d[AllMusic]§c请输入正确的序号";
Chose = "§d[AllMusic]§2你选择了序号%Num%";
CantNext = "§d[AllMusic]§c无法下一页";
CantLast = "§d[AllMusic]§c无法上一页";
}
public boolean check() {
if (NoPer == null)
return true;
if (CantSearch == null)
return true;
if (Res == null)
return true;
if (NoSearch == null)
return true;
if (ErrorNum == null)
return true;
if (Chose == null)
return true;
if (CantNext == null)
return true;
if (CantLast == null)
return true;
return StartSearch == null;
}
}
@@ -0,0 +1,41 @@
package coloryr.allmusic.core.objs.message;
public class VoteObj {
public String NoPermission;
public String DoVote;
public String BQ;
public String Agree;
public String BQAgree;
public String ARAgree;
public String TimeOut;
public String Do;
public VoteObj() {
NoPermission = "§d[AllMusic]§c你没有权限切歌";
DoVote = "§d[AllMusic]§2已发起切歌投票";
BQ = "§d[AllMusic]§2%PlayerName%发起了切歌投票,30秒后结束,输入/music vote 同意切歌。";
Agree = "§d[AllMusic]§2你同意切歌";
BQAgree = "§d[AllMusic]§2%PlayerName%同意切歌,共有%Count%名玩家同意切歌。";
ARAgree = "§d[AllMusic]§2你已申请切歌";
TimeOut = "§d[AllMusic]§2切歌时间结束";
Do = "§d[AllMusic]§2已切歌";
}
public boolean check() {
if (NoPermission == null)
return true;
if (DoVote == null)
return true;
if (BQ == null)
return true;
if (Agree == null)
return true;
if (BQAgree == null)
return true;
if (ARAgree == null)
return true;
if (TimeOut == null)
return true;
return Do == null;
}
}
@@ -0,0 +1,27 @@
package coloryr.allmusic.core.objs.music;
import coloryr.allmusic.core.AllMusic;
public class LyricItemObj {
public String lyric;
public String tlyric;
public LyricItemObj(String lyric, String tlyric) {
this.lyric = lyric;
this.tlyric = tlyric;
}
public String getString() {
if (lyric == null || lyric.isEmpty())
return "";
String data;
if (tlyric != null && !tlyric.isEmpty()) {
data = AllMusic.getMessage().Lyric.TData;
return data.replace("%Lyric%", lyric)
.replace("%TLyric%", tlyric);
}
data = AllMusic.getMessage().Lyric.Data;
return data.replace("%Lyric%", lyric);
}
}
@@ -0,0 +1,32 @@
package coloryr.allmusic.core.objs.music;
public class MusicObj {
/**
* 发送者
*/
public Object sender;
/**
* 歌曲ID
*/
public String id;
/**
* 用户名
*/
public String name;
/**
* 参数
*/
public String[] args;
/**
* 是否是默认点歌方式
*/
public boolean isDefault;
/**
* 是否是Url歌曲
*/
public boolean isUrl;
/**
* 歌曲Url
*/
public String url;
}
@@ -0,0 +1,55 @@
package coloryr.allmusic.core.objs.music;
import coloryr.allmusic.core.objs.SearchMusicObj;
import java.util.List;
public class SearchPageObj {
private final List<SearchMusicObj> resData;
private final int maxpage;
private int page = 0;
public SearchPageObj(List<SearchMusicObj> resData, int maxpage) {
this.resData = resData;
this.maxpage = maxpage;
}
public String getSong(int index) {
return resData.get(index).id;
}
public SearchMusicObj getRes(int a) {
return resData.get(a);
}
public boolean nextPage() {
if (!haveNextPage())
return false;
page++;
return true;
}
public boolean lastPage() {
if (!haveLastPage())
return false;
page--;
return true;
}
public int getIndex() {
int a = resData.size() - page * 10;
return Math.min(a, 10);
}
public boolean haveNextPage() {
return page != (maxpage - 1);
}
public boolean haveLastPage() {
return page != 0;
}
public int getPage() {
return page;
}
}
@@ -0,0 +1,151 @@
package coloryr.allmusic.core.objs.music;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.api.music.trialinfo.freeTrialInfo;
public class SongInfoObj {
/**
* 作者
*/
protected String author;
/**
* 名字
*/
protected String name;
/**
* 音乐ID
*/
protected String id;
/**
* 原曲
*/
protected String alia;
/**
* 点歌者
*/
protected String call;
/**
* 专辑
*/
protected String al;
/**
* 播放链接
*/
protected String playerUrl;
/**
* 图片链接
*/
protected String picUrl;
/**
* 是否是试听
*/
protected boolean isTrial;
/**
* 试听数据
*/
protected freeTrialInfo trialInfo;
/**
* 长度
*/
protected int length;
/**
* 是否是空闲歌单的歌
*/
protected boolean isList;
/**
* 是否是Url歌曲
*/
protected boolean isUrl;
public SongInfoObj(String Name, String Url, int Length) {
this.length = Length;
playerUrl = Url;
this.name = Name;
id = alia = call = al = author = picUrl = "";
isList = false;
isUrl = true;
}
public SongInfoObj(String Author, String Name, String ID, String Alia, String Call, String Al,
boolean isList, int Length, String picUrl, boolean isTrial, freeTrialInfo trialInfo) {
this.author = Author;
this.name = Name;
this.id = ID;
this.alia = Alia;
this.call = Call;
this.al = Al;
this.picUrl = picUrl;
this.isList = isList;
this.length = Length;
this.isTrial = isTrial;
this.trialInfo = trialInfo;
}
public boolean isUrl() {
return isUrl;
}
public boolean isTrial() {
return isTrial;
}
public String getPicUrl() {
return picUrl;
}
public freeTrialInfo getTrialInfo() {
return trialInfo;
}
public String getPlayerUrl() {
return playerUrl;
}
public String getAl() {
return al == null ? "" : al;
}
public String getAlia() {
return alia == null ? "" : alia;
}
public String getCall() {
return call == null ? "" : call;
}
public String getAuthor() {
return author == null ? "" : author;
}
public int getLength() {
return length;
}
public boolean isList() {
return isList;
}
public String getName() {
return name == null ? "" : name;
}
public String getID() {
return id;
}
public String getInfo() {
String info = AllMusic.getMessage().MusicPlay.MusicInfo;
info = info.replace("%MusicName%", name == null ? "" : name)
.replace("%MusicAuthor%", author == null ? "" : author)
.replace("%MusicAl%", al == null ? "" : al)
.replace("%MusicAlia%", alia == null ? "" : alia)
.replace("%PlayerName%", call == null ? "" : call);
return info;
}
public boolean isNull() {
return name == null;
}
}
@@ -0,0 +1,61 @@
package coloryr.allmusic.core.objs.music;
import coloryr.allmusic.core.objs.api.music.trialinfo.freeTrialInfo;
public class TopSongInfoObj extends SongInfoObj {
public TopSongInfoObj() {
super(null, null, 0);
}
public void setAl(String al) {
this.al = al;
}
public void setAlia(String alia) {
this.alia = alia;
}
public void setAuthor(String author) {
this.author = author;
}
public void setCall(String call) {
this.call = call;
}
public void setId(String id) {
this.id = id;
}
public void setLength(int length) {
this.length = length;
}
public void setList(boolean list) {
isList = list;
}
public void setName(String name) {
this.name = name;
}
public void setPicUrl(String picUrl) {
this.picUrl = picUrl;
}
public void setPlayerUrl(String playerUrl) {
this.playerUrl = playerUrl;
}
public void setTrial(boolean trial) {
isTrial = trial;
}
public void setTrialInfo(freeTrialInfo trialInfo) {
this.trialInfo = trialInfo;
}
public void setUrl(boolean url) {
isUrl = url;
}
}
@@ -0,0 +1,12 @@
package coloryr.allmusic.core.side;
public class ComType {
public static final String lyric = "[Lyric]";
public static final String info = "[Info]";
public static final String list = "[List]";
public static final String play = "[Play]";
public static final String img = "[Img]";
public static final String stop = "[Stop]";
public static final String clear = "[clear]";
public static final String pos = "[Pos]";
}
@@ -0,0 +1,7 @@
package coloryr.allmusic.core.side;
public interface IMyLogger {
void warning(String data);
void info(String data);
}
@@ -0,0 +1,246 @@
package coloryr.allmusic.core.side;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.objs.music.MusicObj;
import coloryr.allmusic.core.objs.music.SongInfoObj;
public abstract class ISide {
/**
* 重载
*/
public abstract void reload();
/**
* 获取当前玩家数量
*
* @return 数量
*/
public abstract int getAllPlayer();
/**
* 主线程运行任务
*
* @param run 任务
*/
public abstract void runTask(Runnable run);
/**
* 主线程延迟任务
*
* @param run 任务
* @param delay 延迟
*/
public abstract void runTask(Runnable run, int delay);
/**
* 检查权限
*
* @param player 用户名
* @param permission 权限
* @return 是否有权限
*/
public abstract boolean checkPermission(String player, String permission);
/**
* 是否需要播放
*
* @return 结果
*/
public abstract boolean needPlay();
/**
* 发送AllMusic插件信道消息
*
* @param data 数据
* @param player 用户名
*/
public abstract void send(String data, String player);
/**
* 发送停止指令
*/
public final void sendStop() {
AllMusic.clearNowPlayer();
topSendStop();
}
protected abstract void topSendStop();
/**
* 发送停止指令
*
* @param name 用户名
*/
public final void sendStop(String name) {
AllMusic.removeNowPlayPlayer(name);
topSendStop(name);
}
protected abstract void topSendStop(String name);
/**
* 发送播放歌曲指令
*
* @param url 歌曲Url
*/
public abstract void sendMusic(String url);
public final void sendMusic(String player, String url) {
AllMusic.addNowPlayPlayer(player);
topSendMusic(player, url);
}
protected abstract void topSendMusic(String player, String url);
/**
* 发送图片数据指令
*
* @param url 图片地址
*/
public abstract void sendPic(String url);
/**
* 发送图片数据指令
*
* @param player 用户名
* @param url 图片地址
*/
public abstract void sendPic(String player, String url);
/**
* 发送歌曲位置信息
*
* @param player 用户名
* @param pos 歌曲位置
*/
public abstract void sendPos(String player, int pos);
/**
* 发送Hud的歌词数据
*
* @param data 数据
*/
public abstract void sendHudLyric(String data);
/**
* 发送Hud的信息数据
*
* @param data 数据
*/
public abstract void sendHudInfo(String data);
/**
* 发送Hud的歌曲列表数据
*
* @param data 数据
*/
public abstract void sendHudList(String data);
/**
* 发送Hud位置数据
*/
public abstract void sendHudUtilsAll();
/**
* 发送Bar数据
*
* @param data 数据
*/
public abstract void sendBar(String data);
/**
* 清理Hud数据
*
* @param player 用户名
*/
public abstract void clearHud(String player);
/**
* 清理Hud数据
*/
public abstract void clearHud();
/**
* 广播消息
*
* @param data 消息
*/
public abstract void bq(String data);
/**
* 在主线程中广播消息
*
* @param data 消息
*/
public abstract void bqt(String data);
/**
* 在主线程发送消息
*
* @param obj 接受对象
* @param message 消息
*/
public abstract void sendMessaget(Object obj, String message);
/**
* 发送消息
*
* @param obj 接受对象
* @param message 消息
*/
public abstract void sendMessage(Object obj, String message);
/**
* 发送执行指令
*
* @param obj 接受对象
* @param message 消息
* @param end 结尾
* @param command 指令
*/
public abstract void sendMessageRun(Object obj, String message, String end, String command);
/**
* 发送推荐指令
*
* @param obj 接受对象
* @param message 消息
* @param end 结尾
* @param command 指令
*/
public abstract void sendMessageSuggest(Object obj, String message, String end, String command);
/**
* 当歌曲添加时触发的事件
*
* @param obj 歌曲信息
* @return 是否阻止播放
*/
public abstract boolean onMusicPlay(SongInfoObj obj);
/**
* 当歌曲播放时触发的事件
*
* @param obj 发送者
* @param music 歌曲信息
* @return 是否阻止添加
*/
public abstract boolean onMusicAdd(Object obj, MusicObj music);
/**
* 更新信息
*/
public abstract void updateInfo();
/**
* 更新歌词
*/
public abstract void updateLyric();
/**
* 发送BC的ping包
*/
public abstract void ping();
}
@@ -0,0 +1,7 @@
package coloryr.allmusic.core.sql;
public interface IEconomy {
boolean check(String name, int cost);
boolean cost(String name, int cost);
}
@@ -0,0 +1,68 @@
//package coloryr.allmusic.sql;
//
//import coloryr.allmusic.AllMusic;
//import org.apache.commons.dbcp2.BasicDataSource;
//
//import javax.sql.DataSource;
//import java.sql.*;
//
//public abstract class MysqlConn implements IEconomy{
// //建立连接的驱动驱动名称
// public final String DRIVER_CLASS_NAME = "com.mysql.cj.jdbc.Driver";
// //最大空闲链接
// private final int MAX_IDLE = 20;
// //最大空闲连接
// private final int MinIdle = 8;
// //最大等待时间
// private final long MAX_WAIT_Millis = 5000;
// //最大活动链接
// private final int MAX_TOTAl = 5;
// //初始化时链接池的数量
// private final int INITIAL_SIZE = 10;
// //一个被抛弃连接可以被移除的超时时间
// private final int RemoveAbandonedTimeout = 180;
// //只会发现当前连接失效,再创建一个连接供当前查询使用
// private final boolean TOBESTNORROW = true;
// private BasicDataSource DATA_SOURCE;
//
// public boolean start() {
// try {
// DATA_SOURCE = new BasicDataSource();
// DATA_SOURCE.setDriverClassName(DRIVER_CLASS_NAME);
// DATA_SOURCE.setUrl(AllMusic.getConfig().getEconomys().getMysqlUrl());
// DATA_SOURCE.setMaxTotal(MAX_TOTAl);
// DATA_SOURCE.setInitialSize(INITIAL_SIZE);
// DATA_SOURCE.setMinIdle(MinIdle);
// DATA_SOURCE.setMaxIdle(MAX_IDLE);
// DATA_SOURCE.setMaxWaitMillis(MAX_WAIT_Millis);
// DATA_SOURCE.setTestOnBorrow(TOBESTNORROW);
// DATA_SOURCE.setRemoveAbandonedTimeout(RemoveAbandonedTimeout);
//
// getConnection().createStatement().close();
//
// return test();
// } catch (Exception e) {
// e.printStackTrace();
// }
// return false;
// }
//
// public abstract boolean test();
//
// public DataSource getDateSource() {
// return DATA_SOURCE;
// }
//
// //提供获得链接
// public Connection getConnection() throws SQLException {
// return DATA_SOURCE.getConnection();
// }
//
// public void stop() {
// try {
// DATA_SOURCE.close();
// } catch (SQLException e) {
// e.printStackTrace();
// }
// }
//}
@@ -0,0 +1,30 @@
package coloryr.allmusic.core.utils;
import java.util.regex.Pattern;
public class Function {
public static boolean isInteger(String str) {
Pattern pattern = Pattern.compile("^[-+]?[\\d]*$");
return pattern.matcher(str).matches();
}
public static String getString(String a, String b, String c) {
int x = a.indexOf(b) + b.length();
int y;
if (c != null)
y = a.indexOf(c);
else y = a.length();
if (x < 0 || y < 0)
return a;
return a.substring(x, y);
}
public static int countChar(String a, char b) {
int count = 0;
for (char t : a.toCharArray()) {
if (t == b)
count++;
}
return count;
}
}
@@ -0,0 +1,42 @@
package coloryr.allmusic.core.utils;
import coloryr.allmusic.core.AllMusic;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Date;
public class Logs {
private static final Date date = new Date();
public static File file;
private static FileWriter fw;
private static PrintWriter pw;
public static void logWrite(String text) {
try {
if (fw == null)
fw = new FileWriter(file, true);
String year = String.format("%tF", date);
String time = String.format("%tT", date);
String write = "[" + year + "]" + "[" + time + "]" + text;
if (pw == null)
pw = new PrintWriter(fw);
pw.println(write);
pw.flush();
fw.flush();
} catch (IOException e) {
AllMusic.log.warning("§c日志文件写入失败");
e.printStackTrace();
}
}
public static void stop() throws IOException {
if (fw != null)
pw.close();
if (fw != null)
fw.close();
}
}
@@ -0,0 +1,17 @@
package coloryr.allmusic.mixin;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.server.command.ServerCommandSource;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.Constant;
import org.spongepowered.asm.mixin.injection.ModifyConstant;
@Mixin(ServerCommandSource.class)
public interface IGetCommandOutput {
@Accessor(value = "output")
CommandOutput getOutput();
}
@@ -0,0 +1,25 @@
package coloryr.allmusic.mixin;
import coloryr.allmusic.AllMusicFabric;
import coloryr.allmusic.core.AllMusic;
import net.minecraft.client.gui.screen.TitleScreen;
import net.minecraft.network.ClientConnection;
import net.minecraft.server.PlayerManager;
import net.minecraft.server.network.ServerPlayerEntity;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
@Mixin(PlayerManager.class)
public class ServerPlayerMixin {
@Inject(at = @At("HEAD"), method = "remove")
private void remove(ServerPlayerEntity entity, CallbackInfo info) {
AllMusic.removeNowPlayPlayer(entity.getName().getString());
}
@Inject(at = @At("TAIL"), method = "onPlayerConnect")
private void add(ClientConnection connection, ServerPlayerEntity player, CallbackInfo info) {
AllMusic.joinPlay(player.getName().getString());
}
}
@@ -0,0 +1,67 @@
package coloryr.allmusic.side.fabric;
import coloryr.allmusic.core.command.CommandEX;
import coloryr.allmusic.core.command.TabCommand;
import coloryr.allmusic.mixin.IGetCommandOutput;
import com.mojang.brigadier.Command;
import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.suggestion.SuggestionProvider;
import com.mojang.brigadier.suggestion.Suggestions;
import com.mojang.brigadier.suggestion.SuggestionsBuilder;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;
public class CommandFabric implements Command<ServerCommandSource>, Predicate<ServerCommandSource>, SuggestionProvider<ServerCommandSource> {
public static CommandFabric instance = new CommandFabric();
public void register(CommandDispatcher<ServerCommandSource> dispatcher) {
dispatcher.register(((CommandManager.literal("music").requires(this)).executes(this))
.then(CommandManager.argument("args", StringArgumentType.greedyString())
.suggests(this).executes(this)));
}
@Override
public int run(CommandContext<ServerCommandSource> context) {
var item = context.getSource();
var source = ((IGetCommandOutput) item).getOutput();
var input = context.getInput();
var temp = input.split(" ");
var arg = new String[temp.length - 1];
System.arraycopy(temp, 1, arg, 0, arg.length);
CommandEX.ex(source, context.getSource().getName(), arg);
return 0;
}
@Override
public boolean test(ServerCommandSource stack) {
return true;
}
@Override
public CompletableFuture<Suggestions> getSuggestions(CommandContext<ServerCommandSource> context, SuggestionsBuilder builder) {
var input = context.getInput();
var temp = input.split(" ");
var arg = new String[input.endsWith(" ") ? temp.length : temp.length - 1];
System.arraycopy(temp, 1, arg, 0, temp.length - 1);
if (input.endsWith(" "))
builder = builder.createOffset(builder.getInput().lastIndexOf(32) + 1);
List<String> results = TabCommand.getTabList(context.getSource().getName(), arg);
for (String s : results) {
builder.suggest(s);
}
return builder.buildFuture();
}
}
@@ -0,0 +1,33 @@
package coloryr.allmusic.side.fabric;
import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.ClickEvent;
import net.minecraft.text.LiteralText;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import java.util.UUID;
public class FabricApi {
public static void sendMessageRun(Object obj, String message, String command) {
CommandOutput sender = (CommandOutput) obj;
MutableText send = new LiteralText(message);
send.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
sender.sendSystemMessage(send, UUID.randomUUID());
}
public static void sendMessageSuggest(Object obj, String message, String command) {
CommandOutput sender = (CommandOutput) obj;
MutableText send = new LiteralText(message);
send.getStyle().withClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
sender.sendSystemMessage(send, UUID.randomUUID());
}
public static void sendBar(ServerPlayerEntity player, String message) {
var pack = new OverlayMessageS2CPacket(new LiteralText(message));
player.networkHandler.sendPacket(pack);
}
}
@@ -0,0 +1,16 @@
package coloryr.allmusic.side.fabric;
import coloryr.allmusic.AllMusicFabric;
import coloryr.allmusic.core.side.IMyLogger;
public class LogFabric implements IMyLogger {
@Override
public void warning(String data) {
AllMusicFabric.LOGGER.warn(data);
}
@Override
public void info(String data) {
AllMusicFabric.LOGGER.info(data);
}
}
@@ -0,0 +1,381 @@
package coloryr.allmusic.side.fabric;
import coloryr.allmusic.AllMusicFabric;
import coloryr.allmusic.TaskItem;
import coloryr.allmusic.Tasks;
import coloryr.allmusic.core.AllMusic;
import coloryr.allmusic.core.hud.HudUtils;
import coloryr.allmusic.core.objs.hud.SaveObj;
import coloryr.allmusic.core.objs.music.MusicObj;
import coloryr.allmusic.core.objs.music.SongInfoObj;
import coloryr.allmusic.core.side.ComType;
import coloryr.allmusic.core.side.ISide;
import coloryr.allmusic.side.fabric.event.MusicAddEvent;
import coloryr.allmusic.side.fabric.event.MusicPlayEvent;
import com.google.gson.Gson;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.fabricmc.fabric.api.networking.v1.ServerPlayNetworking;
import net.minecraft.network.PacketByteBuf;
import net.minecraft.server.command.CommandOutput;
import net.minecraft.server.network.ServerPlayNetworkHandler;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.LiteralText;
import net.minecraft.text.Text;
import net.minecraft.util.ActionResult;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.Locale;
import java.util.UUID;
public class SideFabric extends ISide {
@Override
public void reload() {
String path = "allmusic/";
new AllMusic().init(new File(path));
}
@Override
public int getAllPlayer() {
return AllMusicFabric.server.getCurrentPlayerCount();
}
@Override
public void runTask(Runnable run) {
AllMusicFabric.server.execute(run);
}
@Override
public void runTask(Runnable run1, int delay) {
Tasks.taskItems.add(new TaskItem() {{
tick = delay;
run = run1;
}});
}
@Override
public boolean checkPermission(String player, String permission) {
var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player);
if (player1 == null)
return false;
return player1.hasPermissionLevel(2);
}
@Override
public boolean needPlay() {
int online = getAllPlayer();
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (AllMusic.getConfig().NoMusicPlayer.contains(player.getName().getString())) {
online--;
}
}
return online > 0;
}
@Override
public void send(String data, String player) {
send(AllMusicFabric.server.getPlayerManager().getPlayer(player), data);
}
@Override
protected void topSendStop() {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
send(player, ComType.stop);
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c停止指令发送出错");
e.printStackTrace();
}
}
@Override
protected void topSendStop(String name) {
try {
var player = AllMusicFabric.server.getPlayerManager().getPlayer(name);
if (player == null)
return;
send(player, ComType.stop);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c停止指令发送出错");
e.printStackTrace();
}
}
@Override
public void sendMusic(String url) {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (AllMusic.isOK(player.getName().getString(), null, false))
continue;
send(player, ComType.play + url);
AllMusic.addNowPlayPlayer(player.getName().getString());
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌曲指令发送出错");
e.printStackTrace();
}
}
@Override
protected void topSendMusic(String player, String url) {
try {
var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player);
if (player1 == null)
return;
if (AllMusic.isOK(player, null, false))
return;
send(ComType.play + url, player);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌曲指令发送出错");
e.printStackTrace();
}
}
@Override
public void sendPic(String url) {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (AllMusic.isOK(player.getName().getString(), null, true))
continue;
String name = player.getName().getString();
SaveObj obj = HudUtils.get(name);
if (!obj.EnablePic)
continue;
send(player, ComType.img + url);
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c图片指令发送出错");
e.printStackTrace();
}
}
@Override
public void sendPic(String player, String url) {
try {
var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player);
if (player1 == null)
return;
if (AllMusic.isOK(player1.getName().getString(), null, true))
return;
send(ComType.img + url, player);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c图片指令发送出错");
e.printStackTrace();
}
}
@Override
public void sendPos(String player, int pos) {
try {
var player1 = AllMusicFabric.server.getPlayerManager().getPlayer(player);
if (player1 == null)
return;
if (AllMusic.isOK(player1.getName().getString(), null, true))
return;
send(ComType.pos + pos, player);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c清空Hud发生出错");
e.printStackTrace();
}
}
@Override
public void sendHudLyric(String data) {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (AllMusic.isOK(player.getName().getString(), null, true))
continue;
String name = player.getName().getString();
SaveObj obj = HudUtils.get(name);
if (!obj.EnableLyric)
continue;
send(player, ComType.lyric + data);
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌词发送出错");
e.printStackTrace();
}
}
@Override
public void sendHudInfo(String data) {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (AllMusic.isOK(player.getName().getString(), null, true))
continue;
String name = player.getName().getString();
SaveObj obj = HudUtils.get(name);
if (!obj.EnableInfo)
continue;
send(player, ComType.info + data);
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌词信息发送出错");
e.printStackTrace();
}
}
@Override
public void sendHudList(String data) {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (AllMusic.isOK(player.getName().getString(), null, true))
continue;
String name = player.getName().getString();
SaveObj obj = HudUtils.get(name);
if (!obj.EnableList)
continue;
send(player, ComType.list + data);
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c歌曲列表发送出错");
e.printStackTrace();
}
}
@Override
public void sendHudUtilsAll() {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
String Name = player.getName().getString();
try {
SaveObj obj = HudUtils.get(Name);
String data = new Gson().toJson(obj);
send(player, data);
} catch (Exception e1) {
AllMusic.log.warning("§d[AllMusic]§c数据发送发生错误");
e1.printStackTrace();
}
}
}
@Override
public void sendBar(String data) {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
try {
if (AllMusic.isOK(player.getName().getString(), null, true))
continue;
FabricApi.sendBar(player, data);
} catch (Exception e1) {
AllMusic.log.warning("§d[AllMusic]§c数据发送发生错误");
e1.printStackTrace();
}
}
}
@Override
public void clearHud(String player) {
try {
send(ComType.clear, player);
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c清空Hud发生出错");
e.printStackTrace();
}
}
@Override
public void clearHud() {
try {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
send(player, ComType.clear);
}
} catch (Exception e) {
AllMusic.log.warning("§d[AllMusic]§c清空Hud发生出错");
e.printStackTrace();
}
}
@Override
public void bq(String data) {
if (AllMusic.getConfig().MessageLimit
&& data.length() > AllMusic.getConfig().MessageLimitSize) {
data = data.substring(0, AllMusic.getConfig().MessageLimitSize - 1) + "...";
}
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (!AllMusic.getConfig().NoMusicPlayer.contains(player.getName().getString())) {
player.sendMessage(new LiteralText(data), false);
}
}
}
@Override
public void bqt(String data) {
if (AllMusic.getConfig().MessageLimit
&& data.length() > AllMusic.getConfig().MessageLimitSize) {
data = data.substring(0, AllMusic.getConfig().MessageLimitSize - 1) + "...";
}
var finalData = new LiteralText(data);
runTask(() -> {
for (var player : AllMusicFabric.server.getPlayerManager().getPlayerList()) {
if (!AllMusic.getConfig().NoMusicPlayer.contains(player.getName().getString())) {
player.sendMessage(finalData, false);
}
}
});
}
@Override
public void sendMessaget(Object obj, String message) {
runTask(() -> ((CommandOutput) obj).sendSystemMessage(new LiteralText(message), UUID.randomUUID()));
}
@Override
public void sendMessage(Object obj, String message) {
CommandOutput sender = (CommandOutput) obj;
sender.sendSystemMessage(new LiteralText(message), UUID.randomUUID());
}
@Override
public void sendMessageRun(Object obj, String message, String end, String command) {
FabricApi.sendMessageRun(obj, message + end, command);
}
@Override
public void sendMessageSuggest(Object obj, String message, String end, String command) {
FabricApi.sendMessageSuggest(obj, message + end, command);
}
@Override
public boolean onMusicPlay(SongInfoObj obj) {
return MusicPlayEvent.EVENT.invoker().interact(obj) != ActionResult.PASS;
}
@Override
public boolean onMusicAdd(Object obj, MusicObj music) {
return MusicAddEvent.EVENT.invoker().interact((ServerPlayerEntity) obj, music) != ActionResult.PASS;
}
@Override
public void updateInfo() {
}
@Override
public void updateLyric() {
}
@Override
public void ping() {
}
private void send(ServerPlayerEntity players, String data) {
if (players == null)
return;
try {
byte[] bytes = data.getBytes(StandardCharsets.UTF_8);
ByteBuf buf = Unpooled.buffer(bytes.length + 1);
buf.writeByte(666);
buf.writeBytes(bytes);
runTask(() -> ServerPlayNetworking.send(players, AllMusicFabric.ID, new PacketByteBuf(buf)));
} catch (Exception e) {
AllMusic.log.warning("§c数据发送发生错误");
e.printStackTrace();
}
}
}
@@ -0,0 +1,24 @@
package coloryr.allmusic.side.fabric.event;
import coloryr.allmusic.core.objs.music.MusicObj;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
public interface MusicAddEvent {
Event<MusicAddEvent> EVENT = EventFactory.createArrayBacked(MusicAddEvent.class,
(listeners) -> (player, music) -> {
for (MusicAddEvent listener : listeners) {
ActionResult result = listener.interact(player, music);
if (result != ActionResult.PASS) {
return result;
}
}
return ActionResult.PASS;
});
ActionResult interact(ServerPlayerEntity player, MusicObj music);
}
@@ -0,0 +1,25 @@
package coloryr.allmusic.side.fabric.event;
import coloryr.allmusic.core.objs.music.MusicObj;
import coloryr.allmusic.core.objs.music.SongInfoObj;
import net.fabricmc.fabric.api.event.Event;
import net.fabricmc.fabric.api.event.EventFactory;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.util.ActionResult;
public interface MusicPlayEvent {
Event<MusicPlayEvent> EVENT = EventFactory.createArrayBacked(MusicPlayEvent.class,
(listeners) -> (music) -> {
for (MusicPlayEvent listener : listeners) {
ActionResult result = listener.interact(music);
if (result != ActionResult.PASS) {
return result;
}
}
return ActionResult.PASS;
});
ActionResult interact(SongInfoObj music);
}
@@ -0,0 +1,16 @@
{
"required": true,
"minVersion": "0.8",
"package": "coloryr.allmusic.mixin",
"compatibilityLevel": "JAVA_17",
"server": [
"IGetCommandOutput",
"ServerPlayerMixin"
],
"mixins": [
],
"injectors": {
"defaultRequire": 1
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 453 B

@@ -0,0 +1,62 @@
{
"MaxList": 10,
"MinVote": 3,
"Delay": 0,
"KDelay": 0,
"Admin": ["CONSOLE","Color_yr"],
"LoginUser": "",
"NoMusicServer": [],
"NoMusicPlayer": [],
"BanMusic": [],
"PlayList": [],
"PlayListSwitch": true,
"PlayListRandom": true,
"SendLyric": true,
"NeedPermission": false,
"DefaultAddMusic": 0,
"TopPAPI": false,
"MessageLimit": false,
"MessageLimitSize": 40,
"MutePlayMessage": false,
"MuteAddMessage": false,
"ShowInBar": false,
"DefaultHud": {
"List": {
"x": 2,
"y": 74
},
"Lyric": {
"x": 74,
"y": 53
},
"Info": {
"x": 74,
"y": 2
},
"Pic": {
"x": 2,
"y": 2
},
"PicRotateSpeed": 10,
"EnablePicRotate": true,
"EnableList": true,
"EnableLyric": true,
"EnableInfo": true,
"EnablePic": true
},
"Economys": {
"MysqlUrl": "jdbc:mysql://localhost:3306/minecraft?autoReconnect=true&autoReconnectForPools=true",
"Vault": true
},
"UseCost": false,
"SearchCost": 20,
"AddMusicCost": 10,
"MaxMusicTime": 600,
"KtvMode": true,
"MusicBR": "320000",
"FunConfig": {
"Rain": true,
"RainRate": 10
},
"Version": "103"
}
@@ -0,0 +1,37 @@
{
"schemaVersion": 1,
"id": "allmusic",
"version": "${version}",
"name": "AllMusic",
"description": "AllMusic Server Mod",
"authors": [
"Color_yr"
],
"contact": {
"homepage": "https://github.com/Coloryr/AllMusic_Server",
"sources": "https://github.com/Coloryr/AllMusic_Server"
},
"license": "CC0-1.0",
"icon": "assets/allmusic/icon.png",
"environment": "*",
"entrypoints": {
"main": [
"coloryr.allmusic.AllMusicFabric"
]
},
"mixins": [
"allmusic.mixins.json"
],
"depends": {
"fabricloader": ">=0.14.14",
"minecraft": "~1.18.2",
"java": ">=17",
"fabric-api": "*",
"fabric-language-kotlin": ">=1.8.10"
},
"suggests": {
"another-mod": "*"
}
}
@@ -0,0 +1,136 @@
{
"MusicPlay": {
"StopPlay": "§d[AllMusic]§e已停止你的音乐播放",
"NoMusic": "§d[AllMusic]§e无正在播放的歌曲",
"Play": "§d[AllMusic]§e正在播放:%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia% | by: %PlayerName%",
"NoPlay": "§d[AllMusic]§e队列中无歌曲",
"ListMusic": {
"Head": "§d[AllMusic]§e队列中有歌曲数:&Count&",
"Item": "§e%index%->%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia%",
"Get": "§d[AllMusic]§e歌曲列表%ListName%获取成功"
},
"NoCanPlay": "§d[AllMusic]§c无法播放歌曲%MusicID%可能该歌曲为VIP歌曲",
"NoPlayMusic": "§d[AllMusic]§e你不会再收到点歌了!想要再次参与点歌就点一首歌或者参与切歌投票吧!",
"Switch": "§d[AllMusic]§e切换到玩家歌曲",
"AddMusic": "§d[AllMusic]§e音乐列表添加%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia%",
"CheckMusic": "§d[AllMusic]§2正在解析歌曲%MusicID%",
"MusicInfo": "%MusicName% | %MusicAuthor% | %MusicAl% | %MusicAlia% | by: %PlayerName%",
"Trail": "§d[AllMusic]§e该音乐为试听音乐",
"Cancel": "§d[AllMusic]§e播放被取消"
},
"AddMusic": {
"ListFull": "§d[AllMusic]§c错误,队列已满",
"BanMusic": "§d[AllMusic]§c错误,这首歌被禁点了",
"ExistMusic": "§d[AllMusic]§c错误,这首歌已经存在了",
"Success": "§d[AllMusic]§e点歌成功",
"NoPlayer": "§d[AllMusic]§c没有播放的玩家",
"NoID": "§d[AllMusic]§c错误,请输入歌曲数字ID",
"Cancel": "§d[AllMusic]§e点歌被取消",
"TimeOut": "§d[AllMusic]§e点歌被取消,音乐长度过长"
},
"Page": {
"Choice": "§e%index%->%MusicName% | %MusicAuthor% | %MusicAl%",
"Next": "§e[§n点我下一页§r§e]",
"Last": "§e[§n点我上一页§r§e]"
},
"Lyric": {
"Data": "%Lyric%",
"TData": "%Lyric%(%TLyric%)"
},
"Vote": {
"NoPermission": "§d[AllMusic]§c你没有权限切歌",
"DoVote": "§d[AllMusic]§e已发起切歌投票",
"BQ": "§d[AllMusic]§e%PlayerName%发起了切歌投票,30秒后结束,输入/music vote 同意切歌。",
"Agree": "§d[AllMusic]§e你同意切歌",
"BQAgree": "§d[AllMusic]§e%PlayerName%同意切歌,共有%Count%名玩家同意切歌。",
"ARAgree": "§d[AllMusic]§e你已申请切歌",
"TimeOut": "§d[AllMusic]§e切歌时间结束",
"Do": "§d[AllMusic]§e已切歌"
},
"Search": {
"StartSearch": "§d[AllMusic]§e正在排队搜歌",
"NoPer": "§d[AllMusic]§c你没有权限搜歌",
"CantSearch": "§d[AllMusic]§c无法搜索歌曲:%Music%",
"Res": "§d[AllMusic]§e搜索结果",
"NoSearch": "§d[AllMusic]§c你没有搜索音乐",
"ErrorNum": "§d[AllMusic]§c请输入正确的序号",
"Chose": "§d[AllMusic]§e你选择了序号%Num%",
"CantNext": "§d[AllMusic]§c无法下一页",
"CantLast": "§d[AllMusic]§c无法上一页"
},
"Hud": {
"State": "§d[AllMusic]§e设置信息位置:%Hud%,状态:%State%",
"Set": "§d[AllMusic]§e已设置%Hud%的坐标为%x%, %y%",
"Reset": "§d[AllMusic]§eHud恢复至默认位置",
"NoMusic": "没有播放的音乐",
"NoList": "队列中无歌曲",
"NoLyric": "无歌词",
"PicSize": "§d[ALLMusic]§e设置图片尺寸为%Size%",
"PicRotate": "§d[AllMusic]§2设置图片旋转为%State%",
"PicRotateSpeed": "§d[AllMusic]§2设置图片旋转速度为%Size%",
"Music": "%Name% %AllTime%/%NowTime%\n%Author%\n%Alia%\n%Al%\nby: %Player%",
"Lyric": "%Lyric%\n%Tlyric%",
"Ktv": "§e%KLyric%§f%Lyric%§r\n%Tlyric%",
"List": "播放列表里面有%Size%首歌\n%List%"
},
"Command": {
"Error": "§d[AllMusic]§c参数错误,请输入/music help获取帮助",
"NoPer": "§d[AllMusic]§c你没有权限点歌"
},
"HudList": {
"List": "待播放列表",
"Lyric": "歌词",
"Info": "歌曲信息",
"Pic": "图片",
"All": "所有位置",
"PicRoute": "图片旋转",
"PicRouteSpeed": "图片旋转速度"
},
"Custom": {
"Info": "自定义音乐"
},
"PAPI": {
"NoMusic": "没有播放的音乐"
},
"Cost": {
"Search": "§d[AllMusic]§e你搜歌花费了%Cost%",
"AddMusic": "§d[AllMusic]§e你点歌花费了%Cost%",
"NoMoney": "§d[AllMusic]§c你没有足够的钱",
"CostFail": "§d[ALLMusic]§c扣钱过程中错误"
},
"Click": {
"This": "§b[§n点我选择§r§b]",
"Check": "§b[§n点我查看§r§b]"
},
"Help": {
"Normal": {
"Head": "§d[AllMusic]§e帮助手册",
"Base": "§d[AllMusic]§e使用/music [音乐ID] 来点歌",
"Stop": "§d[AllMusic]§e使用/music stop 停止播放歌曲",
"List": "§d[AllMusic]§e使用/music list 查看歌曲队列",
"Vote": "§d[AllMusic]§e使用/music vote 投票切歌",
"NoMusic": "§d[AllMusic]§e使用/music nomusic 不再参与点歌",
"Search": "§d[AllMusic]§e使用/music search [歌名] 搜索歌曲",
"Select": "§d[AllMusic]§e使用/music select [序列] 选择歌曲",
"Hud1": "§d[AllMusic]§e使用/music hud enable [位置] 启用关闭Hud",
"Hud2": "§d[AllMusic]§e使用/music hud [位置] [x] [y] 设置某个Hud的位置",
"Hud3": "§d[AllMusic]§e使用/music hud picsize [尺寸] 设置图片尺寸",
"Hud4": "§d[AllMusic]§e使用/music hud picrotate [开关] 设置图片旋转模式",
"Hud5": "§d[AllMusic]§e使用/music hud picrotatespeed [数值] 设置图片旋转速度"
},
"Admin": {
"Reload": "§d[AllMusic]§e使用/music reload 重读配置文件",
"Next": "§d[AllMusic]§e使用/music next 强制切歌",
"Ban": "§d[AllMusic]§e使用/music ban [ID] 禁止点这首歌",
"Url": "§d[AllMusic]§e使用/music url [url] 播放一首自定义歌曲",
"Delete": "§d[AllMusic]§e使用/music delete [序号] 删除队列中的歌曲",
"AddList": "§d[AllMusic]§e使用/music addlist [歌单ID] 添加歌单到空闲列表",
"ClearList": "§d[AllMusic]§e使用/music clearlist 清空空闲歌单",
"Login": "§d[AllMusic]§e使用/music login 重新登录账户"
}
},
"Fun": {
"Rain": "§d[AllMusic]§e天空开始变得湿润"
},
"Version": "103"
}
File renamed without changes.

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

Loaded 100 of 102 files, more files were not shown because too many files have changed in this diff. Show more