Skip to content

Commit

Permalink
Update version to 1.2.0, add Netherboard#getBoards #15, add PlayerBoa…
Browse files Browse the repository at this point in the history
…rd#setAll and PlayerBoard#clear #18, update Gradle version
  • Loading branch information
MinusKube committed Jun 10, 2020
1 parent 01bf5b8 commit c5fc2bd
Show file tree
Hide file tree
Showing 10 changed files with 100 additions and 32 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ repositories {
}
dependencies {
compile 'fr.minuskube:netherboard-bukkit:1.1.3'
compile 'fr.minuskube:netherboard-bukkit:1.2.0'
// Or if you use Sponge:
// compile 'fr.minuskube:netherboard-sponge:1.1.3'
// compile 'fr.minuskube:netherboard-sponge:1.2.0'
}
```

Expand All @@ -89,7 +89,7 @@ dependencies {
<artifactId>netherboard-sponge</artifactId>
-->

<version>1.1.3</version>
<version>1.2.0</version>
</dependency>
```

Expand Down
28 changes: 9 additions & 19 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '1.2.4'
id 'com.github.johnrengelman.shadow' version '5.2.0'
}

subprojects {
Expand All @@ -11,25 +11,15 @@ subprojects {
sourceCompatibility = '1.8'

group 'fr.minuskube'
version '1.1.3'

configurations { provided }

sourceSets {
main.compileClasspath += configurations.provided
test.compileClasspath += configurations.provided
test.runtimeClasspath += configurations.provided
}
version '1.2.0'

repositories {
mavenCentral()
}

dependencies {
compile 'org.slf4j:slf4j-api:1.7.25'
compile 'org.slf4j:slf4j-simple:1.7.25'

testCompile 'junit:junit:4.12'
implementation 'org.slf4j:slf4j-api:1.7.25'
implementation 'org.slf4j:slf4j-simple:1.7.25'
}

task javadocJar(type: Jar) {
Expand Down Expand Up @@ -122,9 +112,9 @@ project(':bukkit') {
}

dependencies {
provided 'org.spigotmc:spigot-api:1.11.2-R0.1-SNAPSHOT'
compileOnly 'org.spigotmc:spigot-api:1.11.2-R0.1-SNAPSHOT'

compile project(':core')
implementation project(':core')
}
}

Expand All @@ -140,8 +130,8 @@ project(':sponge') {
}

dependencies {
provided 'org.spongepowered:spongeapi:5.1.0'
compileOnly 'org.spongepowered:spongeapi:5.1.0'

compile project(':core')
implementation project(':core')
}
}
}
13 changes: 12 additions & 1 deletion bukkit/src/main/java/fr/minuskube/netherboard/Netherboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class Netherboard {

private static Netherboard instance;

private Map<Player, BPlayerBoard> boards = new HashMap<>();
private final Map<Player, BPlayerBoard> boards = new HashMap<>();

private Netherboard() {}

Expand Down Expand Up @@ -80,6 +80,17 @@ public BPlayerBoard getBoard(Player player) {
return boards.get(player);
}

/**
* Gets all the boards mapped to their player.
* This returns a copy of the current boards map,
* thus modifying the given Map will not have any effect on the boards.
*
* @return a new map with all the player boards
*/
public Map<Player, BPlayerBoard> getBoards() {
return new HashMap<>(boards);
}

/**
* Returns the instance of the Netherboard class.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,26 @@ public void set(String name, Integer score) {
this.lines.put(score, name);
}

@Override
public void setAll(String... lines) {
if(this.deleted)
throw new IllegalStateException("The PlayerBoard is deleted!");

clear();

for(int i = 0; i < lines.length; i++) {
String line = lines[i];

set(line, 16 - i);
}
}

@Override
public void clear() {
this.lines.keySet().forEach(this::remove);
this.lines.clear();
}

private void swapBuffers() {
sendObjectiveDisplay(this.buffer);

Expand Down Expand Up @@ -158,7 +178,7 @@ private void sendObjectiveDisplay(Objective obj) {
}
}

@SuppressWarnings("unchecked")
@SuppressWarnings({"unchecked", "rawtypes"})
private void sendScore(Objective obj, String name, int score, boolean remove) {
try {
Object sbHandle = NMS.getHandle(scoreboard);
Expand Down
4 changes: 2 additions & 2 deletions bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Netherboard
version: 1.1.3
version: 1.2.0
description: Scoreboard API for your Bukkit Plugins.
author: MinusKube
website: https://github.com/MinusKube/netherboard
main: fr.minuskube.netherboard.bukkit.NetherboardPlugin
main: fr.minuskube.netherboard.bukkit.NetherboardPlugin
16 changes: 16 additions & 0 deletions core/src/main/java/fr/minuskube/netherboard/api/PlayerBoard.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@ public interface PlayerBoard<V, N, S> {
*/
void set(V name, N score);

/**
* Sets all the lines of the scoreboard.
* This will clear all of the current board lines, then set
* all of the given lines, from top to down, by giving them each a score
* determined by {@code 16 - index}.
*
* @param lines the new board lines
*/
@SuppressWarnings("unchecked")
void setAll(V... lines);

/**
* Clears all the lines of the scoreboard.
*/
void clear();

/**
* Removes a line from its score.
*
Expand Down
6 changes: 3 additions & 3 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Jun 19 22:38:23 CEST 2017
#Wed Jun 10 01:50:36 CEST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
13 changes: 12 additions & 1 deletion sponge/src/main/java/fr/minuskube/netherboard/Netherboard.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class Netherboard {

private static Netherboard instance;

private Map<Player, SPlayerBoard> boards = new HashMap<>();
private final Map<Player, SPlayerBoard> boards = new HashMap<>();

private Netherboard() {}

Expand Down Expand Up @@ -81,6 +81,17 @@ public SPlayerBoard getBoard(Player player) {
return boards.get(player);
}

/**
* Gets all the boards mapped to their player.
* This returns a copy of the current boards map,
* thus modifying the given Map will not have any effect on the boards.
*
* @return a new map with all the player boards
*/
public Map<Player, SPlayerBoard> getBoards() {
return new HashMap<>(boards);
}

/**
* Returns the instance of the Netherboard class.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
description = "Scoreboard API for your Sponge Plugins.",
authors = "MinusKube",
url = "https://github.com/MinusKube/netherboard",
version = "1.1.3")
public class NetherboardPlugin {}
version = "1.2.0")
public class NetherboardPlugin {}
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,26 @@ public void set(Text name, Integer score) {
this.lines.put(score, name);
}

@Override
public void setAll(Text... lines) {
if(this.deleted)
throw new IllegalStateException("The PlayerBoard is deleted!");

clear();

for(int i = 0; i < lines.length; i++) {
Text line = lines[i];

set(line, 16 - i);
}
}

@Override
public void clear() {
this.lines.keySet().forEach(this::remove);
this.lines.clear();
}

private void swapBuffers() {
this.scoreboard.updateDisplaySlot(this.buffer, DisplaySlots.SIDEBAR);

Expand Down

0 comments on commit c5fc2bd

Please sign in to comment.