8
8
/**
9
9
* Store string content to a pastebin that supports raw text requests (e.g. https://github.com/w4/bin)
10
10
*
11
+ * @param host Pastebin host URL
11
12
* @author Peter (https://github.com/MstrPikachu)
12
13
* @author Azalea (https://github.com/hykilpikonna)
13
14
* @since 2022-11-23
14
15
*/
15
- public class PasteBinStorage implements StringStorage
16
+ public record PasteBinStorage ( String host ) implements StringStorage
16
17
{
17
- private static final String HOST = "https://mcpm.hydev.org/paste/" ;
18
+ /**
19
+ * Construct with default host
20
+ */
21
+ public PasteBinStorage ()
22
+ {
23
+ this ("https://mcpm.hydev.org/paste/" );
24
+ }
18
25
19
26
@ Override
20
27
public String store (String content ) throws IOException
21
28
{
22
29
// Send request
23
- return Request .put (HOST )
30
+ return Request .put (host )
24
31
.bodyString (content , ContentType .TEXT_PLAIN )
25
32
.execute ().returnContent ().asString ();
26
33
}
@@ -31,7 +38,7 @@ public String load(String token) throws IOException
31
38
// If token is not a URL, treat it as the pastebin token and append host from it
32
39
if (!token .startsWith ("http://" ) && !token .startsWith ("https://" ))
33
40
{
34
- token = HOST + token ;
41
+ token = host + token ;
35
42
}
36
43
37
44
// Send request
@@ -43,6 +50,6 @@ public String load(String token) throws IOException
43
50
@ Override
44
51
public String instruction ()
45
52
{
46
- return String .format ("Please save the content to the pastebin at %s, and paste in the URL" , HOST );
53
+ return String .format ("Please save the content to the pastebin at %s, and paste in the URL" , host );
47
54
}
48
55
}
0 commit comments