Skip to content

Commit

Permalink
Update to 1.0.5, fix setName and delete not updating for the client
Browse files Browse the repository at this point in the history
  • Loading branch information
MinusKube committed Jul 9, 2017
1 parent 2b332da commit 110c513
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ subprojects {
sourceCompatibility = '1.8'

group 'fr.minuskube'
version '1.0.4'
version '1.0.5'

configurations { provided }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ public BPlayerBoard createBoard(Player player, String name) {
* @return the newly created board
*/
public BPlayerBoard createBoard(Player player, Scoreboard scoreboard, String name) {
if(boards.containsKey(player))
boards.get(player).delete();
deleteBoard(player);

BPlayerBoard board = new BPlayerBoard(player, scoreboard, name);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ public BPlayerBoard(Player player, Scoreboard scoreboard, String name) {
this.buffer = this.scoreboard.registerNewObjective("bf" + subName, "dummy");

this.objective.setDisplayName(name);
sendObjectiveCreate(this.objective);
sendObjective(this.objective);
sendObjective(this.objective, ObjectiveMode.CREATE);
sendObjectiveDisplay(this.objective);

this.buffer.setDisplayName(name);
sendObjectiveCreate(this.buffer);
sendObjective(this.buffer, ObjectiveMode.CREATE);

this.player.setScoreboard(this.scoreboard);
}
Expand Down Expand Up @@ -113,32 +113,32 @@ public void set(String name, Integer score) {
}

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

Objective temp = this.buffer;

this.buffer = this.objective;
this.objective = temp;
}

private void sendObjectiveCreate(Objective obj) {
private void sendObjective(Objective obj, ObjectiveMode mode) {
try {
Object objHandle = NMS.getHandle(obj);

Object packetObj = NMS.PACKET_OBJ.newInstance(
objHandle,
0
mode.ordinal()
);

NMS.sendPacket(packetObj, player);
} catch(InstantiationException | IllegalAccessException
| InvocationTargetException | NoSuchMethodException e) {

LOGGER.error("Error while creating and sending display packet. (Unsupported Minecraft version?)", e);
LOGGER.error("Error while creating and sending objective packet. (Unsupported Minecraft version?)", e);
}
}

private void sendObjective(Objective obj) {
private void sendObjectiveDisplay(Objective obj) {
try {
Object objHandle = NMS.getHandle(obj);

Expand Down Expand Up @@ -240,6 +240,9 @@ public void delete() {

Netherboard.instance().removeBoard(player);

sendObjective(this.objective, ObjectiveMode.REMOVE);
sendObjective(this.buffer, ObjectiveMode.REMOVE);

this.objective.unregister();
this.objective = null;

Expand Down Expand Up @@ -273,6 +276,9 @@ public void setName(String name) {

this.objective.setDisplayName(name);
this.buffer.setDisplayName(name);

sendObjective(this.objective, ObjectiveMode.UPDATE);
sendObjective(this.buffer, ObjectiveMode.UPDATE);
}

public Player getPlayer() {
Expand All @@ -281,4 +287,7 @@ public Player getPlayer() {

public Scoreboard getScoreboard() { return scoreboard; }


private enum ObjectiveMode { CREATE, REMOVE, UPDATE }

}
2 changes: 1 addition & 1 deletion bukkit/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Netherboard
version: 1.0.4
version: 1.0.5
description: Scoreboard API for your Bukkit Plugins.
author: MinusKube
website: https://github.com/MinusKube/netherboard
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ public SPlayerBoard createBoard(Player player, Text name) {
* @return the newly created board
*/
public SPlayerBoard createBoard(Player player, Scoreboard scoreboard, Text name) {
if(boards.containsKey(player))
boards.get(player).delete();
deleteBoard(player);

SPlayerBoard board = new SPlayerBoard(player, scoreboard, name);

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.0.4")
version = "1.0.5")
public class NetherboardPlugin {}

0 comments on commit 110c513

Please sign in to comment.