Skip to content

Commit

Permalink
添加代理功能
Browse files Browse the repository at this point in the history
  • Loading branch information
R-Josef committed Jan 8, 2023
1 parent 27abf1b commit 1addcdb
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>moe.feo</groupId>
<artifactId>BBSToper</artifactId>
<version>3.6.7</version>
<version>3.6.8</version>
<repositories>
<repository>
<id>spigot-repo</id>
Expand Down
9 changes: 9 additions & 0 deletions resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ mcbbs:
#如果一个玩家没有顶贴是否在加入时发送提示消息
joinmessage: true

# 代理设置
proxy:
# 启用代理
enable: false
# 代理ip
ip: '127.0.0.1'
# 代理端口
port: 10809

gui:
#玩家排名的显示数量
topplayers: 5
Expand Down
2 changes: 1 addition & 1 deletion resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: BBSToper
main: moe.feo.bbstoper.BBSToper
version: 3.6.7
version: 3.6.8
author: Fengshuai(R_Josef)
website: https://www.mcbbs.net/thread-789082-1-1.html
softdepend: [PlaceholderAPI]
Expand Down
6 changes: 5 additions & 1 deletion src/moe/feo/bbstoper/Crawler.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ public void resolveWebData() {
+ "&mobile=no";
Document doc = null;
try {
doc = Jsoup.connect(url).get();
if (Option.PROXY_ENABLE.getBoolean() == true) {
doc = Jsoup.connect(url).proxy(Option.PROXY_IP.getString(), Option.PROXY_PORT.getInt()).get();
} else {
doc = Jsoup.connect(url).get();
}
} catch (IOException e) {
if (Option.DEBUG.getBoolean()) {
e.printStackTrace(); // 这里经常会因为网络连接不顺畅而报错
Expand Down
3 changes: 3 additions & 0 deletions src/moe/feo/bbstoper/Option.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public enum Option {
MCBBS_CHANGEIDCOOLDOWN("mcbbs.changeidcooldown"),
MCBBS_QUERYCOOLDOWN("mcbbs.querycooldown"),
MCBBS_JOINMESSAGE("mcbbs.joinmessage"),
PROXY_ENABLE("proxy.enable"),
PROXY_IP("proxy.ip"),
PROXY_PORT("proxy.port"),
GUI_TOPPLAYERS("gui.topplayers"),
GUI_DISPLAYHEADSKIN("gui.displayheadskin"),
GUI_USECHATGETID("gui.usechatgetid"),
Expand Down

0 comments on commit 1addcdb

Please sign in to comment.