mirror of
https://github.com/refactorinqq/SLC-1.8.9.git
synced 2024-11-10 06:51:32 +01:00
for fushka
This commit is contained in:
parent
2cd52cadd7
commit
7b04e4f2d2
@ -184,9 +184,7 @@ public class ModInstances {
|
||||
mods.add(new FPSSpoofer());
|
||||
}
|
||||
mods.add(new NewMotionBlurMod());
|
||||
if(Client.getInstance().getBuildData().getBranch().equals("fushka")) {
|
||||
mods.add(new DonationsAlertsMod());
|
||||
}
|
||||
mods.add(new DonationsAlertsMod());
|
||||
mods.add(new QuickPlayMod());
|
||||
}
|
||||
|
||||
|
@ -1,23 +1,33 @@
|
||||
package net.silentclient.client.mods.player;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.resources.ResourcePackRepository;
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import net.silentclient.client.Client;
|
||||
import net.silentclient.client.gui.lite.clickgui.utils.GlUtils;
|
||||
import net.silentclient.client.gui.hud.ScreenPosition;
|
||||
import net.silentclient.client.mods.Mod;
|
||||
import net.silentclient.client.mods.ModCategory;
|
||||
import net.silentclient.client.mods.ModDraggable;
|
||||
import net.silentclient.client.utils.HttpPostMultipart;
|
||||
import net.silentclient.donationalerts.DonationAlerts;
|
||||
import net.silentclient.donationalerts.DonationAlertsEvent;
|
||||
|
||||
public class DonationsAlertsMod extends ModDraggable {
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DonationsAlertsMod extends Mod {
|
||||
public static DonationAlerts da;
|
||||
public static final String DASERVER = "https://socket.donationalerts.ru:443";
|
||||
public static final Minecraft mc = Minecraft.getMinecraft();
|
||||
public static ArrayList<DonationAlertsEvent> donates;
|
||||
private int height;
|
||||
private static float goal = 0;
|
||||
private static final float goalMax = 100;
|
||||
private static ArrayList<String> sendedResourcePacks = new ArrayList<>();
|
||||
|
||||
public DonationsAlertsMod() {
|
||||
super("Donation Alerts", ModCategory.MODS, null);
|
||||
@ -27,6 +37,7 @@ public class DonationsAlertsMod extends ModDraggable {
|
||||
public void setup() {
|
||||
super.setup();
|
||||
this.addInputSetting("Token", this, "");
|
||||
this.addInputSetting("Bot Token", this, "");
|
||||
donates = new ArrayList<DonationAlertsEvent>();
|
||||
try {
|
||||
da = new DonationAlerts(DASERVER);
|
||||
@ -61,25 +72,39 @@ public class DonationsAlertsMod extends ModDraggable {
|
||||
DonationAlertsInformation(event.getAmount() + " " + event.currency + " from " + event.getUsername() + ", message: " + event.getMessage());
|
||||
event.setShow(true);
|
||||
event.getTimer().reset();
|
||||
donates.add(event);
|
||||
// donates.add(event);
|
||||
|
||||
switch(event.getAmount()) {
|
||||
case "100.00":
|
||||
mc.thePlayer.sendChatMessage("Test!");
|
||||
break;
|
||||
case "200.00":
|
||||
disableKeyboard(10000);
|
||||
break;
|
||||
if(event.currency.equalsIgnoreCase("rub")) {
|
||||
if(Float.parseFloat(event.getAmount()) == 500) {
|
||||
sendCurrentPackToTelegram();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void disableKeyboard(int timeout) {
|
||||
(new Thread() {
|
||||
public void run() {
|
||||
|
||||
|
||||
public static void sendCurrentPackToTelegram() {
|
||||
new Thread(() -> {
|
||||
Client.logger.info("Sending Resource Pack to Telegram");
|
||||
String url = String.format("https://api.telegram.org/bot%s/sendDocument", Client.getInstance().getSettingsManager().getSettingByClass(DonationsAlertsMod.class, "Bot Token").getValString());
|
||||
Map<String, String> headers = new HashMap<>();
|
||||
List<ResourcePackRepository.Entry> rps = Lists.reverse(Minecraft.getMinecraft().getResourcePackRepository().getRepositoryEntries());
|
||||
if(!rps.isEmpty() && !sendedResourcePacks.contains(rps.get(0).getResourcePackName())) {
|
||||
headers.put("User-Agent", "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36");
|
||||
HttpPostMultipart multipart;
|
||||
try {
|
||||
multipart = new HttpPostMultipart(url, "utf-8", headers);
|
||||
multipart.addFilePart("document", new File(Minecraft.getMinecraft().getResourcePackRepository().getDirResourcepacks(), rps.get(0).getResourcePackName()));
|
||||
multipart.addFormField("chat_id", "-1002041784318");
|
||||
multipart.addFormField("caption", String.format("Ресурспак со стрима: %s", EnumChatFormatting.getTextWithoutFormattingCodes(rps.get(0).getResourcePackName())));
|
||||
sendedResourcePacks.add(rps.get(0).getResourcePackName());
|
||||
multipart.finish();
|
||||
} catch (IOException e) {
|
||||
Client.logger.catching(e);
|
||||
}
|
||||
} else {
|
||||
Client.logger.error("Resource Pack not found");
|
||||
}
|
||||
}).start();
|
||||
}).start();
|
||||
}
|
||||
|
||||
public static void DonationAlertsInformation(String message)
|
||||
@ -87,39 +112,4 @@ public class DonationsAlertsMod extends ModDraggable {
|
||||
Client.logger.info("[DonationsAlerts]: " + message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return height;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean render(ScreenPosition pos) {
|
||||
int y = 0;
|
||||
height = 0;
|
||||
|
||||
for(DonationAlertsEvent donate : donates) {
|
||||
if(donate.getTimer().delay(5000)) {
|
||||
donate.setShow(false);
|
||||
}
|
||||
if(donate.isShow()) {
|
||||
String header = donate.getUsername() + " – " + donate.getAmount() + " " + donate.getCurrency();
|
||||
GlUtils.startScale(0, y, 1.3F);
|
||||
font.drawString(header, 0, y, -1, true);
|
||||
GlUtils.stopScale();
|
||||
if(!donate.getMessage().trim().equals("")) {
|
||||
y += font.FONT_HEIGHT * 1.3F + 4;
|
||||
font.drawString(donate.getMessage(), (font.getStringWidth(header) * 1.3F) / 2, y, -1, true);
|
||||
}
|
||||
y += 20;
|
||||
height += (font.FONT_HEIGHT * 1.3F) + (!donate.getMessage().trim().equals("") ? font.FONT_HEIGHT : 0) + 20;
|
||||
}
|
||||
};
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user