Skip to content

Commit

Permalink
sound effects
Browse files Browse the repository at this point in the history
sound effects
  • Loading branch information
lcy0x1 committed Jun 8, 2019
2 parents 0a86447 + b55a40d commit 88cf4aa
Show file tree
Hide file tree
Showing 71 changed files with 2,725 additions and 1,552 deletions.
6 changes: 0 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,6 @@
<artifactId>google-http-client</artifactId>
<version>1.24.1</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.jcraft/jorbis -->
<dependency>
<groupId>org.jcraft</groupId>
<artifactId>jorbis</artifactId>
<version>0.0.17</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.json/json -->
<dependency>
<groupId>org.json</groupId>
Expand Down
79 changes: 52 additions & 27 deletions src/io/BCJSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,8 @@ public class BCJSON extends WebFileIO {
private static final String req = "http://battlecatsultimate.cf/api/java/";
private static final String ast = "http://battlecatsultimate.cf/api/resources/";
private static final String path = "./assets/";
private static final String login = "login.php";
private static final String upload = "upload.php";
private static final String rate = "rate.php";
private static final String getinfo = "getinfo.php";
private static final String delete = "delete.php";
private static final String fileio = "fileio.php";
private static final String logio = "logio.php";
private static final String retrieve = "acquire.php";
private static final String changePassword = "changePassword.php";

private static final String[] cals;

Expand All @@ -72,6 +66,20 @@ public class BCJSON extends WebFileIO {

}

public static boolean changePassword(long pass) {
JSONObject inp = new JSONObject();
inp.put("uid", ID);
inp.put("password", PASSWORD);
inp.put("newpass", pass);
try {
JSONObject ans = read(inp.toString(), changePassword);
return ans.getInt("ret") == 0;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}

public static void checkDownload() {
LoadPage.prog("check download");
File f;
Expand All @@ -88,7 +96,9 @@ public static void checkDownload() {
LoadPage.prog("check jar update...");
if (MainBCU.ver < data.getInt("jar")) {
if (Opts.updateCheck("JAR", data.getString("jar-desc"))) {
String name = "BCU " + Data.revVer(data.getInt("jar")) + ".jar";
int ver = data.getInt("jar");
String name = "BCU" + (ver >= 40800 ? "-" : " ");
name += Data.revVer(ver) + ".jar";
if (download(ast + "jar/" + name, new File("./" + name), LoadPage.lp)) {
Writer.logClose(false);
System.exit(0);
Expand Down Expand Up @@ -145,7 +155,7 @@ public static boolean delete(int pid) {
inp.put("password", PASSWORD);
inp.put("pid", pid);
try {
JSONObject ans = read(inp.toString(), delete);
JSONObject ans = read(inp.toString(), "delete.php");
int ret = ans.getInt("ret");
if (ret == 0) {
WebPack wp = packlist.get(pid);
Expand All @@ -165,7 +175,7 @@ public static int getID(String str) throws IOException {
PASSWORD = new Random().nextLong();
inp.put("password", PASSWORD);
inp.put("bcuver", MainBCU.ver);
JSONObject ans = read(inp.toString(), login);
JSONObject ans = read(inp.toString(), "login.php");
int ret = ans.getInt("ret");
if (ret == 0)
return ans.getInt("id");
Expand All @@ -176,16 +186,22 @@ else if (ret == 2)
throw new IOException(ans.getString("message"));
}

public static List<WebPack> getPacks(int uid, int sort) throws IOException {
if (packlist.size() == 0)
refreshPacks();
List<WebPack> l = new ArrayList<>();
for (WebPack wp : packlist.values())
if ((uid == -1 || wp.uid == uid) && wp.state == 0 || wp.uid == uid && uid == ID)
l.add(wp);
l.sort(WebPack.getComp(sort));
public static boolean getPackInfo(WebPack wp, int pid) {
JSONObject inp = new JSONObject();
inp.put("user", ID);
inp.put("pid", Data.hex(pid));
inp.put("bcuver", MainBCU.ver);

return l;
try {
JSONObject res = read(inp.toString(), "getPackInfo.php");
JSONObject packs = res.getJSONObject("pack");
wp.desp = packs.getString("desp");
wp.loadImg(packs.getJSONArray("img"));
return true;
} catch (IOException e) {
e.printStackTrace();
return false;
}
}

public static int getPassword(String str) throws IOException {
Expand Down Expand Up @@ -226,15 +242,14 @@ public static int initUpload(int pid, String name, String desc) {
inp.put("bcuver", MainBCU.ver);

try {
JSONObject ans = read(inp.toString(), upload);
JSONObject ans = read(inp.toString(), "upload.php");
int ret = ans.getInt("ret");
if (ret == 0) {
WebPack wp = new WebPack(pid);
wp.author = USERNAME;
wp.desp = desc;
wp.name = name;
wp.uid = ID;
wp.url = req + "downloadpack.php?packid=" + pid;
boolean b = reversion(pid);
return b ? 0 : 5;
} else if (ret == 2)
Expand All @@ -254,7 +269,7 @@ public static int[][] rate(int pid, int val) {
inp.put("rate", val + 1);

try {
JSONObject ans = read(inp.toString(), rate);
JSONObject ans = read(inp.toString(), "rate.php");
int ret = ans.getInt("ret");
return ret == 0 ? getRate(ans.getJSONObject("rate")) : null;
} catch (IOException e) {
Expand All @@ -266,7 +281,8 @@ public static int[][] rate(int pid, int val) {
public static void refreshPacks() throws IOException {
JSONObject inp = new JSONObject();
inp.put("user", ID);
JSONObject res = read(inp.toString(), getinfo);
inp.put("bcuver", MainBCU.ver);
JSONObject res = read(inp.toString(), "getinfo.php");
JSONArray packs = res.getJSONArray("pack");
int len = packs.length();
packlist.clear();
Expand All @@ -277,7 +293,7 @@ public static void refreshPacks() throws IOException {

public static boolean report(File f) {
try {
return upload(f, req + logio);
return upload(f, req + "logio.php");
} catch (IOException e) {
e.printStackTrace();
return false;
Expand All @@ -294,15 +310,15 @@ public static boolean reversion(int pid) {
File f = new File("./pack/" + pid + ".bcupack");
if (f.exists())
try {
boolean b = upload(f, req + fileio);
boolean b = upload(f, req + "fileio.php");
if (b) {
JSONObject inp = new JSONObject();
inp.put("uid", ID);
inp.put("password", PASSWORD);
inp.put("pid", pid);
inp.put("rev", 1);
inp.put("bcuver", MainBCU.ver);
JSONObject ans = read(inp.toString(), upload);
JSONObject ans = read(inp.toString(), "upload.php");
if (ans.getInt("ret") == 0)
return true;
}
Expand All @@ -324,7 +340,7 @@ public static boolean update(int pid, String name, String desc) {
inp.put("desc", process(desc));

try {
JSONObject ans = read(inp.toString(), upload);
JSONObject ans = read(inp.toString(), "upload.php");
int ret = ans.getInt("ret");
if (ret == 0) {
WebPack wp = packlist.get(pid);
Expand All @@ -339,6 +355,15 @@ public static boolean update(int pid, String name, String desc) {
}
}

public static boolean uploadImg(int pid, String iid, File f) {
try {
return upload(f, req + "uploadImage.php?packid=" + pid + "&imgid=" + iid);
} catch (IOException e) {
e.printStackTrace();
return false;
}
}

private static void checkLib(JSONObject lib) {
if (lib != null && lib.length() > 1) {
Map<String, String> libmap = new TreeMap<>();
Expand Down
Loading

0 comments on commit 88cf4aa

Please sign in to comment.