Skip to content

Commit

Permalink
[VoteUp 2] 添加 bStats 数据统计.
Browse files Browse the repository at this point in the history
本次 commit 包含以下内容:
- [Added] 添加了 bStats 数据统计,可于配置文件中关闭。
  • Loading branch information
Polar-Pumpkin committed Jun 26, 2020
1 parent 964c512 commit 26a3905
Show file tree
Hide file tree
Showing 10 changed files with 99 additions and 10 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions VoteUp/VoteUp.iml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Polar-Pumpkin:ParrotX:f0f4340df0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.scireum:parsii:1.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.WesJD.AnvilGUI:anvilgui:99a504a3bb" level="project" />
<orderEntry type="library" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
</component>
</module>
21 changes: 20 additions & 1 deletion VoteUp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>net.shoal.sir</groupId>
<artifactId>VoteUp</artifactId>
<version>2.0-BETA</version>
<version>2.0.2-BETA</version>
<packaging>jar</packaging>

<name>VoteUp</name>
Expand All @@ -32,6 +32,15 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<relocations>
<relocation>
<pattern>org.bstats</pattern>
<!-- Replace this with your package! -->
<shadedPattern>org.serverct.parrot</shadedPattern>
</relocation>
</relocations>
</configuration>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -62,6 +71,10 @@
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
<repository>
<id>CodeMC</id>
<url>https://repo.codemc.org/repository/maven-public</url>
</repository>
</repositories>

<dependencies>
Expand All @@ -83,5 +96,11 @@
<version>f0f4340df0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>
<version>1.7</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
10 changes: 10 additions & 0 deletions VoteUp/src/main/java/net/shoal/sir/voteup/VoteUp.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@
import net.shoal.sir.voteup.config.ConfigManager;
import net.shoal.sir.voteup.listener.InventoryClickListener;
import net.shoal.sir.voteup.listener.PlayerJoinListener;
import org.bstats.bukkit.Metrics;
import org.bukkit.Bukkit;
import org.serverct.parrot.parrotx.PPlugin;

public final class VoteUp extends PPlugin {
public final static int PLUGIN_ID = 7972;

@Override
protected void registerListener() {
Bukkit.getPluginManager().registerEvents(new PlayerJoinListener(), this);
Expand All @@ -27,6 +30,13 @@ public void load() {
VoteUpAPI.GUI_MANAGER.init();
VoteUpAPI.CACHE_MANAGER.init();

if (pConfig.getConfig().getBoolean(ConfigManager.Path.BSTATS.path, true)) {
Metrics metrics = new Metrics(this, PLUGIN_ID);
metrics.addCustomChart(new Metrics.SingleLineChart("totalVote", () -> VoteUpAPI.VOTE_MANAGER.list(vote -> !vote.isDraft).size()));
metrics.addCustomChart(new Metrics.SingleLineChart("openVote", () -> VoteUpAPI.VOTE_MANAGER.list(vote -> !vote.isDraft && vote.open).size()));
metrics.addCustomChart(new Metrics.SingleLineChart("closeVote", () -> VoteUpAPI.VOTE_MANAGER.list(vote -> !vote.isDraft && !vote.open).size()));
}

super.registerCommand(new VoteUpCmd());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ public void saveDefault() {
}

public enum Path {
BSTATS("bStats"),
SOUND_ENABLE("Sound.Enable"),
SOUND_ACTION_START("Sound.Action.Start"),
SOUND_ACTION_SUCCESS("Sound.Action.Success"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

import java.io.File;
import java.util.*;
import java.util.function.Predicate;

public class VoteManager extends PFolder {

Expand Down Expand Up @@ -71,6 +72,14 @@ public Vote getNewest() {
return votes.get(0);
}

public List<Vote> list(Predicate<Vote> filter) {
List<Vote> result = new ArrayList<>();
voteMap.values().forEach(vote -> {
if (filter.test(vote)) result.add(vote);
});
return result;
}

public Vote create(UUID uuid) {
Vote vote = new Vote(plugin.pConfig.getConfig().getInt(ConfigManager.Path.SETTINGS_PARTICIPANT_LEAST.path, 3), uuid, "1d");
voteMap.put(vote.voteID, vote);
Expand Down
48 changes: 48 additions & 0 deletions VoteUp/src/main/resources/Guis/VoteList.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
Settings:
Title: "检索结果"
Row: 5
Items:
GLASS:
ItemStack:
Material: GRAY_STAINED_GLASS_PANE
Position:
X: 1-9
Y: 1,5
BACK:
ItemStack:
Display: "&b返回"
Material: MAP
Lore:
- ''
- ' &7导航 &b▶'
- ' %BACK%'
- ''
- ' &b▶ &f返回上一个界面'
- ''
Position:
X: 2
Y: 5
MODEL:
ItemStack:
Display: "&9投票 %TITLE% (%OPEN%)"
Material: WRITABLE_BOOK
Lore:
- ''
- ' &7投票类型 &b▶'
- ' &f%TYPE%'
- ' &7&o%TYPE_desc%'
- ''
- ' &7目标人数 &b▶'
- ' &f%GOAL% 人'
- ''
- ' &7投票简述 &b▶ '
- ' &f&o%DESCRIPTION%'
- ''
- ' &7由 &f%OWNER% &7于 &f%STARTTIME% &7发起'
- ' &7持续 &f%DURATION%'
- ''
- ' &b▶ &f左键查看投票详细信息'
- ''
Position:
X: 2-8
Y: 2-3
1 change: 1 addition & 0 deletions VoteUp/src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Debug: false
bStats: true
Language: Chinese
Sound:
Enable: true
Expand Down

0 comments on commit 26a3905

Please sign in to comment.