Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Publish docs

on:
push:
branches:
- master
paths:
- docs/**
- mkdocs.yml
- requirements.txt
- .github/workflows/docs.yml
workflow_dispatch:

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v2
with:
python-version: 3.x
- name: Install dependencies
run: pip install -r requirements.txt
- name: Deploy docs
run: mkdocs gh-deploy --force
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ hs_err_pid*
# User-specific stuff
/.idea/
run/**
.venv

# CMake
cmake-build-*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ public static class SpriteUploaders {

private static final ResourceLocation TEXTURE = ResourceLocation.create("screenshotuploader", "themes/vanilla/textures/settings.png");

public static Icon IMGUR = Icon.sprite32(TEXTURE, 0, 1);
public static Icon XBACKBONE = Icon.sprite32(TEXTURE, 1, 1);
public static Icon ZIPLINE = Icon.sprite32(TEXTURE, 2, 1);
public static Icon CRAFTSHOT = Icon.sprite32(TEXTURE, 0, 1);
public static Icon IMGUR = Icon.sprite32(TEXTURE, 1, 1);
public static Icon XBACKBONE = Icon.sprite32(TEXTURE, 2, 1);
public static Icon ZIPLINE = Icon.sprite32(TEXTURE, 3, 1);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.rappytv.screenshotuploader.api;

import org.jetbrains.annotations.NotNull;

/**
* This exception is thrown when an upload fails for whatever reason
*/
Expand All @@ -12,7 +14,7 @@ public class UploadException extends RuntimeException {
* @param message The reason why the upload failed
* @param uploader The uploader the upload failed with
*/
public UploadException(String message, Uploader<?> uploader) {
public UploadException(@NotNull String message, @NotNull Uploader<?> uploader) {
super(message);
this.uploader = uploader;
}
Expand All @@ -22,7 +24,7 @@ public UploadException(String message, Uploader<?> uploader) {
* @param cause The reason why the upload failed
* @param uploader The uploader the upload failed with
*/
public UploadException(Throwable cause, Uploader<?> uploader) {
public UploadException(@NotNull Throwable cause, @NotNull Uploader<?> uploader) {
super(cause);
this.uploader = uploader;
}
Expand All @@ -31,6 +33,7 @@ public UploadException(Throwable cause, Uploader<?> uploader) {
* Get the uploader with which the upload failed
* @return The uploader the upload failed with
*/
@NotNull
public Uploader<?> getUploader() {
return this.uploader;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import com.rappytv.screenshotuploader.core.command.UploadCommand;
import com.rappytv.screenshotuploader.core.config.UploaderConfig;
import com.rappytv.screenshotuploader.core.listener.ScreenshotListener;
import com.rappytv.screenshotuploader.core.uploader.uploaders.CraftShotUploader;
import com.rappytv.screenshotuploader.core.uploader.uploaders.ImgurUploader;
import com.rappytv.screenshotuploader.core.uploader.uploaders.XBackBoneUploader;
import com.rappytv.screenshotuploader.core.uploader.uploaders.ZiplineUploader;
Expand Down Expand Up @@ -40,6 +41,7 @@ protected void enable() {
this.registerSettingCategory();
this.registerCommand(new UploadCommand(this));
this.registerListener(new ScreenshotListener());
uploaderRegistry().registerUploader(new CraftShotUploader());
uploaderRegistry().registerUploader(new ImgurUploader(this));
uploaderRegistry().registerUploader(new XBackBoneUploader(this));
uploaderRegistry().registerUploader(new ZiplineUploader(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,34 +21,42 @@ public class UploadCommand extends Command {
public UploadCommand(ScreenshotUploaderAddon addon) {
super("supload");
this.addon = addon;

this.translationKey("screenshotuploader.command");
}

@Override
public boolean execute(String prefix, String[] args) {
if(args.length < 1) {
this.displayMessage(ScreenshotUploaderAddon.prefix().append(Component.translatable("screenshotuploader.upload.file", NamedTextColor.RED)));
this.displayMessage(ScreenshotUploaderAddon.prefix().append(Component.translatable(
this.getTranslationKey("fileNotFound"),
NamedTextColor.RED
)));
return true;
}
File file = new File(System.getProperty("user.dir") + "/screenshots/" + args[0]);
if(!file.exists()) {
this.displayMessage(ScreenshotUploaderAddon.prefix().append(Component.translatable("screenshotuploader.upload.file", NamedTextColor.RED)));
this.displayMessage(ScreenshotUploaderAddon.prefix().append(Component.translatable(
this.getTranslationKey("fileNotFound"),
NamedTextColor.RED
)));
return true;
}
if(this.history.contains(file.getName()) && this.addon.configuration().askBeforeDoubleUploads().get()) {
if(args.length < 2 || !args[1].equalsIgnoreCase("force")) {
Component component = Component.empty()
.append(ScreenshotUploaderAddon.prefix())
.append(Component.translatable(
"screenshotuploader.upload.alreadyUploaded",
this.getTranslationKey("alreadyUploaded"),
NamedTextColor.RED
))
.append(Component.space())
.append(
Component.translatable("screenshotuploader.upload.openAnyway")
Component.translatable(this.getTranslationKey("openAnyway"))
.color(NamedTextColor.AQUA)
.decorate(TextDecoration.UNDERLINED)
.hoverEvent(HoverEvent.showText(Component.translatable(
"screenshotuploader.upload.upload",
this.getTranslationKey("uploadFile"),
NamedTextColor.GREEN,
Component.text(file.getName())
)))
Expand All @@ -64,7 +72,9 @@ public boolean execute(String prefix, String[] args) {
}
}
this.history.add(file.getName());
Laby.labyAPI().minecraft().executeNextTick(() -> Laby.labyAPI().minecraft().minecraftWindow().displayScreen(new UploadActivity(file)));
Laby.labyAPI().minecraft().executeOnRenderThread(() ->
Laby.labyAPI().minecraft().minecraftWindow().displayScreen(new UploadActivity(file))
);
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ public class UploaderConfig extends AddonConfig {

@SettingSection("uploaders")
@IntroducedIn(namespace = "screenshotuploader", value = "1.0.4")
@SpriteSlot(size = 32, y = 1)
@SpriteSlot(size = 32, x = 1, y = 1)
private final ImgurConfig imgur = new ImgurConfig();

@SpriteSlot(size = 32, x = 1, y = 1)
@SpriteSlot(size = 32, x = 2, y = 1)
private final XBackBoneConfig xbackbone = new XBackBoneConfig();

@SpriteSlot(size = 32, x = 2, y = 1)
@SpriteSlot(size = 32, x = 3, y = 1)
private final ZiplineConfig zipline = new ZiplineConfig();

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class XBackBoneConfig extends Config {
public ConfigProperty<String> base() {
return this.base;
}

public ConfigProperty<String> auth() {
return this.auth;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.rappytv.screenshotuploader.core.listener;

import com.rappytv.screenshotuploader.core.ScreenshotUploaderAddon;
import com.rappytv.screenshotuploader.core.ui.activity.UploadActivity;
import java.io.File;
import net.labymod.api.Laby;
import net.labymod.api.client.component.Component;
import net.labymod.api.client.component.event.ClickEvent;
Expand All @@ -10,30 +12,60 @@
import net.labymod.api.event.Phase;
import net.labymod.api.event.Subscribe;
import net.labymod.api.event.client.misc.WriteScreenshotEvent;
import net.labymod.api.notification.Notification;
import net.labymod.api.notification.Notification.NotificationButton;

public class ScreenshotListener {

private static final String TRANSLATION_KEY = "screenshotuploader.event.";

@Subscribe
public void onScreenshot(WriteScreenshotEvent event) {
if(event.getPhase() != Phase.POST) return;
String fileName = event.getDestination().getName();

Component component = Component.empty()
.append(ScreenshotUploaderAddon.prefix())
.append(Component.translatable("screenshotuploader.upload.madeScreenshot"))
.append(Component.translatable(TRANSLATION_KEY + "madeScreenshot"))
.append(Component.space())
.append(
Component.translatable("screenshotuploader.upload.uploadQuestion")
Component.translatable(TRANSLATION_KEY + "uploadQuestion")
.color(NamedTextColor.AQUA)
.decorate(TextDecoration.UNDERLINED)
.clickEvent(ClickEvent.runCommand("/supload " + fileName))
.hoverEvent(HoverEvent.showText(Component.translatable(
"screenshotuploader.upload.upload",
"screenshotuploader.command.uploadFile",
NamedTextColor.DARK_PURPLE,
Component.text(fileName)
)))
);

Laby.references().chatExecutor().displayClientMessage(component);

if(!Laby.labyAPI().minecraft().isIngame()) {
NotificationButton button = NotificationButton.of(
Component.translatable(TRANSLATION_KEY + "notification.button"),
() -> Laby.labyAPI().minecraft().executeOnRenderThread(() -> {
File file = event.getDestination();

if(!file.exists()) {
Notification.builder()
.title(Component.translatable("screenshotuploader.notification.error"))
.text(Component.translatable("screenshotuploader.command.fileNotFound"))
.buildAndPush();
return;
}
Laby.labyAPI().minecraft().minecraftWindow().displayScreen(
new UploadActivity(file)
);
})
);

Notification.builder()
.title(Component.translatable(TRANSLATION_KEY + "notification.title"))
.text(Component.translatable(TRANSLATION_KEY + "notification.description"))
.addButton(button)
.buildAndPush();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public void initialize(Parent parent) {

button.setActionListener(() -> {
button.setEnabled(false);
button.setHoverComponent(null);
button.updateComponent(Component.translatable("screenshotuploader.activity.uploading", NamedTextColor.AQUA));
Task.builder(() -> {
try {
Expand Down Expand Up @@ -71,6 +72,7 @@ public void initialize(Parent parent) {
}
});
} catch (UploadException e) {
button.setHoverComponent(Component.text(e.getMessage(), NamedTextColor.RED));
ScreenshotUploaderAddon.logging().error("Failed to upload screenshot to " + e.getUploader().getName(), e);
Laby.labyAPI().minecraft().executeOnRenderThread(() -> {
button.setEnabled(true);
Expand Down
Loading