Move hiscore client to rl-client
Thie removes the http-service hiscore api, which we haven't used in awhile and doesn't work in practice due to upstream rate limits, as well as the xp tracker which also hasn't been used in a long time since there are now multiple quality community run xptrackers.
This commit is contained in:
@@ -58,11 +58,6 @@
|
|||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-csv</artifactId>
|
|
||||||
<version>1.4</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
|
|||||||
@@ -1,111 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017. l2-
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.api.hiscore;
|
|
||||||
|
|
||||||
import java.util.Objects;
|
|
||||||
|
|
||||||
public class SingleHiscoreSkillResult
|
|
||||||
{
|
|
||||||
private String player;
|
|
||||||
private String skillName;
|
|
||||||
private Skill skill;
|
|
||||||
|
|
||||||
public String getPlayer()
|
|
||||||
{
|
|
||||||
return player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayer(String player)
|
|
||||||
{
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getSkillName()
|
|
||||||
{
|
|
||||||
return skillName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSkillName(String skillName)
|
|
||||||
{
|
|
||||||
this.skillName = skillName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Skill getSkill()
|
|
||||||
{
|
|
||||||
return skill;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSkill(Skill skill)
|
|
||||||
{
|
|
||||||
this.skill = skill;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int hash = 7;
|
|
||||||
hash = 37 * hash + Objects.hashCode(this.player);
|
|
||||||
hash = 37 * hash + Objects.hashCode(this.skillName);
|
|
||||||
hash = 37 * hash + Objects.hashCode(this.skill);
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final SingleHiscoreSkillResult other = (SingleHiscoreSkillResult) obj;
|
|
||||||
if (!Objects.equals(this.player, other.player))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!Objects.equals(this.skillName, other.skillName))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (!Objects.equals(this.skill, other.skill))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "SingleHiscoreSkillResult{" + "player=" + player + ", skillName=" + skillName + ", skill=" + skill + '}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,101 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.api.hiscore;
|
|
||||||
|
|
||||||
public class Skill
|
|
||||||
{
|
|
||||||
private final int rank;
|
|
||||||
private final int level;
|
|
||||||
private final long experience;
|
|
||||||
|
|
||||||
public Skill(int rank, int level, long experience)
|
|
||||||
{
|
|
||||||
this.rank = rank;
|
|
||||||
this.level = level;
|
|
||||||
this.experience = experience;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getRank()
|
|
||||||
{
|
|
||||||
return rank;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getLevel()
|
|
||||||
{
|
|
||||||
return level;
|
|
||||||
}
|
|
||||||
|
|
||||||
public long getExperience()
|
|
||||||
{
|
|
||||||
return experience;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int hashCode()
|
|
||||||
{
|
|
||||||
int hash = 3;
|
|
||||||
hash = 59 * hash + this.rank;
|
|
||||||
hash = 59 * hash + this.level;
|
|
||||||
hash = 59 * hash + (int) (this.experience ^ (this.experience >>> 32));
|
|
||||||
return hash;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean equals(Object obj)
|
|
||||||
{
|
|
||||||
if (this == obj)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (obj == null)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (getClass() != obj.getClass())
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
final Skill other = (Skill) obj;
|
|
||||||
if (this.rank != other.rank)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.level != other.level)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (this.experience != other.experience)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return "Skill{" + "rank=" + rank + ", level=" + level + ", experience=" + experience + '}';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.api.xp;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.EqualsAndHashCode;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
@EqualsAndHashCode(exclude = "time")
|
|
||||||
public class XpData
|
|
||||||
{
|
|
||||||
private Instant time;
|
|
||||||
|
|
||||||
private int attack_xp;
|
|
||||||
private int defence_xp;
|
|
||||||
private int strength_xp;
|
|
||||||
private int hitpoints_xp;
|
|
||||||
private int ranged_xp;
|
|
||||||
private int prayer_xp;
|
|
||||||
private int magic_xp;
|
|
||||||
private int cooking_xp;
|
|
||||||
private int woodcutting_xp;
|
|
||||||
private int fletching_xp;
|
|
||||||
private int fishing_xp;
|
|
||||||
private int firemaking_xp;
|
|
||||||
private int crafting_xp;
|
|
||||||
private int smithing_xp;
|
|
||||||
private int mining_xp;
|
|
||||||
private int herblore_xp;
|
|
||||||
private int agility_xp;
|
|
||||||
private int thieving_xp;
|
|
||||||
private int slayer_xp;
|
|
||||||
private int farming_xp;
|
|
||||||
private int runecraft_xp;
|
|
||||||
private int hunter_xp;
|
|
||||||
private int construction_xp;
|
|
||||||
|
|
||||||
private int overall_rank;
|
|
||||||
private int attack_rank;
|
|
||||||
private int defence_rank;
|
|
||||||
private int strength_rank;
|
|
||||||
private int hitpoints_rank;
|
|
||||||
private int ranged_rank;
|
|
||||||
private int prayer_rank;
|
|
||||||
private int magic_rank;
|
|
||||||
private int cooking_rank;
|
|
||||||
private int woodcutting_rank;
|
|
||||||
private int fletching_rank;
|
|
||||||
private int fishing_rank;
|
|
||||||
private int firemaking_rank;
|
|
||||||
private int crafting_rank;
|
|
||||||
private int smithing_rank;
|
|
||||||
private int mining_rank;
|
|
||||||
private int herblore_rank;
|
|
||||||
private int agility_rank;
|
|
||||||
private int thieving_rank;
|
|
||||||
private int slayer_rank;
|
|
||||||
private int farming_rank;
|
|
||||||
private int runecraft_rank;
|
|
||||||
private int hunter_rank;
|
|
||||||
private int construction_rank;
|
|
||||||
}
|
|
||||||
@@ -37,7 +37,6 @@
|
|||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
|
<spring.boot.version>1.5.6.RELEASE</spring.boot.version>
|
||||||
<mapstruct.version>1.4.2.Final</mapstruct.version>
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@@ -60,11 +59,6 @@
|
|||||||
<artifactId>spring-jdbc</artifactId>
|
<artifactId>spring-jdbc</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.mapstruct</groupId>
|
|
||||||
<artifactId>mapstruct</artifactId>
|
|
||||||
<version>${mapstruct.version}</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
@@ -163,31 +157,6 @@
|
|||||||
<finalName>runelite-${project.version}</finalName>
|
<finalName>runelite-${project.version}</finalName>
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<configuration>
|
|
||||||
<source>1.8</source> <!-- required for mapstruct -->
|
|
||||||
<target>1.8</target> <!-- required for mapstruct -->
|
|
||||||
<annotationProcessorPaths>
|
|
||||||
<path>
|
|
||||||
<groupId>org.mapstruct</groupId>
|
|
||||||
<artifactId>mapstruct-processor</artifactId>
|
|
||||||
<version>${mapstruct.version}</version>
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok-mapstruct-binding</artifactId>
|
|
||||||
<version>0.2.0</version>
|
|
||||||
</path>
|
|
||||||
<path>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>${lombok.version}</version>
|
|
||||||
</path>
|
|
||||||
</annotationProcessorPaths>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-war-plugin</artifactId>
|
<artifactId>maven-war-plugin</artifactId>
|
||||||
|
|||||||
@@ -118,13 +118,6 @@ public class SpringBootWebApplication extends SpringBootServletInitializer
|
|||||||
return new DataSourceProperties();
|
return new DataSourceProperties();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigurationProperties(prefix = "datasource.runelite-tracker")
|
|
||||||
@Bean("dataSourceRuneLiteTracker")
|
|
||||||
public DataSourceProperties dataSourcePropertiesTracker()
|
|
||||||
{
|
|
||||||
return new DataSourceProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(value = "runelite", destroyMethod = "")
|
@Bean(value = "runelite", destroyMethod = "")
|
||||||
public DataSource runeliteDataSource(@Qualifier("dataSourceRuneLite") DataSourceProperties dataSourceProperties)
|
public DataSource runeliteDataSource(@Qualifier("dataSourceRuneLite") DataSourceProperties dataSourceProperties)
|
||||||
{
|
{
|
||||||
@@ -137,12 +130,6 @@ public class SpringBootWebApplication extends SpringBootServletInitializer
|
|||||||
return getDataSource(dataSourceProperties);
|
return getDataSource(dataSourceProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean(value = "runelite-tracker", destroyMethod = "")
|
|
||||||
public DataSource runeliteTrackerDataSource(@Qualifier("dataSourceRuneLiteTracker") DataSourceProperties dataSourceProperties)
|
|
||||||
{
|
|
||||||
return getDataSource(dataSourceProperties);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean("Runelite SQL2O")
|
@Bean("Runelite SQL2O")
|
||||||
public Sql2o sql2o(@Qualifier("runelite") DataSource dataSource)
|
public Sql2o sql2o(@Qualifier("runelite") DataSource dataSource)
|
||||||
{
|
{
|
||||||
@@ -155,12 +142,6 @@ public class SpringBootWebApplication extends SpringBootServletInitializer
|
|||||||
return createSql2oFromDataSource(dataSource);
|
return createSql2oFromDataSource(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean("Runelite XP Tracker SQL2O")
|
|
||||||
public Sql2o trackerSql2o(@Qualifier("runelite-tracker") DataSource dataSource)
|
|
||||||
{
|
|
||||||
return createSql2oFromDataSource(dataSource);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean(destroyMethod = "")
|
@Bean(destroyMethod = "")
|
||||||
public MongoClient mongoClient(@Value("${mongo.host:}") String host, @Value("${mongo.jndiName:}") String jndiName) throws NamingException
|
public MongoClient mongoClient(@Value("${mongo.host:}") String host, @Value("${mongo.jndiName:}") String jndiName) throws NamingException
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.hiscore;
|
|
||||||
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
|
||||||
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
|
||||||
import net.runelite.http.service.util.HiscoreEndpointEditor;
|
|
||||||
import net.runelite.http.service.xp.XpTrackerService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.WebDataBinder;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.InitBinder;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/hiscore")
|
|
||||||
public class HiscoreController
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private HiscoreService hiscoreService;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private XpTrackerService xpTrackerService;
|
|
||||||
|
|
||||||
@GetMapping("/{endpoint}")
|
|
||||||
public HiscoreResult lookup(@PathVariable HiscoreEndpoint endpoint, @RequestParam String username) throws ExecutionException
|
|
||||||
{
|
|
||||||
HiscoreResult result = hiscoreService.lookupUsername(username, endpoint);
|
|
||||||
|
|
||||||
// Submit to xp tracker?
|
|
||||||
switch (endpoint)
|
|
||||||
{
|
|
||||||
case NORMAL:
|
|
||||||
case IRONMAN:
|
|
||||||
case ULTIMATE_IRONMAN:
|
|
||||||
case HARDCORE_IRONMAN:
|
|
||||||
xpTrackerService.update(username, result);
|
|
||||||
}
|
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/{endpoint}/{skillName}")
|
|
||||||
public SingleHiscoreSkillResult singleSkillLookup(@PathVariable HiscoreEndpoint endpoint, @PathVariable String skillName, @RequestParam String username) throws ExecutionException
|
|
||||||
{
|
|
||||||
HiscoreSkill skill = HiscoreSkill.valueOf(skillName.toUpperCase());
|
|
||||||
|
|
||||||
// RS api only supports looking up all stats
|
|
||||||
HiscoreResult result = hiscoreService.lookupUsername(username, endpoint);
|
|
||||||
|
|
||||||
// Find the skill to return
|
|
||||||
Skill requested = result.getSkill(skill);
|
|
||||||
|
|
||||||
SingleHiscoreSkillResult skillResult = new SingleHiscoreSkillResult();
|
|
||||||
skillResult.setPlayer(username);
|
|
||||||
skillResult.setSkillName(skillName);
|
|
||||||
skillResult.setSkill(requested);
|
|
||||||
|
|
||||||
return skillResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
@InitBinder
|
|
||||||
public void initBinder(WebDataBinder binder)
|
|
||||||
{
|
|
||||||
binder.registerCustomEditor(HiscoreEndpoint.class, new HiscoreEndpointEditor());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,36 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.hiscore;
|
|
||||||
|
|
||||||
import lombok.Value;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
|
|
||||||
@Value
|
|
||||||
class HiscoreKey
|
|
||||||
{
|
|
||||||
String username;
|
|
||||||
HiscoreEndpoint endpoint;
|
|
||||||
}
|
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.hiscore;
|
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
|
||||||
import com.google.common.cache.CacheLoader;
|
|
||||||
import com.google.common.cache.LoadingCache;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import okhttp3.HttpUrl;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
public class HiscoreService
|
|
||||||
{
|
|
||||||
private final HiscoreClient hiscoreClient = new HiscoreClient(RuneLiteAPI.CLIENT);
|
|
||||||
private final LoadingCache<HiscoreKey, HiscoreResult> hiscoreCache = CacheBuilder.newBuilder()
|
|
||||||
.maximumSize(128)
|
|
||||||
.expireAfterWrite(1, TimeUnit.MINUTES)
|
|
||||||
.build(
|
|
||||||
new CacheLoader<HiscoreKey, HiscoreResult>()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public HiscoreResult load(HiscoreKey key) throws IOException
|
|
||||||
{
|
|
||||||
return hiscoreClient.lookup(key.getUsername(), key.getEndpoint());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
@VisibleForTesting
|
|
||||||
HiscoreResult lookupUsername(String username, HttpUrl httpUrl) throws IOException
|
|
||||||
{
|
|
||||||
return hiscoreClient.lookup(username, httpUrl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public HiscoreResult lookupUsername(String username, HiscoreEndpoint endpoint) throws ExecutionException
|
|
||||||
{
|
|
||||||
return hiscoreCache.get(new HiscoreKey(username, endpoint));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package net.runelite.http.service.util;
|
|
||||||
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
|
|
||||||
import java.beans.PropertyEditorSupport;
|
|
||||||
|
|
||||||
public class HiscoreEndpointEditor extends PropertyEditorSupport
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void setAsText(String text) throws IllegalArgumentException
|
|
||||||
{
|
|
||||||
setValue(HiscoreEndpoint.valueOf(text.toUpperCase()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.xp;
|
|
||||||
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import net.runelite.http.api.xp.XpData;
|
|
||||||
import net.runelite.http.service.xp.beans.XpEntity;
|
|
||||||
import org.mapstruct.Mapper;
|
|
||||||
import org.mapstruct.Mapping;
|
|
||||||
import org.mapstruct.factory.Mappers;
|
|
||||||
|
|
||||||
@Mapper
|
|
||||||
public interface XpMapper
|
|
||||||
{
|
|
||||||
XpMapper INSTANCE = Mappers.getMapper(XpMapper.class);
|
|
||||||
|
|
||||||
XpData xpEntityToXpData(XpEntity xpEntity);
|
|
||||||
|
|
||||||
@Mapping(target = "time", ignore = true)
|
|
||||||
|
|
||||||
@Mapping(source = "attack.experience", target = "attack_xp")
|
|
||||||
@Mapping(source = "defence.experience", target = "defence_xp")
|
|
||||||
@Mapping(source = "strength.experience", target = "strength_xp")
|
|
||||||
@Mapping(source = "hitpoints.experience", target = "hitpoints_xp")
|
|
||||||
@Mapping(source = "ranged.experience", target = "ranged_xp")
|
|
||||||
@Mapping(source = "prayer.experience", target = "prayer_xp")
|
|
||||||
@Mapping(source = "magic.experience", target = "magic_xp")
|
|
||||||
@Mapping(source = "cooking.experience", target = "cooking_xp")
|
|
||||||
@Mapping(source = "woodcutting.experience", target = "woodcutting_xp")
|
|
||||||
@Mapping(source = "fletching.experience", target = "fletching_xp")
|
|
||||||
@Mapping(source = "fishing.experience", target = "fishing_xp")
|
|
||||||
@Mapping(source = "firemaking.experience", target = "firemaking_xp")
|
|
||||||
@Mapping(source = "crafting.experience", target = "crafting_xp")
|
|
||||||
@Mapping(source = "smithing.experience", target = "smithing_xp")
|
|
||||||
@Mapping(source = "mining.experience", target = "mining_xp")
|
|
||||||
@Mapping(source = "herblore.experience", target = "herblore_xp")
|
|
||||||
@Mapping(source = "agility.experience", target = "agility_xp")
|
|
||||||
@Mapping(source = "thieving.experience", target = "thieving_xp")
|
|
||||||
@Mapping(source = "slayer.experience", target = "slayer_xp")
|
|
||||||
@Mapping(source = "farming.experience", target = "farming_xp")
|
|
||||||
@Mapping(source = "runecraft.experience", target = "runecraft_xp")
|
|
||||||
@Mapping(source = "hunter.experience", target = "hunter_xp")
|
|
||||||
@Mapping(source = "construction.experience", target = "construction_xp")
|
|
||||||
|
|
||||||
@Mapping(source = "overall.rank", target = "overall_rank")
|
|
||||||
@Mapping(source = "attack.rank", target = "attack_rank")
|
|
||||||
@Mapping(source = "defence.rank", target = "defence_rank")
|
|
||||||
@Mapping(source = "strength.rank", target = "strength_rank")
|
|
||||||
@Mapping(source = "hitpoints.rank", target = "hitpoints_rank")
|
|
||||||
@Mapping(source = "ranged.rank", target = "ranged_rank")
|
|
||||||
@Mapping(source = "prayer.rank", target = "prayer_rank")
|
|
||||||
@Mapping(source = "magic.rank", target = "magic_rank")
|
|
||||||
@Mapping(source = "cooking.rank", target = "cooking_rank")
|
|
||||||
@Mapping(source = "woodcutting.rank", target = "woodcutting_rank")
|
|
||||||
@Mapping(source = "fletching.rank", target = "fletching_rank")
|
|
||||||
@Mapping(source = "fishing.rank", target = "fishing_rank")
|
|
||||||
@Mapping(source = "firemaking.rank", target = "firemaking_rank")
|
|
||||||
@Mapping(source = "crafting.rank", target = "crafting_rank")
|
|
||||||
@Mapping(source = "smithing.rank", target = "smithing_rank")
|
|
||||||
@Mapping(source = "mining.rank", target = "mining_rank")
|
|
||||||
@Mapping(source = "herblore.rank", target = "herblore_rank")
|
|
||||||
@Mapping(source = "agility.rank", target = "agility_rank")
|
|
||||||
@Mapping(source = "thieving.rank", target = "thieving_rank")
|
|
||||||
@Mapping(source = "slayer.rank", target = "slayer_rank")
|
|
||||||
@Mapping(source = "farming.rank", target = "farming_rank")
|
|
||||||
@Mapping(source = "runecraft.rank", target = "runecraft_rank")
|
|
||||||
@Mapping(source = "hunter.rank", target = "hunter_rank")
|
|
||||||
@Mapping(source = "construction.rank", target = "construction_rank")
|
|
||||||
XpData hiscoreResultToXpData(HiscoreResult hiscoreResult);
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.xp;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import net.runelite.http.api.xp.XpData;
|
|
||||||
import net.runelite.http.service.xp.beans.XpEntity;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
|
||||||
import org.springframework.web.bind.annotation.RequestParam;
|
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
|
||||||
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/xp")
|
|
||||||
public class XpTrackerController
|
|
||||||
{
|
|
||||||
@Autowired
|
|
||||||
private XpTrackerService xpTrackerService;
|
|
||||||
|
|
||||||
@GetMapping("/update")
|
|
||||||
public void update(@RequestParam String username)
|
|
||||||
{
|
|
||||||
xpTrackerService.tryUpdate(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
@GetMapping("/get")
|
|
||||||
public XpData get(@RequestParam String username, @RequestParam(required = false) Instant time)
|
|
||||||
{
|
|
||||||
if (time == null)
|
|
||||||
{
|
|
||||||
time = Instant.now();
|
|
||||||
}
|
|
||||||
XpEntity xpEntity = xpTrackerService.findXpAtTime(username, time);
|
|
||||||
return XpMapper.INSTANCE.xpEntityToXpData(xpEntity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,307 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.xp;
|
|
||||||
|
|
||||||
import com.google.common.hash.BloomFilter;
|
|
||||||
import com.google.common.hash.Funnels;
|
|
||||||
import java.nio.charset.Charset;
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
|
||||||
import java.util.ArrayDeque;
|
|
||||||
import java.util.Queue;
|
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import net.runelite.http.api.xp.XpData;
|
|
||||||
import net.runelite.http.service.hiscore.HiscoreService;
|
|
||||||
import net.runelite.http.service.xp.beans.PlayerEntity;
|
|
||||||
import net.runelite.http.service.xp.beans.XpEntity;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
|
||||||
import org.springframework.scheduling.annotation.Scheduled;
|
|
||||||
import org.springframework.stereotype.Service;
|
|
||||||
import org.sql2o.Connection;
|
|
||||||
import org.sql2o.Sql2o;
|
|
||||||
|
|
||||||
@Service
|
|
||||||
@Slf4j
|
|
||||||
public class XpTrackerService
|
|
||||||
{
|
|
||||||
private static final int QUEUE_LIMIT = 32768;
|
|
||||||
private static final int BLOOMFILTER_EXPECTED_INSERTIONS = 100_000;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
@Qualifier("Runelite XP Tracker SQL2O")
|
|
||||||
private Sql2o sql2o;
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private HiscoreService hiscoreService;
|
|
||||||
|
|
||||||
private final Queue<String> usernameUpdateQueue = new ArrayDeque<>();
|
|
||||||
private BloomFilter<String> usernameFilter = createFilter();
|
|
||||||
|
|
||||||
public void update(String username) throws ExecutionException
|
|
||||||
{
|
|
||||||
HiscoreResult hiscoreResult = hiscoreService.lookupUsername(username, HiscoreEndpoint.NORMAL);
|
|
||||||
update(username, hiscoreResult);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void tryUpdate(String username)
|
|
||||||
{
|
|
||||||
if (usernameFilter.mightContain(username))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try (Connection con = sql2o.open())
|
|
||||||
{
|
|
||||||
PlayerEntity playerEntity = findOrCreatePlayer(con, username);
|
|
||||||
Duration frequency = updateFrequency(playerEntity);
|
|
||||||
Instant now = Instant.now();
|
|
||||||
Duration timeSinceLastUpdate = Duration.between(playerEntity.getLast_updated(), now);
|
|
||||||
if (timeSinceLastUpdate.toMillis() < frequency.toMillis())
|
|
||||||
{
|
|
||||||
log.debug("User {} updated too recently", username);
|
|
||||||
usernameFilter.put(username);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
synchronized (usernameUpdateQueue)
|
|
||||||
{
|
|
||||||
if (usernameUpdateQueue.size() >= QUEUE_LIMIT)
|
|
||||||
{
|
|
||||||
log.warn("Username update queue is full ({})", QUEUE_LIMIT);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
usernameUpdateQueue.add(username);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
usernameFilter.put(username);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void update(String username, HiscoreResult hiscoreResult)
|
|
||||||
{
|
|
||||||
try (Connection con = sql2o.open())
|
|
||||||
{
|
|
||||||
PlayerEntity playerEntity = findOrCreatePlayer(con, username);
|
|
||||||
|
|
||||||
Instant now = Instant.now();
|
|
||||||
XpEntity currentXp = findXpAtTime(con, username, now);
|
|
||||||
if (currentXp != null)
|
|
||||||
{
|
|
||||||
XpData hiscoreData = XpMapper.INSTANCE.hiscoreResultToXpData(hiscoreResult);
|
|
||||||
XpData existingData = XpMapper.INSTANCE.xpEntityToXpData(currentXp);
|
|
||||||
|
|
||||||
if (hiscoreData.equals(existingData))
|
|
||||||
{
|
|
||||||
log.debug("Hiscore for {} already up to date", username);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
con.createQuery("insert into xp (player,attack_xp,defence_xp,strength_xp,hitpoints_xp,ranged_xp,prayer_xp,magic_xp,cooking_xp,woodcutting_xp,"
|
|
||||||
+ "fletching_xp,fishing_xp,firemaking_xp,crafting_xp,smithing_xp,mining_xp,herblore_xp,agility_xp,thieving_xp,slayer_xp,farming_xp,"
|
|
||||||
+ "runecraft_xp,hunter_xp,construction_xp,attack_rank,defence_rank,strength_rank,hitpoints_rank,ranged_rank,prayer_rank,magic_rank,"
|
|
||||||
+ "cooking_rank,woodcutting_rank,fletching_rank,fishing_rank,firemaking_rank,crafting_rank,smithing_rank,mining_rank,herblore_rank,"
|
|
||||||
+ "agility_rank,thieving_rank,slayer_rank,farming_rank,runecraft_rank,hunter_rank,construction_rank,overall_rank) values (:player,:attack_xp,:defence_xp,"
|
|
||||||
+ ":strength_xp,:hitpoints_xp,:ranged_xp,:prayer_xp,:magic_xp,:cooking_xp,:woodcutting_xp,:fletching_xp,:fishing_xp,:firemaking_xp,"
|
|
||||||
+ ":crafting_xp,:smithing_xp,:mining_xp,:herblore_xp,:agility_xp,:thieving_xp,:slayer_xp,:farming_xp,:runecraft_xp,:hunter_xp,"
|
|
||||||
+ ":construction_xp,:attack_rank,:defence_rank,:strength_rank,:hitpoints_rank,:ranged_rank,:prayer_rank,:magic_rank,:cooking_rank,"
|
|
||||||
+ ":woodcutting_rank,:fletching_rank,:fishing_rank,:firemaking_rank,:crafting_rank,:smithing_rank,:mining_rank,:herblore_rank,"
|
|
||||||
+ ":agility_rank,:thieving_rank,:slayer_rank,:farming_rank,:runecraft_rank,:hunter_rank,:construction_rank,:overall_rank)")
|
|
||||||
.addParameter("player", playerEntity.getId())
|
|
||||||
.addParameter("attack_xp", hiscoreResult.getAttack().getExperience())
|
|
||||||
.addParameter("defence_xp", hiscoreResult.getDefence().getExperience())
|
|
||||||
.addParameter("strength_xp", hiscoreResult.getStrength().getExperience())
|
|
||||||
.addParameter("hitpoints_xp", hiscoreResult.getHitpoints().getExperience())
|
|
||||||
.addParameter("ranged_xp", hiscoreResult.getRanged().getExperience())
|
|
||||||
.addParameter("prayer_xp", hiscoreResult.getPrayer().getExperience())
|
|
||||||
.addParameter("magic_xp", hiscoreResult.getMagic().getExperience())
|
|
||||||
.addParameter("cooking_xp", hiscoreResult.getCooking().getExperience())
|
|
||||||
.addParameter("woodcutting_xp", hiscoreResult.getWoodcutting().getExperience())
|
|
||||||
.addParameter("fletching_xp", hiscoreResult.getFletching().getExperience())
|
|
||||||
.addParameter("fishing_xp", hiscoreResult.getFishing().getExperience())
|
|
||||||
.addParameter("firemaking_xp", hiscoreResult.getFiremaking().getExperience())
|
|
||||||
.addParameter("crafting_xp", hiscoreResult.getCrafting().getExperience())
|
|
||||||
.addParameter("smithing_xp", hiscoreResult.getSmithing().getExperience())
|
|
||||||
.addParameter("mining_xp", hiscoreResult.getMining().getExperience())
|
|
||||||
.addParameter("herblore_xp", hiscoreResult.getHerblore().getExperience())
|
|
||||||
.addParameter("agility_xp", hiscoreResult.getAgility().getExperience())
|
|
||||||
.addParameter("thieving_xp", hiscoreResult.getThieving().getExperience())
|
|
||||||
.addParameter("slayer_xp", hiscoreResult.getSlayer().getExperience())
|
|
||||||
.addParameter("farming_xp", hiscoreResult.getFarming().getExperience())
|
|
||||||
.addParameter("runecraft_xp", hiscoreResult.getRunecraft().getExperience())
|
|
||||||
.addParameter("hunter_xp", hiscoreResult.getHunter().getExperience())
|
|
||||||
.addParameter("construction_xp", hiscoreResult.getConstruction().getExperience())
|
|
||||||
.addParameter("attack_rank", hiscoreResult.getAttack().getRank())
|
|
||||||
.addParameter("defence_rank", hiscoreResult.getDefence().getRank())
|
|
||||||
.addParameter("strength_rank", hiscoreResult.getStrength().getRank())
|
|
||||||
.addParameter("hitpoints_rank", hiscoreResult.getHitpoints().getRank())
|
|
||||||
.addParameter("ranged_rank", hiscoreResult.getRanged().getRank())
|
|
||||||
.addParameter("prayer_rank", hiscoreResult.getPrayer().getRank())
|
|
||||||
.addParameter("magic_rank", hiscoreResult.getMagic().getRank())
|
|
||||||
.addParameter("cooking_rank", hiscoreResult.getCooking().getRank())
|
|
||||||
.addParameter("woodcutting_rank", hiscoreResult.getWoodcutting().getRank())
|
|
||||||
.addParameter("fletching_rank", hiscoreResult.getFletching().getRank())
|
|
||||||
.addParameter("fishing_rank", hiscoreResult.getFishing().getRank())
|
|
||||||
.addParameter("firemaking_rank", hiscoreResult.getFiremaking().getRank())
|
|
||||||
.addParameter("crafting_rank", hiscoreResult.getCrafting().getRank())
|
|
||||||
.addParameter("smithing_rank", hiscoreResult.getSmithing().getRank())
|
|
||||||
.addParameter("mining_rank", hiscoreResult.getMining().getRank())
|
|
||||||
.addParameter("herblore_rank", hiscoreResult.getHerblore().getRank())
|
|
||||||
.addParameter("agility_rank", hiscoreResult.getAgility().getRank())
|
|
||||||
.addParameter("thieving_rank", hiscoreResult.getThieving().getRank())
|
|
||||||
.addParameter("slayer_rank", hiscoreResult.getSlayer().getRank())
|
|
||||||
.addParameter("farming_rank", hiscoreResult.getFarming().getRank())
|
|
||||||
.addParameter("runecraft_rank", hiscoreResult.getRunecraft().getRank())
|
|
||||||
.addParameter("hunter_rank", hiscoreResult.getHunter().getRank())
|
|
||||||
.addParameter("construction_rank", hiscoreResult.getConstruction().getRank())
|
|
||||||
.addParameter("overall_rank", hiscoreResult.getOverall().getRank())
|
|
||||||
.executeUpdate();
|
|
||||||
|
|
||||||
con.createQuery("update player set rank = :rank, last_updated = CURRENT_TIMESTAMP where id = :id")
|
|
||||||
.addParameter("id", playerEntity.getId())
|
|
||||||
.addParameter("rank", hiscoreResult.getOverall().getRank())
|
|
||||||
.executeUpdate();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private synchronized PlayerEntity findOrCreatePlayer(Connection con, String username)
|
|
||||||
{
|
|
||||||
PlayerEntity playerEntity = con.createQuery("select * from player where name = :name")
|
|
||||||
.addParameter("name", username)
|
|
||||||
.executeAndFetchFirst(PlayerEntity.class);
|
|
||||||
if (playerEntity != null)
|
|
||||||
{
|
|
||||||
return playerEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
Instant now = Instant.now();
|
|
||||||
|
|
||||||
int id = con.createQuery("insert into player (name, tracked_since) values (:name, :tracked_since)")
|
|
||||||
.addParameter("name", username)
|
|
||||||
.addParameter("tracked_since", now)
|
|
||||||
.executeUpdate()
|
|
||||||
.getKey(int.class);
|
|
||||||
|
|
||||||
playerEntity = new PlayerEntity();
|
|
||||||
playerEntity.setId(id);
|
|
||||||
playerEntity.setName(username);
|
|
||||||
playerEntity.setTracked_since(now);
|
|
||||||
playerEntity.setLast_updated(now);
|
|
||||||
return playerEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
private XpEntity findXpAtTime(Connection con, String username, Instant time)
|
|
||||||
{
|
|
||||||
return con.createQuery("select * from xp join player on player.id=xp.player where player.name = :username and time <= :time order by time desc limit 1")
|
|
||||||
.throwOnMappingFailure(false)
|
|
||||||
.addParameter("username", username)
|
|
||||||
.addParameter("time", time)
|
|
||||||
.executeAndFetchFirst(XpEntity.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
public XpEntity findXpAtTime(String username, Instant time)
|
|
||||||
{
|
|
||||||
try (Connection con = sql2o.open())
|
|
||||||
{
|
|
||||||
return findXpAtTime(con, username, time);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(fixedDelay = 1000)
|
|
||||||
public void update() throws ExecutionException
|
|
||||||
{
|
|
||||||
String next;
|
|
||||||
synchronized (usernameUpdateQueue)
|
|
||||||
{
|
|
||||||
next = usernameUpdateQueue.poll();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (next == null)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
update(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Scheduled(fixedDelay = 6 * 60 * 60 * 1000) // 6 hours
|
|
||||||
public void clearFilter()
|
|
||||||
{
|
|
||||||
usernameFilter = createFilter();
|
|
||||||
}
|
|
||||||
|
|
||||||
private BloomFilter<String> createFilter()
|
|
||||||
{
|
|
||||||
final BloomFilter<String> filter = BloomFilter.create(
|
|
||||||
Funnels.stringFunnel(Charset.defaultCharset()),
|
|
||||||
BLOOMFILTER_EXPECTED_INSERTIONS
|
|
||||||
);
|
|
||||||
|
|
||||||
synchronized (usernameUpdateQueue)
|
|
||||||
{
|
|
||||||
for (String toUpdate : usernameUpdateQueue)
|
|
||||||
{
|
|
||||||
filter.put(toUpdate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return filter;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* scale how often to check hiscore updates for players based on their rank
|
|
||||||
* @param playerEntity
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
private static Duration updateFrequency(PlayerEntity playerEntity)
|
|
||||||
{
|
|
||||||
Integer rank = playerEntity.getRank();
|
|
||||||
if (rank == null || rank == -1)
|
|
||||||
{
|
|
||||||
return Duration.ofDays(7);
|
|
||||||
}
|
|
||||||
else if (rank < 10_000)
|
|
||||||
{
|
|
||||||
return Duration.ofHours(6);
|
|
||||||
}
|
|
||||||
else if (rank < 50_000)
|
|
||||||
{
|
|
||||||
return Duration.ofDays(2);
|
|
||||||
}
|
|
||||||
else if (rank < 100_000)
|
|
||||||
{
|
|
||||||
return Duration.ofDays(5);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return Duration.ofDays(7);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.xp.beans;
|
|
||||||
|
|
||||||
import java.time.Instant;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
|
||||||
public class XpEntity
|
|
||||||
{
|
|
||||||
private Integer id;
|
|
||||||
private Instant time;
|
|
||||||
private Integer player;
|
|
||||||
private int overall_xp;
|
|
||||||
private int attack_xp;
|
|
||||||
private int defence_xp;
|
|
||||||
private int strength_xp;
|
|
||||||
private int hitpoints_xp;
|
|
||||||
private int ranged_xp;
|
|
||||||
private int prayer_xp;
|
|
||||||
private int magic_xp;
|
|
||||||
private int cooking_xp;
|
|
||||||
private int woodcutting_xp;
|
|
||||||
private int fletching_xp;
|
|
||||||
private int fishing_xp;
|
|
||||||
private int firemaking_xp;
|
|
||||||
private int crafting_xp;
|
|
||||||
private int smithing_xp;
|
|
||||||
private int mining_xp;
|
|
||||||
private int herblore_xp;
|
|
||||||
private int agility_xp;
|
|
||||||
private int thieving_xp;
|
|
||||||
private int slayer_xp;
|
|
||||||
private int farming_xp;
|
|
||||||
private int runecraft_xp;
|
|
||||||
private int hunter_xp;
|
|
||||||
private int construction_xp;
|
|
||||||
|
|
||||||
private int overall_rank;
|
|
||||||
private int attack_rank;
|
|
||||||
private int defence_rank;
|
|
||||||
private int strength_rank;
|
|
||||||
private int hitpoints_rank;
|
|
||||||
private int ranged_rank;
|
|
||||||
private int prayer_rank;
|
|
||||||
private int magic_rank;
|
|
||||||
private int cooking_rank;
|
|
||||||
private int woodcutting_rank;
|
|
||||||
private int fletching_rank;
|
|
||||||
private int fishing_rank;
|
|
||||||
private int firemaking_rank;
|
|
||||||
private int crafting_rank;
|
|
||||||
private int smithing_rank;
|
|
||||||
private int mining_rank;
|
|
||||||
private int herblore_rank;
|
|
||||||
private int agility_rank;
|
|
||||||
private int thieving_rank;
|
|
||||||
private int slayer_rank;
|
|
||||||
private int farming_rank;
|
|
||||||
private int runecraft_rank;
|
|
||||||
private int hunter_rank;
|
|
||||||
private int construction_rank;
|
|
||||||
}
|
|
||||||
@@ -18,13 +18,6 @@ datasource:
|
|||||||
url: jdbc:mariadb://localhost:3306/cache
|
url: jdbc:mariadb://localhost:3306/cache
|
||||||
username: runelite
|
username: runelite
|
||||||
password: runelite
|
password: runelite
|
||||||
runelite-tracker:
|
|
||||||
jndiName:
|
|
||||||
driverClassName: org.mariadb.jdbc.Driver
|
|
||||||
type: org.mariadb.jdbc.MariaDbDataSource
|
|
||||||
url: jdbc:mariadb://localhost:3306/xptracker
|
|
||||||
username: runelite
|
|
||||||
password: runelite
|
|
||||||
|
|
||||||
# Development mongo
|
# Development mongo
|
||||||
mongo:
|
mongo:
|
||||||
|
|||||||
@@ -3,8 +3,6 @@ datasource:
|
|||||||
jndiName: java:comp/env/jdbc/runelite
|
jndiName: java:comp/env/jdbc/runelite
|
||||||
runelite-cache:
|
runelite-cache:
|
||||||
jndiName: java:comp/env/jdbc/runelite-cache2
|
jndiName: java:comp/env/jdbc/runelite-cache2
|
||||||
runelite-tracker:
|
|
||||||
jndiName: java:comp/env/jdbc/runelite-tracker
|
|
||||||
|
|
||||||
# By default Spring tries to register the datasource as an MXBean,
|
# By default Spring tries to register the datasource as an MXBean,
|
||||||
# so if multiple apis are deployed on one web container with
|
# so if multiple apis are deployed on one web container with
|
||||||
|
|||||||
@@ -1,135 +0,0 @@
|
|||||||
-- MySQL dump 10.16 Distrib 10.2.18-MariaDB, for Linux (x86_64)
|
|
||||||
--
|
|
||||||
-- Host: localhost Database: xptracker
|
|
||||||
-- ------------------------------------------------------
|
|
||||||
-- Server version 10.2.18-MariaDB
|
|
||||||
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
|
||||||
/*!40101 SET NAMES utf8 */;
|
|
||||||
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
|
||||||
/*!40103 SET TIME_ZONE='+00:00' */;
|
|
||||||
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
|
||||||
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
|
||||||
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
|
||||||
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table structure for table `player`
|
|
||||||
--
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `player`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
|
||||||
CREATE TABLE `player` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`name` varchar(32) NOT NULL,
|
|
||||||
`tracked_since` timestamp NOT NULL DEFAULT current_timestamp(),
|
|
||||||
`last_updated` timestamp NOT NULL DEFAULT current_timestamp(),
|
|
||||||
`rank` int(11) DEFAULT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `name` (`name`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
|
|
||||||
--
|
|
||||||
-- Table structure for table `xp`
|
|
||||||
--
|
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `xp`;
|
|
||||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
|
||||||
/*!40101 SET character_set_client = utf8 */;
|
|
||||||
CREATE TABLE `xp` (
|
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
|
||||||
`time` timestamp NOT NULL DEFAULT current_timestamp(),
|
|
||||||
`player` int(11) NOT NULL,
|
|
||||||
`attack_xp` int(11) NOT NULL,
|
|
||||||
`defence_xp` int(11) NOT NULL,
|
|
||||||
`strength_xp` int(11) NOT NULL,
|
|
||||||
`hitpoints_xp` int(11) NOT NULL,
|
|
||||||
`ranged_xp` int(11) NOT NULL,
|
|
||||||
`prayer_xp` int(11) NOT NULL,
|
|
||||||
`magic_xp` int(11) NOT NULL,
|
|
||||||
`cooking_xp` int(11) NOT NULL,
|
|
||||||
`woodcutting_xp` int(11) NOT NULL,
|
|
||||||
`fletching_xp` int(11) NOT NULL,
|
|
||||||
`fishing_xp` int(11) NOT NULL,
|
|
||||||
`firemaking_xp` int(11) NOT NULL,
|
|
||||||
`crafting_xp` int(11) NOT NULL,
|
|
||||||
`smithing_xp` int(11) NOT NULL,
|
|
||||||
`mining_xp` int(11) NOT NULL,
|
|
||||||
`herblore_xp` int(11) NOT NULL,
|
|
||||||
`agility_xp` int(11) NOT NULL,
|
|
||||||
`thieving_xp` int(11) NOT NULL,
|
|
||||||
`slayer_xp` int(11) NOT NULL,
|
|
||||||
`farming_xp` int(11) NOT NULL,
|
|
||||||
`runecraft_xp` int(11) NOT NULL,
|
|
||||||
`hunter_xp` int(11) NOT NULL,
|
|
||||||
`construction_xp` int(11) NOT NULL,
|
|
||||||
`overall_xp` int(11) GENERATED ALWAYS AS (`attack_xp` + `defence_xp` + `strength_xp` + `hitpoints_xp` + `ranged_xp` + `prayer_xp` + `magic_xp` + `cooking_xp` + `woodcutting_xp` + `fletching_xp` + `fishing_xp` + `firemaking_xp` + `crafting_xp` + `smithing_xp` + `mining_xp` + `herblore_xp` + `agility_xp` + `thieving_xp` + `slayer_xp` + `farming_xp` + `runecraft_xp` + `hunter_xp` + `construction_xp`) VIRTUAL,
|
|
||||||
`attack_level` int(11) GENERATED ALWAYS AS (level_for_xp(`attack_xp` AS `attack_xp`)) VIRTUAL,
|
|
||||||
`defence_level` int(11) GENERATED ALWAYS AS (level_for_xp(`defence_xp` AS `defence_xp`)) VIRTUAL,
|
|
||||||
`strength_level` int(11) GENERATED ALWAYS AS (level_for_xp(`strength_xp` AS `strength_xp`)) VIRTUAL,
|
|
||||||
`hitpoints_level` int(11) GENERATED ALWAYS AS (level_for_xp(`hitpoints_xp` AS `hitpoints_xp`)) VIRTUAL,
|
|
||||||
`ranged_level` int(11) GENERATED ALWAYS AS (level_for_xp(`ranged_xp` AS `ranged_xp`)) VIRTUAL,
|
|
||||||
`prayer_level` int(11) GENERATED ALWAYS AS (level_for_xp(`prayer_xp` AS `prayer_xp`)) VIRTUAL,
|
|
||||||
`magic_level` int(11) GENERATED ALWAYS AS (level_for_xp(`magic_xp` AS `magic_xp`)) VIRTUAL,
|
|
||||||
`cooking_level` int(11) GENERATED ALWAYS AS (level_for_xp(`cooking_xp` AS `cooking_xp`)) VIRTUAL,
|
|
||||||
`woodcutting_level` int(11) GENERATED ALWAYS AS (level_for_xp(`woodcutting_xp` AS `woodcutting_xp`)) VIRTUAL,
|
|
||||||
`fletching_level` int(11) GENERATED ALWAYS AS (level_for_xp(`fletching_xp` AS `fletching_xp`)) VIRTUAL,
|
|
||||||
`fishing_level` int(11) GENERATED ALWAYS AS (level_for_xp(`fishing_xp` AS `fishing_xp`)) VIRTUAL,
|
|
||||||
`firemaking_level` int(11) GENERATED ALWAYS AS (level_for_xp(`firemaking_xp` AS `firemaking_xp`)) VIRTUAL,
|
|
||||||
`crafting_level` int(11) GENERATED ALWAYS AS (level_for_xp(`crafting_xp` AS `crafting_xp`)) VIRTUAL,
|
|
||||||
`smithing_level` int(11) GENERATED ALWAYS AS (level_for_xp(`smithing_xp` AS `smithing_xp`)) VIRTUAL,
|
|
||||||
`mining_level` int(11) GENERATED ALWAYS AS (level_for_xp(`mining_xp` AS `mining_xp`)) VIRTUAL,
|
|
||||||
`herblore_level` int(11) GENERATED ALWAYS AS (level_for_xp(`herblore_xp` AS `herblore_xp`)) VIRTUAL,
|
|
||||||
`agility_level` int(11) GENERATED ALWAYS AS (level_for_xp(`agility_xp` AS `agility_xp`)) VIRTUAL,
|
|
||||||
`thieving_level` int(11) GENERATED ALWAYS AS (level_for_xp(`thieving_xp` AS `thieving_xp`)) VIRTUAL,
|
|
||||||
`slayer_level` int(11) GENERATED ALWAYS AS (level_for_xp(`slayer_xp` AS `slayer_xp`)) VIRTUAL,
|
|
||||||
`farming_level` int(11) GENERATED ALWAYS AS (level_for_xp(`farming_xp` AS `farming_xp`)) VIRTUAL,
|
|
||||||
`runecraft_level` int(11) GENERATED ALWAYS AS (level_for_xp(`runecraft_xp` AS `runecraft_xp`)) VIRTUAL,
|
|
||||||
`hunter_level` int(11) GENERATED ALWAYS AS (level_for_xp(`hunter_xp` AS `hunter_xp`)) VIRTUAL,
|
|
||||||
`construction_level` int(11) GENERATED ALWAYS AS (level_for_xp(`construction_xp` AS `construction_xp`)) VIRTUAL,
|
|
||||||
`overall_level` int(11) GENERATED ALWAYS AS (`attack_level` + `defence_level` + `strength_level` + `hitpoints_level` + `ranged_level` + `prayer_level` + `magic_level` + `cooking_level` + `woodcutting_level` + `fletching_level` + `fishing_level` + `firemaking_level` + `crafting_level` + `smithing_level` + `mining_level` + `herblore_level` + `agility_level` + `thieving_level` + `slayer_level` + `farming_level` + `runecraft_level` + `hunter_level` + `construction_level`) VIRTUAL,
|
|
||||||
`attack_rank` int(11) NOT NULL,
|
|
||||||
`defence_rank` int(11) NOT NULL,
|
|
||||||
`strength_rank` int(11) NOT NULL,
|
|
||||||
`hitpoints_rank` int(11) NOT NULL,
|
|
||||||
`ranged_rank` int(11) NOT NULL,
|
|
||||||
`prayer_rank` int(11) NOT NULL,
|
|
||||||
`magic_rank` int(11) NOT NULL,
|
|
||||||
`cooking_rank` int(11) NOT NULL,
|
|
||||||
`woodcutting_rank` int(11) NOT NULL,
|
|
||||||
`fletching_rank` int(11) NOT NULL,
|
|
||||||
`fishing_rank` int(11) NOT NULL,
|
|
||||||
`firemaking_rank` int(11) NOT NULL,
|
|
||||||
`crafting_rank` int(11) NOT NULL,
|
|
||||||
`smithing_rank` int(11) NOT NULL,
|
|
||||||
`mining_rank` int(11) NOT NULL,
|
|
||||||
`herblore_rank` int(11) NOT NULL,
|
|
||||||
`agility_rank` int(11) NOT NULL,
|
|
||||||
`thieving_rank` int(11) NOT NULL,
|
|
||||||
`slayer_rank` int(11) NOT NULL,
|
|
||||||
`farming_rank` int(11) NOT NULL,
|
|
||||||
`runecraft_rank` int(11) NOT NULL,
|
|
||||||
`hunter_rank` int(11) NOT NULL,
|
|
||||||
`construction_rank` int(11) NOT NULL,
|
|
||||||
`overall_rank` int(11) NOT NULL,
|
|
||||||
PRIMARY KEY (`id`),
|
|
||||||
UNIQUE KEY `player_time` (`player`,`time`),
|
|
||||||
KEY `idx_time` (`time`),
|
|
||||||
CONSTRAINT `fk_player` FOREIGN KEY (`player`) REFERENCES `player` (`id`)
|
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
|
||||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
|
||||||
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
|
||||||
|
|
||||||
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
|
||||||
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
|
||||||
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
|
||||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
|
||||||
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
|
||||||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
|
||||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
|
||||||
|
|
||||||
-- Dump completed on 2019-02-15 21:01:17
|
|
||||||
@@ -1,162 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.hiscore;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import okhttp3.mockwebserver.MockResponse;
|
|
||||||
import okhttp3.mockwebserver.MockWebServer;
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Before;
|
|
||||||
import org.junit.Rule;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class HiscoreServiceTest
|
|
||||||
{
|
|
||||||
private static final String RESPONSE = "654683,705,1304518\n"
|
|
||||||
+ "679419,50,107181\n"
|
|
||||||
+ "550667,48,85764\n"
|
|
||||||
+ "861497,50,101366\n"
|
|
||||||
+ "891591,48,87843\n"
|
|
||||||
+ "-1,1,4\n"
|
|
||||||
+ "840255,27,10073\n"
|
|
||||||
+ "1371912,10,1310\n"
|
|
||||||
+ "432193,56,199795\n"
|
|
||||||
+ "495638,56,198304\n"
|
|
||||||
+ "514466,37,27502\n"
|
|
||||||
+ "456981,54,159727\n"
|
|
||||||
+ "459159,49,93010\n"
|
|
||||||
+ "1028855,8,823\n"
|
|
||||||
+ "862906,29,12749\n"
|
|
||||||
+ "795020,31,16097\n"
|
|
||||||
+ "673591,5,495\n"
|
|
||||||
+ "352676,51,112259\n"
|
|
||||||
+ "428419,40,37235\n"
|
|
||||||
+ "461887,43,51971\n"
|
|
||||||
+ "598582,1,10\n"
|
|
||||||
+ "638177,1,0\n"
|
|
||||||
+ "516239,9,1000\n"
|
|
||||||
+ "492790,1,0\n"
|
|
||||||
+ "2,2460\n" // leagues
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "73,1738\n"
|
|
||||||
+ "531,1432\n"
|
|
||||||
+ "324,212\n"
|
|
||||||
+ "8008,131\n"
|
|
||||||
+ "1337,911\n"
|
|
||||||
+ "42,14113\n"
|
|
||||||
+ "1,777\n"
|
|
||||||
+ "254,92\n"
|
|
||||||
+ "-1,-1\n" // lms
|
|
||||||
+ "1,241\n" // soul wars
|
|
||||||
+ "24870,37\n"
|
|
||||||
+ "15020,388\n"
|
|
||||||
+ "50463,147\n"
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "92357,1\n"
|
|
||||||
+ "22758,637\n"
|
|
||||||
+ "22744,107\n"
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "20150,17\n"
|
|
||||||
+ "29400,18\n"
|
|
||||||
+ "13465,172\n"
|
|
||||||
+ "1889,581\n"
|
|
||||||
+ "42891,11\n"
|
|
||||||
+ "1624,1957\n"
|
|
||||||
+ "1243,2465\n"
|
|
||||||
+ "1548,2020\n"
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "16781,327\n"
|
|
||||||
+ "19004,149\n"
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "72046,5\n"
|
|
||||||
+ "5158,374\n"
|
|
||||||
+ "20902,279\n"
|
|
||||||
+ "702,6495\n"
|
|
||||||
+ "10170,184\n"
|
|
||||||
+ "8064,202\n"
|
|
||||||
+ "6936,2\n" // Mimic
|
|
||||||
+ "1,4920\n" // Nex
|
|
||||||
+ "2335,9\n" // Nightmare
|
|
||||||
+ "2336,10\n" // Phosanis Nightmare
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "19779,22\n"
|
|
||||||
+ "58283,10\n"
|
|
||||||
+ "1234,5678\n" // Tempoross
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "-1,-1\n"
|
|
||||||
+ "-1,-1\n" // TOB
|
|
||||||
+ "42,42\n" // TOB: Hard Mode
|
|
||||||
+ "29347,130\n"
|
|
||||||
+ "723,4\n"
|
|
||||||
+ "1264,38\n"
|
|
||||||
+ "44595,4\n"
|
|
||||||
+ "24820,4\n"
|
|
||||||
+ "12116,782\n"
|
|
||||||
+ "2299,724\n"
|
|
||||||
+ "19301,62\n"
|
|
||||||
+ "1498,5847\n";
|
|
||||||
|
|
||||||
@Rule
|
|
||||||
public final MockWebServer server = new MockWebServer();
|
|
||||||
|
|
||||||
@Before
|
|
||||||
public void before() throws IOException
|
|
||||||
{
|
|
||||||
server.enqueue(new MockResponse().setBody(RESPONSE));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testNormalLookup() throws Exception
|
|
||||||
{
|
|
||||||
HiscoreTestService hiscores = new HiscoreTestService(server.url("/"));
|
|
||||||
|
|
||||||
HiscoreResult result = hiscores.lookupUsername("zezima", HiscoreEndpoint.NORMAL.getHiscoreURL());
|
|
||||||
|
|
||||||
Assert.assertEquals(50, result.getAttack().getLevel());
|
|
||||||
Assert.assertEquals(159727L, result.getFishing().getExperience());
|
|
||||||
Assert.assertEquals(492790, result.getConstruction().getRank());
|
|
||||||
Assert.assertEquals(1432, result.getClueScrollAll().getLevel());
|
|
||||||
Assert.assertEquals(324, result.getClueScrollBeginner().getRank());
|
|
||||||
Assert.assertEquals(8008, result.getClueScrollEasy().getRank());
|
|
||||||
Assert.assertEquals(911, result.getClueScrollMedium().getLevel());
|
|
||||||
Assert.assertEquals(42, result.getClueScrollHard().getRank());
|
|
||||||
Assert.assertEquals(777, result.getClueScrollElite().getLevel());
|
|
||||||
Assert.assertEquals(254, result.getClueScrollMaster().getRank());
|
|
||||||
Assert.assertEquals(-1, result.getLastManStanding().getLevel());
|
|
||||||
Assert.assertEquals(241, result.getSoulWarsZeal().getLevel());
|
|
||||||
Assert.assertEquals(2460, result.getLeaguePoints().getLevel());
|
|
||||||
Assert.assertEquals(37, result.getAbyssalSire().getLevel());
|
|
||||||
Assert.assertEquals(92357, result.getCallisto().getRank());
|
|
||||||
Assert.assertEquals(4920, result.getNex().getLevel());
|
|
||||||
Assert.assertEquals(2336, result.getPhosanisNightmare().getRank());
|
|
||||||
Assert.assertEquals(5678, result.getTempoross().getLevel());
|
|
||||||
Assert.assertEquals(42, result.getTheatreOfBloodHardMode().getLevel());
|
|
||||||
Assert.assertEquals(5847, result.getZulrah().getLevel());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,46 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2017, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
||||||
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
||||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
||||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
||||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
||||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
||||||
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.hiscore;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import okhttp3.HttpUrl;
|
|
||||||
|
|
||||||
class HiscoreTestService extends HiscoreService
|
|
||||||
{
|
|
||||||
private final HttpUrl testUrl;
|
|
||||||
|
|
||||||
HiscoreTestService(HttpUrl testUrl)
|
|
||||||
{
|
|
||||||
this.testUrl = testUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public HiscoreResult lookupUsername(String username, HttpUrl endpoint) throws IOException
|
|
||||||
{
|
|
||||||
return super.lookupUsername(username, testUrl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
|
||||||
* All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions are met:
|
|
||||||
*
|
|
||||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
|
||||||
* list of conditions and the following disclaimer.
|
|
||||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
||||||
* this list of conditions and the following disclaimer in the documentation
|
|
||||||
* and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
|
||||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
|
||||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
||||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
|
||||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
|
||||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
||||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
|
||||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
package net.runelite.http.service.xp;
|
|
||||||
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
|
||||||
import net.runelite.http.api.xp.XpData;
|
|
||||||
import net.runelite.http.service.xp.beans.XpEntity;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class XpMapperTest
|
|
||||||
{
|
|
||||||
@Test
|
|
||||||
public void testXpEntityToXpData()
|
|
||||||
{
|
|
||||||
XpEntity xpEntity = new XpEntity();
|
|
||||||
xpEntity.setAgility_rank(42);
|
|
||||||
xpEntity.setAgility_xp(9001);
|
|
||||||
|
|
||||||
XpData xpData = XpMapper.INSTANCE.xpEntityToXpData(xpEntity);
|
|
||||||
assertEquals(42, xpData.getAgility_rank());
|
|
||||||
assertEquals(9001, xpData.getAgility_xp());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testHiscoreResultToXpData()
|
|
||||||
{
|
|
||||||
HiscoreResult hiscoreResult = new HiscoreResult();
|
|
||||||
hiscoreResult.setAgility(new Skill(42, 9, 9001));
|
|
||||||
|
|
||||||
XpData xpData = XpMapper.INSTANCE.hiscoreResultToXpData(hiscoreResult);
|
|
||||||
assertEquals(42, xpData.getAgility_rank());
|
|
||||||
assertEquals(9001, xpData.getAgility_xp());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -110,6 +110,32 @@
|
|||||||
<artifactId>commons-text</artifactId>
|
<artifactId>commons-text</artifactId>
|
||||||
<version>1.2</version>
|
<version>1.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-csv</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.runelite</groupId>
|
||||||
|
<artifactId>archive-patcher</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna</artifactId>
|
||||||
|
<version>5.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.java.dev.jna</groupId>
|
||||||
|
<artifactId>jna-platform</artifactId>
|
||||||
|
<version>5.9.0</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.findbugs</groupId>
|
||||||
|
<artifactId>jsr305</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JOGL -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.runelite.jogl</groupId>
|
<groupId>net.runelite.jogl</groupId>
|
||||||
<artifactId>jogl-all</artifactId>
|
<artifactId>jogl-all</artifactId>
|
||||||
@@ -174,6 +200,8 @@
|
|||||||
<version>2.4.0-rc-20210117</version>
|
<version>2.4.0-rc-20210117</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- JOCL -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.runelite.jocl</groupId>
|
<groupId>net.runelite.jocl</groupId>
|
||||||
<artifactId>jocl</artifactId>
|
<artifactId>jocl</artifactId>
|
||||||
@@ -193,25 +221,6 @@
|
|||||||
<classifier>macos-arm64</classifier>
|
<classifier>macos-arm64</classifier>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>net.runelite</groupId>
|
|
||||||
<artifactId>archive-patcher</artifactId>
|
|
||||||
<version>1.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna</artifactId>
|
|
||||||
<version>5.9.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>net.java.dev.jna</groupId>
|
|
||||||
<artifactId>jna-platform</artifactId>
|
|
||||||
<version>5.9.0</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.google.code.findbugs</groupId>
|
|
||||||
<artifactId>jsr305</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.runelite</groupId>
|
<groupId>net.runelite</groupId>
|
||||||
|
|||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
@@ -64,28 +64,6 @@ public class HiscoreClient
|
|||||||
return lookup(username, HiscoreEndpoint.NORMAL);
|
return lookup(username, HiscoreEndpoint.NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SingleHiscoreSkillResult lookup(String username, HiscoreSkill skill, HiscoreEndpoint endpoint) throws IOException
|
|
||||||
{
|
|
||||||
HiscoreResult result = lookupSync(username, endpoint.getHiscoreURL());
|
|
||||||
|
|
||||||
if (result == null)
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Skill requested = result.getSkill(skill);
|
|
||||||
SingleHiscoreSkillResult skillResult = new SingleHiscoreSkillResult();
|
|
||||||
skillResult.setPlayer(username);
|
|
||||||
skillResult.setSkillName(skill.getName());
|
|
||||||
skillResult.setSkill(requested);
|
|
||||||
return skillResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
public SingleHiscoreSkillResult lookup(String username, HiscoreSkill skill) throws IOException
|
|
||||||
{
|
|
||||||
return lookup(username, skill, HiscoreEndpoint.NORMAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
private HiscoreResult lookupSync(String username, HttpUrl hiscoreUrl) throws IOException
|
private HiscoreResult lookupSync(String username, HttpUrl hiscoreUrl) throws IOException
|
||||||
{
|
{
|
||||||
try (Response response = client.newCall(buildRequest(username, hiscoreUrl)).execute())
|
try (Response response = client.newCall(buildRequest(username, hiscoreUrl)).execute())
|
||||||
@@ -109,7 +87,7 @@ public class HiscoreClient
|
|||||||
@Override
|
@Override
|
||||||
public void onResponse(Call call, Response response) throws IOException
|
public void onResponse(Call call, Response response) throws IOException
|
||||||
{
|
{
|
||||||
try
|
try // NOPMD: UseTryWithResources
|
||||||
{
|
{
|
||||||
future.complete(processResponse(username, response));
|
future.complete(processResponse(username, response));
|
||||||
}
|
}
|
||||||
@@ -156,9 +134,7 @@ public class HiscoreClient
|
|||||||
{
|
{
|
||||||
CSVParser parser = CSVParser.parse(responseStr, CSVFormat.DEFAULT);
|
CSVParser parser = CSVParser.parse(responseStr, CSVFormat.DEFAULT);
|
||||||
|
|
||||||
HiscoreResultBuilder hiscoreBuilder = new HiscoreResultBuilder();
|
HiscoreResultBuilder hiscoreBuilder = new HiscoreResultBuilder(username);
|
||||||
hiscoreBuilder.setPlayer(username);
|
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
for (CSVRecord record : parser.getRecords())
|
for (CSVRecord record : parser.getRecords())
|
||||||
@@ -23,8 +23,7 @@
|
|||||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
package net.runelite.client.hiscore;
|
||||||
package net.runelite.http.api.hiscore;
|
|
||||||
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import okhttp3.HttpUrl;
|
import okhttp3.HttpUrl;
|
||||||
@@ -46,6 +45,6 @@ public enum HiscoreEndpoint
|
|||||||
HiscoreEndpoint(String name, String hiscoreURL)
|
HiscoreEndpoint(String name, String hiscoreURL)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.hiscoreURL = HttpUrl.parse(hiscoreURL);
|
this.hiscoreURL = HttpUrl.get(hiscoreURL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.client.game;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import com.google.common.cache.CacheLoader;
|
import com.google.common.cache.CacheLoader;
|
||||||
import com.google.common.util.concurrent.ListenableFuture;
|
import com.google.common.util.concurrent.ListenableFuture;
|
||||||
@@ -31,11 +31,8 @@ import com.google.common.util.concurrent.MoreExecutors;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import static net.runelite.client.game.HiscoreManager.EMPTY;
|
import static net.runelite.client.hiscore.HiscoreManager.EMPTY;
|
||||||
import static net.runelite.client.game.HiscoreManager.NONE;
|
import static net.runelite.client.hiscore.HiscoreManager.NONE;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult>
|
class HiscoreLoader extends CacheLoader<HiscoreManager.HiscoreKey, HiscoreResult>
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.client.game;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
import com.google.common.cache.LoadingCache;
|
import com.google.common.cache.LoadingCache;
|
||||||
@@ -33,9 +33,6 @@ import javax.inject.Inject;
|
|||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
|
|
||||||
@Singleton
|
@Singleton
|
||||||
@@ -56,7 +53,7 @@ public class HiscoreManager
|
|||||||
private final HiscoreClient hiscoreClient;
|
private final HiscoreClient hiscoreClient;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
public HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient)
|
private HiscoreManager(ScheduledExecutorService executor, OkHttpClient okHttpClient)
|
||||||
{
|
{
|
||||||
hiscoreClient = new HiscoreClient(okHttpClient);
|
hiscoreClient = new HiscoreClient(okHttpClient);
|
||||||
hiscoreCache = CacheBuilder.newBuilder()
|
hiscoreCache = CacheBuilder.newBuilder()
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@@ -120,77 +120,77 @@ public class HiscoreResult
|
|||||||
switch (skill)
|
switch (skill)
|
||||||
{
|
{
|
||||||
case ATTACK:
|
case ATTACK:
|
||||||
return getAttack();
|
return attack;
|
||||||
case DEFENCE:
|
case DEFENCE:
|
||||||
return getDefence();
|
return defence;
|
||||||
case STRENGTH:
|
case STRENGTH:
|
||||||
return getStrength();
|
return strength;
|
||||||
case HITPOINTS:
|
case HITPOINTS:
|
||||||
return getHitpoints();
|
return hitpoints;
|
||||||
case RANGED:
|
case RANGED:
|
||||||
return getRanged();
|
return ranged;
|
||||||
case PRAYER:
|
case PRAYER:
|
||||||
return getPrayer();
|
return prayer;
|
||||||
case MAGIC:
|
case MAGIC:
|
||||||
return getMagic();
|
return magic;
|
||||||
case COOKING:
|
case COOKING:
|
||||||
return getCooking();
|
return cooking;
|
||||||
case WOODCUTTING:
|
case WOODCUTTING:
|
||||||
return getWoodcutting();
|
return woodcutting;
|
||||||
case FLETCHING:
|
case FLETCHING:
|
||||||
return getFletching();
|
return fletching;
|
||||||
case FISHING:
|
case FISHING:
|
||||||
return getFishing();
|
return fishing;
|
||||||
case FIREMAKING:
|
case FIREMAKING:
|
||||||
return getFiremaking();
|
return firemaking;
|
||||||
case CRAFTING:
|
case CRAFTING:
|
||||||
return getCrafting();
|
return crafting;
|
||||||
case SMITHING:
|
case SMITHING:
|
||||||
return getSmithing();
|
return smithing;
|
||||||
case MINING:
|
case MINING:
|
||||||
return getMining();
|
return mining;
|
||||||
case HERBLORE:
|
case HERBLORE:
|
||||||
return getHerblore();
|
return herblore;
|
||||||
case AGILITY:
|
case AGILITY:
|
||||||
return getAgility();
|
return agility;
|
||||||
case THIEVING:
|
case THIEVING:
|
||||||
return getThieving();
|
return thieving;
|
||||||
case SLAYER:
|
case SLAYER:
|
||||||
return getSlayer();
|
return slayer;
|
||||||
case FARMING:
|
case FARMING:
|
||||||
return getFarming();
|
return farming;
|
||||||
case RUNECRAFT:
|
case RUNECRAFT:
|
||||||
return getRunecraft();
|
return runecraft;
|
||||||
case HUNTER:
|
case HUNTER:
|
||||||
return getHunter();
|
return hunter;
|
||||||
case CONSTRUCTION:
|
case CONSTRUCTION:
|
||||||
return getConstruction();
|
return construction;
|
||||||
case LEAGUE_POINTS:
|
case LEAGUE_POINTS:
|
||||||
return getLeaguePoints();
|
return leaguePoints;
|
||||||
case OVERALL:
|
case OVERALL:
|
||||||
return getOverall();
|
return overall;
|
||||||
case BOUNTY_HUNTER_HUNTER:
|
case BOUNTY_HUNTER_HUNTER:
|
||||||
return getBountyHunterHunter();
|
return bountyHunterHunter;
|
||||||
case BOUNTY_HUNTER_ROGUE:
|
case BOUNTY_HUNTER_ROGUE:
|
||||||
return getBountyHunterRogue();
|
return bountyHunterRogue;
|
||||||
case CLUE_SCROLL_ALL:
|
case CLUE_SCROLL_ALL:
|
||||||
return getClueScrollAll();
|
return clueScrollAll;
|
||||||
case CLUE_SCROLL_BEGINNER:
|
case CLUE_SCROLL_BEGINNER:
|
||||||
return getClueScrollBeginner();
|
return clueScrollBeginner;
|
||||||
case CLUE_SCROLL_EASY:
|
case CLUE_SCROLL_EASY:
|
||||||
return getClueScrollEasy();
|
return clueScrollEasy;
|
||||||
case CLUE_SCROLL_MEDIUM:
|
case CLUE_SCROLL_MEDIUM:
|
||||||
return getClueScrollMedium();
|
return clueScrollMedium;
|
||||||
case CLUE_SCROLL_HARD:
|
case CLUE_SCROLL_HARD:
|
||||||
return getClueScrollHard();
|
return clueScrollHard;
|
||||||
case CLUE_SCROLL_ELITE:
|
case CLUE_SCROLL_ELITE:
|
||||||
return getClueScrollElite();
|
return clueScrollElite;
|
||||||
case CLUE_SCROLL_MASTER:
|
case CLUE_SCROLL_MASTER:
|
||||||
return getClueScrollMaster();
|
return clueScrollMaster;
|
||||||
case LAST_MAN_STANDING:
|
case LAST_MAN_STANDING:
|
||||||
return getLastManStanding();
|
return lastManStanding;
|
||||||
case SOUL_WARS_ZEAL:
|
case SOUL_WARS_ZEAL:
|
||||||
return getSoulWarsZeal();
|
return soulWarsZeal;
|
||||||
case ABYSSAL_SIRE:
|
case ABYSSAL_SIRE:
|
||||||
return abyssalSire;
|
return abyssalSire;
|
||||||
case ALCHEMICAL_HYDRA:
|
case ALCHEMICAL_HYDRA:
|
||||||
@@ -22,21 +22,18 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
class HiscoreResultBuilder
|
class HiscoreResultBuilder
|
||||||
{
|
{
|
||||||
private String player;
|
private final String player;
|
||||||
private final List<Skill> skills = new ArrayList<>();
|
private final List<Skill> skills = new ArrayList<>();
|
||||||
|
|
||||||
public void setPlayer(String player)
|
|
||||||
{
|
|
||||||
this.player = player;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setNextSkill(Skill skill)
|
void setNextSkill(Skill skill)
|
||||||
{
|
{
|
||||||
skills.add(skill);
|
skills.add(skill);
|
||||||
@@ -22,13 +22,13 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import static net.runelite.http.api.hiscore.HiscoreSkillType.SKILL;
|
import static net.runelite.client.hiscore.HiscoreSkillType.SKILL;
|
||||||
import static net.runelite.http.api.hiscore.HiscoreSkillType.ACTIVITY;
|
import static net.runelite.client.hiscore.HiscoreSkillType.ACTIVITY;
|
||||||
import static net.runelite.http.api.hiscore.HiscoreSkillType.BOSS;
|
import static net.runelite.client.hiscore.HiscoreSkillType.BOSS;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
@@ -22,7 +22,7 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.api.hiscore;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
public enum HiscoreSkillType
|
public enum HiscoreSkillType
|
||||||
{
|
{
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2018, Adam <Adam@sigterm.info>
|
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -22,17 +22,14 @@
|
|||||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
package net.runelite.http.service.xp.beans;
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
import java.time.Instant;
|
import lombok.Value;
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
@Data
|
@Value
|
||||||
public class PlayerEntity
|
public class Skill
|
||||||
{
|
{
|
||||||
private Integer id;
|
int rank;
|
||||||
private String name;
|
int level;
|
||||||
private Instant tracked_since;
|
long experience;
|
||||||
private Instant last_updated;
|
|
||||||
private Integer rank;
|
|
||||||
}
|
}
|
||||||
@@ -82,6 +82,11 @@ import net.runelite.client.config.RuneLiteConfig;
|
|||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ChatInput;
|
import net.runelite.client.events.ChatInput;
|
||||||
import net.runelite.client.game.ItemManager;
|
import net.runelite.client.game.ItemManager;
|
||||||
|
import net.runelite.client.hiscore.HiscoreClient;
|
||||||
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
|
import net.runelite.client.hiscore.HiscoreSkill;
|
||||||
|
import net.runelite.client.hiscore.Skill;
|
||||||
import net.runelite.client.input.KeyManager;
|
import net.runelite.client.input.KeyManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
@@ -90,12 +95,6 @@ import net.runelite.client.util.QuantityFormatter;
|
|||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.chat.ChatClient;
|
import net.runelite.http.api.chat.ChatClient;
|
||||||
import net.runelite.http.api.chat.Duels;
|
import net.runelite.http.api.chat.Duels;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
|
||||||
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
|
||||||
import net.runelite.http.api.item.ItemPrice;
|
import net.runelite.http.api.item.ItemPrice;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import org.apache.commons.text.WordUtils;
|
import org.apache.commons.text.WordUtils;
|
||||||
@@ -1372,16 +1371,14 @@ public class ChatCommandsPlugin extends Plugin
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final SingleHiscoreSkillResult result = hiscoreClient.lookup(lookup.getName(), skill, lookup.getEndpoint());
|
final HiscoreResult result = hiscoreClient.lookup(lookup.getName(), lookup.getEndpoint());
|
||||||
|
|
||||||
if (result == null)
|
if (result == null)
|
||||||
{
|
{
|
||||||
log.warn("unable to look up skill {} for {}: not found", skill, search);
|
log.warn("unable to look up skill {} for {}: not found", skill, search);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Skill hiscoreSkill = result.getSkill();
|
final Skill hiscoreSkill = result.getSkill(skill);
|
||||||
|
|
||||||
ChatMessageBuilder chatMessageBuilder = new ChatMessageBuilder()
|
ChatMessageBuilder chatMessageBuilder = new ChatMessageBuilder()
|
||||||
.append(ChatColorType.NORMAL)
|
.append(ChatColorType.NORMAL)
|
||||||
.append("Level ")
|
.append("Level ")
|
||||||
|
|||||||
@@ -61,13 +61,13 @@ import net.runelite.client.ui.components.materialtabs.MaterialTab;
|
|||||||
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
|
import net.runelite.client.ui.components.materialtabs.MaterialTabGroup;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.QuantityFormatter;
|
import net.runelite.client.util.QuantityFormatter;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
import net.runelite.client.hiscore.HiscoreClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
import net.runelite.client.hiscore.HiscoreSkill;
|
||||||
import static net.runelite.http.api.hiscore.HiscoreSkill.*;
|
import static net.runelite.client.hiscore.HiscoreSkill.*;
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkillType;
|
import net.runelite.client.hiscore.HiscoreSkillType;
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
import net.runelite.client.hiscore.Skill;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ import net.runelite.client.ui.ClientToolbar;
|
|||||||
import net.runelite.client.ui.NavigationButton;
|
import net.runelite.client.ui.NavigationButton;
|
||||||
import net.runelite.client.util.ImageUtil;
|
import net.runelite.client.util.ImageUtil;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "HiScore",
|
name = "HiScore",
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ import net.runelite.api.ParamID;
|
|||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.VarPlayer;
|
import net.runelite.api.VarPlayer;
|
||||||
import net.runelite.api.Varbits;
|
import net.runelite.api.Varbits;
|
||||||
import net.runelite.client.game.HiscoreManager;
|
import net.runelite.client.hiscore.HiscoreManager;
|
||||||
import net.runelite.client.game.NPCManager;
|
import net.runelite.client.game.NPCManager;
|
||||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||||
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
import net.runelite.client.ui.overlay.OverlayMenuEntry;
|
||||||
@@ -53,7 +53,7 @@ import net.runelite.client.ui.overlay.components.ComponentConstants;
|
|||||||
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
|
import net.runelite.client.ui.overlay.components.ProgressBarComponent;
|
||||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
|
|
||||||
class OpponentInfoOverlay extends OverlayPanel
|
class OpponentInfoOverlay extends OverlayPanel
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import net.runelite.client.eventbus.Subscribe;
|
|||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Opponent Information",
|
name = "Opponent Information",
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ import net.runelite.api.Client;
|
|||||||
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
import static net.runelite.api.MenuAction.RUNELITE_OVERLAY_CONFIG;
|
||||||
import net.runelite.api.Player;
|
import net.runelite.api.Player;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.client.game.HiscoreManager;
|
import net.runelite.client.hiscore.HiscoreManager;
|
||||||
import net.runelite.client.ui.overlay.Overlay;
|
import net.runelite.client.ui.overlay.Overlay;
|
||||||
import net.runelite.client.ui.overlay.OverlayLayer;
|
import net.runelite.client.ui.overlay.OverlayLayer;
|
||||||
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
import static net.runelite.client.ui.overlay.OverlayManager.OPTION_CONFIGURE;
|
||||||
@@ -44,8 +44,8 @@ import net.runelite.client.ui.overlay.components.LineComponent;
|
|||||||
import net.runelite.client.ui.overlay.components.PanelComponent;
|
import net.runelite.client.ui.overlay.components.PanelComponent;
|
||||||
import net.runelite.client.ui.overlay.components.TitleComponent;
|
import net.runelite.client.ui.overlay.components.TitleComponent;
|
||||||
import net.runelite.client.util.Text;
|
import net.runelite.client.util.Text;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
import net.runelite.client.hiscore.HiscoreSkill;
|
||||||
|
|
||||||
class PlayerComparisonOverlay extends Overlay
|
class PlayerComparisonOverlay extends Overlay
|
||||||
{
|
{
|
||||||
@@ -153,7 +153,7 @@ class PlayerComparisonOverlay extends Overlay
|
|||||||
final HiscoreSkill hiscoreSkill = HISCORE_COMBAT_SKILLS[i];
|
final HiscoreSkill hiscoreSkill = HISCORE_COMBAT_SKILLS[i];
|
||||||
final Skill skill = COMBAT_SKILLS[i];
|
final Skill skill = COMBAT_SKILLS[i];
|
||||||
|
|
||||||
final net.runelite.http.api.hiscore.Skill opponentSkill = opponentSkills.getSkill(hiscoreSkill);
|
final net.runelite.client.hiscore.Skill opponentSkill = opponentSkills.getSkill(hiscoreSkill);
|
||||||
|
|
||||||
if (opponentSkill == null || opponentSkill.getLevel() == -1)
|
if (opponentSkill == null || opponentSkill.getLevel() == -1)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -58,13 +58,13 @@ import net.runelite.api.events.GameStateChanged;
|
|||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
import net.runelite.client.events.ConfigChanged;
|
||||||
import net.runelite.client.game.HiscoreManager;
|
import net.runelite.client.hiscore.HiscoreManager;
|
||||||
import net.runelite.client.plugins.Plugin;
|
import net.runelite.client.plugins.Plugin;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.ui.overlay.OverlayManager;
|
import net.runelite.client.ui.overlay.OverlayManager;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
import net.runelite.http.api.hiscore.HiscoreResult;
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
import net.runelite.client.hiscore.Skill;
|
||||||
|
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Player-owned House",
|
name = "Player-owned House",
|
||||||
|
|||||||
@@ -0,0 +1,160 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2021, Adam <Adam@sigterm.info>
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
* list of conditions and the following disclaimer.
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
* this list of conditions and the following disclaimer in the documentation
|
||||||
|
* and/or other materials provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||||
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||||
|
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||||
|
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||||
|
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||||
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||||
|
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*/
|
||||||
|
package net.runelite.client.hiscore;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
|
import okhttp3.mockwebserver.MockResponse;
|
||||||
|
import okhttp3.mockwebserver.MockWebServer;
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class HiscoreClientTest
|
||||||
|
{
|
||||||
|
private static final String RESPONSE = "654683,705,1304518\n"
|
||||||
|
+ "679419,50,107181\n"
|
||||||
|
+ "550667,48,85764\n"
|
||||||
|
+ "861497,50,101366\n"
|
||||||
|
+ "891591,48,87843\n"
|
||||||
|
+ "-1,1,4\n"
|
||||||
|
+ "840255,27,10073\n"
|
||||||
|
+ "1371912,10,1310\n"
|
||||||
|
+ "432193,56,199795\n"
|
||||||
|
+ "495638,56,198304\n"
|
||||||
|
+ "514466,37,27502\n"
|
||||||
|
+ "456981,54,159727\n"
|
||||||
|
+ "459159,49,93010\n"
|
||||||
|
+ "1028855,8,823\n"
|
||||||
|
+ "862906,29,12749\n"
|
||||||
|
+ "795020,31,16097\n"
|
||||||
|
+ "673591,5,495\n"
|
||||||
|
+ "352676,51,112259\n"
|
||||||
|
+ "428419,40,37235\n"
|
||||||
|
+ "461887,43,51971\n"
|
||||||
|
+ "598582,1,10\n"
|
||||||
|
+ "638177,1,0\n"
|
||||||
|
+ "516239,9,1000\n"
|
||||||
|
+ "492790,1,0\n"
|
||||||
|
+ "2,2460\n" // leagues
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "73,1738\n"
|
||||||
|
+ "531,1432\n"
|
||||||
|
+ "324,212\n"
|
||||||
|
+ "8008,131\n"
|
||||||
|
+ "1337,911\n"
|
||||||
|
+ "42,14113\n"
|
||||||
|
+ "1,777\n"
|
||||||
|
+ "254,92\n"
|
||||||
|
+ "-1,-1\n" // lms
|
||||||
|
+ "1,241\n" // soul wars
|
||||||
|
+ "24870,37\n"
|
||||||
|
+ "15020,388\n"
|
||||||
|
+ "50463,147\n"
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "92357,1\n"
|
||||||
|
+ "22758,637\n"
|
||||||
|
+ "22744,107\n"
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "20150,17\n"
|
||||||
|
+ "29400,18\n"
|
||||||
|
+ "13465,172\n"
|
||||||
|
+ "1889,581\n"
|
||||||
|
+ "42891,11\n"
|
||||||
|
+ "1624,1957\n"
|
||||||
|
+ "1243,2465\n"
|
||||||
|
+ "1548,2020\n"
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "16781,327\n"
|
||||||
|
+ "19004,149\n"
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "72046,5\n"
|
||||||
|
+ "5158,374\n"
|
||||||
|
+ "20902,279\n"
|
||||||
|
+ "702,6495\n"
|
||||||
|
+ "10170,184\n"
|
||||||
|
+ "8064,202\n"
|
||||||
|
+ "6936,2\n" // Mimic
|
||||||
|
+ "1,4920\n" // Nex
|
||||||
|
+ "2335,9\n" // Nightmare
|
||||||
|
+ "2336,10\n" // Phosanis Nightmare
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "19779,22\n"
|
||||||
|
+ "58283,10\n"
|
||||||
|
+ "1234,5678\n" // Tempoross
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "-1,-1\n"
|
||||||
|
+ "-1,-1\n" // TOB
|
||||||
|
+ "42,42\n" // TOB: Hard Mode
|
||||||
|
+ "29347,130\n"
|
||||||
|
+ "723,4\n"
|
||||||
|
+ "1264,38\n"
|
||||||
|
+ "44595,4\n"
|
||||||
|
+ "24820,4\n"
|
||||||
|
+ "12116,782\n"
|
||||||
|
+ "2299,724\n"
|
||||||
|
+ "19301,62\n"
|
||||||
|
+ "1498,5847\n";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public final MockWebServer server = new MockWebServer();
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() throws IOException
|
||||||
|
{
|
||||||
|
server.enqueue(new MockResponse().setBody(RESPONSE));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testNormalLookup() throws Exception
|
||||||
|
{
|
||||||
|
HiscoreClient hiscoreClient = new HiscoreClient(RuneLiteAPI.CLIENT);
|
||||||
|
|
||||||
|
HiscoreResult result = hiscoreClient.lookup("zezima", server.url("/"));
|
||||||
|
|
||||||
|
assertEquals(50, result.getAttack().getLevel());
|
||||||
|
assertEquals(159727L, result.getFishing().getExperience());
|
||||||
|
assertEquals(492790, result.getConstruction().getRank());
|
||||||
|
assertEquals(1432, result.getClueScrollAll().getLevel());
|
||||||
|
assertEquals(324, result.getClueScrollBeginner().getRank());
|
||||||
|
assertEquals(8008, result.getClueScrollEasy().getRank());
|
||||||
|
assertEquals(911, result.getClueScrollMedium().getLevel());
|
||||||
|
assertEquals(42, result.getClueScrollHard().getRank());
|
||||||
|
assertEquals(777, result.getClueScrollElite().getLevel());
|
||||||
|
assertEquals(254, result.getClueScrollMaster().getRank());
|
||||||
|
assertEquals(-1, result.getLastManStanding().getLevel());
|
||||||
|
assertEquals(241, result.getSoulWarsZeal().getLevel());
|
||||||
|
assertEquals(2460, result.getLeaguePoints().getLevel());
|
||||||
|
assertEquals(37, result.getAbyssalSire().getLevel());
|
||||||
|
assertEquals(92357, result.getCallisto().getRank());
|
||||||
|
assertEquals(4920, result.getNex().getLevel());
|
||||||
|
assertEquals(2336, result.getPhosanisNightmare().getRank());
|
||||||
|
assertEquals(5678, result.getTempoross().getLevel());
|
||||||
|
assertEquals(42, result.getTheatreOfBloodHardMode().getLevel());
|
||||||
|
assertEquals(5847, result.getZulrah().getLevel());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -54,17 +54,19 @@ import net.runelite.client.chat.ChatMessageManager;
|
|||||||
import net.runelite.client.config.ChatColorConfig;
|
import net.runelite.client.config.ChatColorConfig;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.config.RuneLiteConfig;
|
import net.runelite.client.config.RuneLiteConfig;
|
||||||
|
import net.runelite.client.hiscore.HiscoreClient;
|
||||||
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
|
import net.runelite.client.hiscore.HiscoreResult;
|
||||||
|
import net.runelite.client.hiscore.Skill;
|
||||||
import net.runelite.http.api.RuneLiteAPI;
|
import net.runelite.http.api.RuneLiteAPI;
|
||||||
import net.runelite.http.api.chat.ChatClient;
|
import net.runelite.http.api.chat.ChatClient;
|
||||||
import net.runelite.http.api.hiscore.HiscoreClient;
|
|
||||||
import net.runelite.http.api.hiscore.HiscoreSkill;
|
|
||||||
import net.runelite.http.api.hiscore.SingleHiscoreSkillResult;
|
|
||||||
import net.runelite.http.api.hiscore.Skill;
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.ArgumentCaptor;
|
import org.mockito.ArgumentCaptor;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
|
import static org.mockito.ArgumentMatchers.nullable;
|
||||||
import org.mockito.Mock;
|
import org.mockito.Mock;
|
||||||
import static org.mockito.Mockito.any;
|
import static org.mockito.Mockito.any;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.atLeastOnce;
|
||||||
@@ -545,11 +547,11 @@ public class ChatCommandsPluginTest
|
|||||||
{
|
{
|
||||||
when(chatCommandsConfig.lvl()).thenReturn(true);
|
when(chatCommandsConfig.lvl()).thenReturn(true);
|
||||||
|
|
||||||
SingleHiscoreSkillResult skillResult = new SingleHiscoreSkillResult();
|
HiscoreResult hiscoreResult = new HiscoreResult();
|
||||||
skillResult.setPlayer(PLAYER_NAME);
|
hiscoreResult.setPlayer(PLAYER_NAME);
|
||||||
skillResult.setSkill(new Skill(10, 1000, -1));
|
hiscoreResult.setZulrah(new Skill(10, 1000, -1));
|
||||||
|
|
||||||
when(hiscoreClient.lookup(PLAYER_NAME, HiscoreSkill.ZULRAH, null)).thenReturn(skillResult);
|
when(hiscoreClient.lookup(eq(PLAYER_NAME), nullable(HiscoreEndpoint.class))).thenReturn(hiscoreResult);
|
||||||
|
|
||||||
MessageNode messageNode = mock(MessageNode.class);
|
MessageNode messageNode = mock(MessageNode.class);
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@
|
|||||||
package net.runelite.client.plugins.hiscore;
|
package net.runelite.client.plugins.hiscore;
|
||||||
|
|
||||||
import static net.runelite.client.plugins.hiscore.HiscorePanel.formatLevel;
|
import static net.runelite.client.plugins.hiscore.HiscorePanel.formatLevel;
|
||||||
import net.runelite.http.api.hiscore.HiscoreEndpoint;
|
import net.runelite.client.hiscore.HiscoreEndpoint;
|
||||||
import okhttp3.OkHttpClient;
|
import okhttp3.OkHttpClient;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|||||||
Reference in New Issue
Block a user