Buy cosmetics service
This commit is contained in:
@@ -83,9 +83,25 @@ public class ServiceClient {
|
||||
|
||||
public static void setHat(String hat) {
|
||||
try {
|
||||
session.request(ServiceMethods.SetCloak, hat).get();
|
||||
session.request(ServiceMethods.SetHat, hat).get();
|
||||
} catch (Exception e) {
|
||||
SaturnClient.LOGGER.error("Failed to set hat (service): ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void buyCloak(String cloak) {
|
||||
try {
|
||||
session.request(ServiceMethods.BuyCloak, cloak).get();
|
||||
} catch (Exception e) {
|
||||
SaturnClient.LOGGER.error("Failed to buy cloak (service): ", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static void buyHat(String hat) {
|
||||
try {
|
||||
session.request(ServiceMethods.BuyHat, hat).get();
|
||||
} catch (Exception e) {
|
||||
SaturnClient.LOGGER.error("Failed to buy hat (service): ", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,15 @@ public class ServiceMethods {
|
||||
public static final Method<String, AuthResponse, String> Authenticate = new Method<>("auth",
|
||||
String.class, AuthResponse.class, String.class);
|
||||
|
||||
// Equip
|
||||
public static final Method<String, String, String> SetCloak = new Method<>("set_cloak",
|
||||
String.class, String.class, String.class);
|
||||
public static final Method<String, String, String> SetHat = new Method<>("set_hat",
|
||||
String.class, String.class, String.class);
|
||||
|
||||
// Buy
|
||||
public static final Method<String, String, String> BuyCloak = new Method<>("buy_cloak",
|
||||
String.class, String.class, String.class);
|
||||
public static final Method<String, String, String> BuyHat = new Method<>("buy_hat",
|
||||
String.class, String.class, String.class);
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.saturnclient.ui2.screens.store;
|
||||
|
||||
import org.saturnclient.saturnclient.SaturnClient;
|
||||
import org.saturnclient.saturnclient.auth.Auth;
|
||||
import org.saturnclient.saturnclient.client.ServiceClient;
|
||||
import org.saturnclient.saturnclient.client.player.SaturnPlayer;
|
||||
import org.saturnclient.saturnclient.cosmetics.Hats;
|
||||
import org.saturnclient.ui2.SaturnScreen;
|
||||
@@ -42,7 +42,7 @@ public class HatStore extends SaturnScreen {
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
|
||||
SaturnPlayer player = Auth.players.get(Auth.uuid);
|
||||
SaturnPlayer player = SaturnPlayer.get();
|
||||
|
||||
if (player != null) {
|
||||
for (String hat : Hats.ALL_HATS) {
|
||||
@@ -54,7 +54,7 @@ public class HatStore extends SaturnScreen {
|
||||
long now = System.currentTimeMillis();
|
||||
if (now - lastPurchaseTime >= 3000) {
|
||||
Utils.notify(NotificationKind.Info, "Purchase processing", "Please wait");
|
||||
Auth.buyHat(hat);
|
||||
ServiceClient.buyHat(hat);
|
||||
lastPurchaseTime = now;
|
||||
new Thread(() -> {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user