Fixed store purchase
This commit is contained in:
@@ -17,15 +17,17 @@ import org.saturnclient.ui2.elements.Text;
|
|||||||
import org.saturnclient.ui2.resources.Fonts;
|
import org.saturnclient.ui2.resources.Fonts;
|
||||||
import org.saturnclient.ui2.resources.Textures;
|
import org.saturnclient.ui2.resources.Textures;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
public class CloakStore extends SaturnScreen {
|
public class CloakStore extends SaturnScreen {
|
||||||
private long lastPurchaseTime = 0;
|
private long lastPurchaseTime = 0;
|
||||||
|
|
||||||
public CloakStore() {
|
public CloakStore() {
|
||||||
super("Hat Store");
|
super("Cloak Store");
|
||||||
}
|
}
|
||||||
|
|
||||||
public CloakStore(long lastPurchaseTime) {
|
public CloakStore(long lastPurchaseTime) {
|
||||||
super("Hat Store");
|
super("Cloak Store");
|
||||||
this.lastPurchaseTime = lastPurchaseTime;
|
this.lastPurchaseTime = lastPurchaseTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,15 +53,21 @@ public class CloakStore extends SaturnScreen {
|
|||||||
scroll.draw(new CosmeticPreview(cloak == player.cloak, Textures.getCloakPreview(cloak), () -> {
|
scroll.draw(new CosmeticPreview(cloak == player.cloak, Textures.getCloakPreview(cloak), () -> {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (now - lastPurchaseTime >= 3000) {
|
if (now - lastPurchaseTime >= 3000) {
|
||||||
Utils.notify(NotificationKind.Info, "Purchase processing", "Please wait 3 seconds");
|
Utils.notify(NotificationKind.Info, "Purchase processing", "Please wait");
|
||||||
Auth.buyCloak(cloak);
|
Auth.buyCloak(cloak);
|
||||||
lastPurchaseTime = now;
|
lastPurchaseTime = now;
|
||||||
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(3000);
|
Thread.sleep(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
RenderSystem.recordRenderCall(() -> {
|
||||||
SaturnClient.client.setScreen(new CloakStore(now));
|
SaturnClient.client.setScreen(new CloakStore(now));
|
||||||
|
Utils.notify(NotificationKind.Success, "Purchase complete",
|
||||||
|
"Congrats, enjoy your new cloak!");
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
Utils.notify(NotificationKind.Error, "Timeout error", "Please wait 3 seconds");
|
Utils.notify(NotificationKind.Error, "Timeout error", "Please wait 3 seconds");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import org.saturnclient.ui2.elements.Text;
|
|||||||
import org.saturnclient.ui2.resources.Fonts;
|
import org.saturnclient.ui2.resources.Fonts;
|
||||||
import org.saturnclient.ui2.resources.Textures;
|
import org.saturnclient.ui2.resources.Textures;
|
||||||
|
|
||||||
|
import com.mojang.blaze3d.systems.RenderSystem;
|
||||||
|
|
||||||
public class HatStore extends SaturnScreen {
|
public class HatStore extends SaturnScreen {
|
||||||
private long lastPurchaseTime = 0;
|
private long lastPurchaseTime = 0;
|
||||||
|
|
||||||
@@ -51,15 +53,21 @@ public class HatStore extends SaturnScreen {
|
|||||||
scroll.draw(new CosmeticPreview(hat == player.hat, Textures.getHatPreview(hat), () -> {
|
scroll.draw(new CosmeticPreview(hat == player.hat, Textures.getHatPreview(hat), () -> {
|
||||||
long now = System.currentTimeMillis();
|
long now = System.currentTimeMillis();
|
||||||
if (now - lastPurchaseTime >= 3000) {
|
if (now - lastPurchaseTime >= 3000) {
|
||||||
Utils.notify(NotificationKind.Info, "Purchase processing", "Please wait 3 seconds");
|
Utils.notify(NotificationKind.Info, "Purchase processing", "Please wait");
|
||||||
Auth.buyHat(hat);
|
Auth.buyHat(hat);
|
||||||
lastPurchaseTime = now;
|
lastPurchaseTime = now;
|
||||||
|
new Thread(() -> {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(3000);
|
Thread.sleep(5000);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
RenderSystem.recordRenderCall(() -> {
|
||||||
SaturnClient.client.setScreen(new HatStore(now));
|
SaturnClient.client.setScreen(new HatStore(now));
|
||||||
|
Utils.notify(NotificationKind.Success, "Purchase complete",
|
||||||
|
"Congrats, enjoy your new hat!");
|
||||||
|
});
|
||||||
|
}).start();
|
||||||
} else {
|
} else {
|
||||||
Utils.notify(NotificationKind.Error, "Timeout error", "Please wait 3 seconds");
|
Utils.notify(NotificationKind.Error, "Timeout error", "Please wait 3 seconds");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user