Skip to content

Commit

Permalink
Fix PluginBridge (#254 #253 #232)
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraLS3 committed Aug 17, 2017
1 parent 53f27a6 commit 5cc5d61
Show file tree
Hide file tree
Showing 15 changed files with 116 additions and 95 deletions.

This file was deleted.

4 changes: 2 additions & 2 deletions Plan/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.djrapitops</groupId>
<artifactId>Plan</artifactId>
<version>3.6.3</version>
<version>3.7.0</version>
<packaging>jar</packaging>
<repositories>
<repository>
Expand Down Expand Up @@ -35,7 +35,7 @@
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>PlanPluginBridge</artifactId>
<version>3.6.0</version>
<version>3.7.0</version>
<scope>compile</scope>
</dependency>
<!-- -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public abstract class Importer {
/**
* Constructor.
*/
Importer() {
public Importer() {
info = "No info specified";
}

Expand Down
6 changes: 4 additions & 2 deletions Plan/src/main/java/com/djrapitops/plan/ui/html/Html.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import com.djrapitops.plugin.utilities.Verify;

import java.io.Serializable;

/**
* @author Rsl1122
*/
Expand Down Expand Up @@ -72,11 +74,11 @@ public String parse() {
* @param p The replacement Strings
* @return The parsed HTML String
*/
public String parse(String... p) {
public String parse(Serializable... p) {
Verify.nullCheck(p);
String returnValue = this.html;
for (int i = 0; i < p.length; i++) {
returnValue = returnValue.replace("REPLACE" + i, p[i]);
returnValue = returnValue.replace("REPLACE" + i, p[i].toString());
}
return returnValue;
}
Expand Down

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

This file was deleted.

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.

Binary file removed PlanPluginBridge/PlanPluginBridge-3.6.0.jar
Binary file not shown.
Binary file added PlanPluginBridge/PlanPluginBridge-3.7.0.jar
Binary file not shown.
36 changes: 29 additions & 7 deletions PlanPluginBridge/pom.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.djrapitops</groupId>
<artifactId>PlanPluginBridge</artifactId>
<version>3.6.3</version>
<version>3.7.0</version>
<packaging>jar</packaging>
<repositories>
<repository>
<id>plan-repo</id>
<url>http://repo.fuzzlemann.de/artifactory/libs-release/</url>
</repository>
<repository>
<id>plan-snapshot-repo</id>
<url>http://repo.fuzzlemann.de/artifactory/libs-snapshot/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
Expand All @@ -23,13 +32,13 @@
<dependency>
<groupId>com.djrapitops</groupId>
<artifactId>Plan</artifactId>
<version>3.6.2</version>
<version>3.7.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>craftbukkit</artifactId>
<version>1.11.2-R0.1-SNAPSHOT</version>
<groupId>com.destroystokyo.paper</groupId>
<artifactId>paper</artifactId>
<version>1.12-R0.1-20170725.202533-1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -59,7 +68,7 @@
<dependency>
<groupId>com.gamingmesh</groupId>
<artifactId>jobs</artifactId>
<version>3.9.1</version>
<version>4.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -117,9 +126,22 @@
<scope>provided</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.9</version>
</plugin>
</plugins>
</build>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<sonar.language>java</sonar.language>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
<sonar.jacoco.reportPaths>${project.basedir}/target/jacoco.exec</sonar.jacoco.reportPaths>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@
*/
package com.djrapitops.pluginbridge.plan;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.UserData;
import org.bukkit.Location;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
*
* @author Rsl1122
Expand Down Expand Up @@ -49,11 +50,6 @@ public boolean isBanned() {
return data.isBanned();
}

@Override
@Deprecated
public void setBanned(boolean bln) {
}

@Override
public boolean isWhitelisted() {
return true;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
package com.djrapitops.pluginbridge.plan.importing;

import java.util.UUID;
import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.importing.Importer;
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
import me.edge209.OnTime.OnTimeAPI;
import org.bukkit.GameMode;
import org.bukkit.OfflinePlayer;

import java.util.UUID;

import static org.bukkit.Bukkit.getOfflinePlayer;

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,25 @@
package com.djrapitops.pluginbridge.plan.jobs;

import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.PlayerManager;
import com.gamingmesh.jobs.container.JobProgression;
import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;

import com.gamingmesh.jobs.container.JobsPlayer;
import main.java.com.djrapitops.plan.Plan;
import com.gamingmesh.jobs.dao.JobsDAOData;
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.ui.html.Html;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;

import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;

/**
* PluginData class for Jobs-plugin.
*
* <p>
* Registered to the plugin by JobsHook
*
* @author Rsl1122
* @since 3.2.1
* @see JobsHook
* @since 3.2.1
*/
public class JobsAnalysisJobTable extends PluginData {

Expand All @@ -41,33 +38,30 @@ public JobsAnalysisJobTable() {

@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
PlayerManager pm = Jobs.getPlayerManager();
List<List<JobProgression>> players = Plan.getPlanAPI().getInspectCachedUserData().stream()
.map(p -> pm.getPlayerInfo(p.getUuid()))
.filter(Objects::nonNull)
.map(pm::getJobsPlayerOffline)
.map(JobsPlayer::getJobProgression)
.filter(list -> !list.isEmpty())
List<JobsDAOData> allJobs = Jobs.getDBManager().getDB().getAllJobs()
.values().stream()
.flatMap(Collection::stream)
.collect(Collectors.toList());
if (players.isEmpty()) {

if (allJobs.isEmpty()) {
return parseContainer("", Html.TABLELINE_4.parse("No Players with Jobs", "", "", ""));
}

Map<String, Integer> workers = new HashMap<>();
Map<String, Long> totals = new HashMap<>();
for (List<JobProgression> jobs : players) {
for (JobProgression job : jobs) {
String name = job.getJob().getName();
int level = job.getLevel();
if (!workers.containsKey(name)) {
workers.put(name, 0);
}
workers.put(name, workers.get(name) + 1);
if (!totals.containsKey(name)) {
totals.put(name, 0L);
}
totals.put(name, totals.get(name) + level);
for (JobsDAOData data : allJobs) {
String job = data.getJobName();
int level = data.getLevel();
if (!workers.containsKey(job)) {
workers.put(job, 0);
}
workers.put(job, workers.get(job) + 1);
if (!totals.containsKey(job)) {
totals.put(job, 0L);
}
totals.put(job, totals.get(job) + level);
}

StringBuilder html = new StringBuilder();
for (String job : workers.keySet()) {
Integer amountOfWorkers = workers.get(job);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,24 +1,22 @@
package com.djrapitops.pluginbridge.plan.jobs;

import com.gamingmesh.jobs.Jobs;
import com.gamingmesh.jobs.PlayerManager;
import com.gamingmesh.jobs.container.JobProgression;
import com.gamingmesh.jobs.container.JobsPlayer;
import com.gamingmesh.jobs.container.PlayerInfo;
import com.gamingmesh.jobs.dao.JobsDAOData;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.ui.html.Html;

import java.io.Serializable;
import java.util.List;
import java.util.UUID;
import main.java.com.djrapitops.plan.data.additional.PluginData;
import main.java.com.djrapitops.plan.ui.html.Html;

/**
* PluginData class for Jobs-plugin.
*
* <p>
* Registered to the plugin by JobsHook
*
* @author Rsl1122
* @since 3.2.1
* @see JobsHook
* @since 3.2.1
*/
public class JobsInspectJobTable extends PluginData {

Expand All @@ -37,14 +35,11 @@ public JobsInspectJobTable() {
@Override
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
try {
PlayerManager pm = Jobs.getPlayerManager();
PlayerInfo info = pm.getPlayerInfo(uuid);
JobsPlayer player = pm.getJobsPlayerOffline(info);
List<JobProgression> progression = player.getJobProgression();
if (!progression.isEmpty()) {
List<JobsDAOData> playersJobs = Jobs.getDBManager().getDB().getAllJobs(null, uuid);
if (!playersJobs.isEmpty()) {
StringBuilder html = new StringBuilder();
for (JobProgression job : progression) {
html.append(Html.TABLELINE_2.parse(job.getJob().getName(), "" + job.getLevel()));
for (JobsDAOData job : playersJobs) {
html.append(Html.TABLELINE_2.parse(job.getJobName(), job.getLevel()));
}
return parseContainer("", html.toString());
}
Expand Down

0 comments on commit 5cc5d61

Please sign in to comment.