Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some qol in ServerEndpoint. #23

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
19 changes: 13 additions & 6 deletions src/main/java/net/earthmc/emcapi/endpoint/ServerEndpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import com.palmergames.bukkit.towny.TownyAPI;
import com.palmergames.bukkit.towny.TownySettings;
import io.minimum.minecraft.superbvote.SuperbVote;
import io.minimum.minecraft.superbvote.votes.VoteParty;
import net.earthmc.emcapi.object.endpoint.GetEndpoint;
import net.earthmc.emcapi.util.EndpointUtils;
import au.lupine.quarters.object.entity.Quarter;
import au.lupine.quarters.api.manager.QuarterManager;
import org.bukkit.Bukkit;
import org.bukkit.World;

import java.time.LocalTime;
import java.util.List;

public class ServerEndpoint extends GetEndpoint {

Expand All @@ -37,7 +40,7 @@ public JsonObject getJsonElement() {

JsonObject statusObject = new JsonObject();
statusObject.addProperty("hasStorm", overworld.hasStorm());
statusObject.addProperty("isThundering", overworld.hasStorm());
statusObject.addProperty("isThundering", overworld.isThundering());
serverObject.add("status", statusObject);

JsonObject statsObject = new JsonObject();
Expand All @@ -51,12 +54,16 @@ public JsonObject getJsonElement() {
statsObject.addProperty("numTowns", townyAPI.getTowns().size());
statsObject.addProperty("numTownBlocks", townyAPI.getTownBlocks().size());
statsObject.addProperty("numNations", townyAPI.getNations().size());
statsObject.addProperty("numQuarters", quarterManager.getAllQuarters().size());
statsObject.addProperty("numCuboids", quarterManager.getAllQuarters().stream().mapToInt(quarter -> quarter.getCuboids().size()).sum());

List<Quarter> quarters = quarterManager.getAllQuarters();
statsObject.addProperty("numQuarters", quarters.size());
statsObject.addProperty("numCuboids", quarters.parallelStream().mapToInt(q -> q.getCuboids().size()).sum());

serverObject.add("stats", statsObject);

int target = SuperbVote.getPlugin().getVoteParty().votesNeeded();
int currentVotes = SuperbVote.getPlugin().getVoteParty().getCurrentVotes();
VoteParty voteParty = SuperbVote.getPlugin().getVoteParty();
int target = voteParty.votesNeeded();
int currentVotes = voteParty.getCurrentVotes();

JsonObject votePartyObject = new JsonObject();
votePartyObject.addProperty("target", target);
Expand All @@ -65,4 +72,4 @@ public JsonObject getJsonElement() {

return serverObject;
}
}
}