Skip to content

Commit a5667ee

Browse files
author
Valandur
committed
Merge branch 'release/v4.6.1'
2 parents 9ccb054 + 0e368d6 commit a5667ee

File tree

12 files changed

+170
-20
lines changed

12 files changed

+170
-20
lines changed

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version=4.6.0
1+
version=4.6.1
22
minecraftVersion=1.11.2
33
spongeVersion=6.1

src/main/java/valandur/webapi/json/request/player/UpdatePlayerRequest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,4 +41,16 @@ public Integer getLevel() {
4141
public Integer getExperienceSinceLevel() {
4242
return experienceSinceLevel;
4343
}
44+
45+
@JsonDeserialize
46+
private Double health;
47+
public Double getHealth() {
48+
return health;
49+
}
50+
51+
@JsonDeserialize
52+
private Double maxHealth;
53+
public Double getMaxHealth() {
54+
return maxHealth;
55+
}
4456
}

src/main/java/valandur/webapi/servlet/EntityServlet.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import org.spongepowered.api.item.inventory.Inventory;
1010
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
1111
import org.spongepowered.api.util.Tuple;
12+
import org.spongepowered.api.world.Location;
1213
import org.spongepowered.api.world.World;
1314
import valandur.webapi.WebAPI;
1415
import valandur.webapi.api.annotation.WebAPIEndpoint;
@@ -67,10 +68,22 @@ public void updateEntity(ServletData data, CachedEntity entity) {
6768

6869
Entity live = (Entity)optLive.get();
6970

71+
if (req.getWorld().isPresent()) {
72+
Optional<?> optWorld = req.getWorld().get().getLive();
73+
if (!optWorld.isPresent())
74+
return null;
75+
76+
if (req.getPosition() != null) {
77+
live.transferToWorld((World)optWorld.get(), req.getPosition());
78+
} else {
79+
live.transferToWorld((World)optWorld.get());
80+
}
81+
} else if (req.getPosition() != null) {
82+
live.setLocation(new Location<World>(live.getWorld(), req.getPosition()));
83+
}
7084
if (req.getVelocity() != null) {
7185
live.setVelocity(req.getVelocity());
7286
}
73-
7487
if (req.getRotation() != null) {
7588
live.setRotation(req.getRotation());
7689
}

src/main/java/valandur/webapi/servlet/PlayerServlet.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,15 @@
33
import com.fasterxml.jackson.databind.JsonNode;
44
import org.eclipse.jetty.http.HttpMethod;
55
import org.spongepowered.api.data.manipulator.mutable.entity.ExperienceHolderData;
6+
import org.spongepowered.api.data.manipulator.mutable.entity.HealthData;
67
import org.spongepowered.api.entity.living.player.Player;
78
import org.spongepowered.api.event.cause.entity.damage.source.DamageSource;
89
import org.spongepowered.api.item.inventory.Carrier;
910
import org.spongepowered.api.item.inventory.Inventory;
1011
import org.spongepowered.api.item.inventory.ItemStackSnapshot;
1112
import org.spongepowered.api.util.Tuple;
13+
import org.spongepowered.api.world.Location;
14+
import org.spongepowered.api.world.World;
1215
import valandur.webapi.WebAPI;
1316
import valandur.webapi.api.annotation.WebAPIEndpoint;
1417
import valandur.webapi.api.annotation.WebAPIServlet;
@@ -66,10 +69,22 @@ public void updatePlayer(ServletData data, CachedPlayer player) {
6669

6770
Player live = (Player)optLive.get();
6871

72+
if (req.getWorld().isPresent()) {
73+
Optional<?> optWorld = req.getWorld().get().getLive();
74+
if (!optWorld.isPresent())
75+
return null;
76+
77+
if (req.getPosition() != null) {
78+
live.transferToWorld((World)optWorld.get(), req.getPosition());
79+
} else {
80+
live.transferToWorld((World)optWorld.get());
81+
}
82+
} else if (req.getPosition() != null) {
83+
live.setLocation(new Location<World>(live.getWorld(), req.getPosition()));
84+
}
6985
if (req.getVelocity() != null) {
7086
live.setVelocity(req.getVelocity());
7187
}
72-
7388
if (req.getRotation() != null) {
7489
live.setRotation(req.getRotation());
7590
}
@@ -98,6 +113,13 @@ public void updatePlayer(ServletData data, CachedPlayer player) {
98113
live.get(ExperienceHolderData.class).map(exp -> exp.experienceSinceLevel().set(req.getExperienceSinceLevel()));
99114
}
100115

116+
if (req.getHealth() != null) {
117+
live.get(HealthData.class).map(h -> h.health().set(req.getHealth()));
118+
}
119+
if (req.getMaxHealth() != null) {
120+
live.get(HealthData.class).map(h -> h.maxHealth().set(req.getMaxHealth()));
121+
}
122+
101123
if (req.getDamage() != null) {
102124
DamageRequest dmgReq = req.getDamage();
103125
DamageSource.Builder builder = DamageSource.builder();

src/main/resources/assets/webapi/swagger/definitions/CommandRequest.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,12 @@ properties:
1111
type: string
1212
description: The command and it's arguments that are sent to the server.
1313
waitLines:
14-
type: integer
14+
type: number
15+
format: integer
1516
description: The minimum amount of lines of text to wait for before returning the response.
1617
default: 0
1718
waitTime:
18-
type: integer
19+
type: number
20+
format: integer
1921
description: The amount of time in milliseconds to wait for response messages from the server.
2022
default: 0

src/main/resources/assets/webapi/swagger/definitions/Inventory.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,12 @@ properties:
66
type: string
77
description: The name of the inventory.
88
stackCount:
9-
type: integer
9+
type: number
10+
format: integer
1011
description: The amount of different stacks in the inventory.
1112
itemCount:
12-
type: integer
13+
type: number
14+
format: integer
1315
description: The total amount of items in the inventory.
1416
items:
1517
type: array

src/main/resources/assets/webapi/swagger/definitions/PlayerFull.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ allOf:
1818
type: string
1919
description: The address the player is connecting from
2020
latency:
21-
type: integer
21+
type: number
22+
format: integer
2223
description: The delay between the player and server
2324
armour:
2425
type: object
@@ -53,13 +54,16 @@ allOf:
5354
type: object
5455
properties:
5556
level:
56-
type: integer
57+
type: number
58+
format: integer
5759
description: The current level of the player
5860
experience:
59-
type: integer
61+
type: number
62+
format: integer
6063
description: The amount of experience SINCE THE LAST LEVEL.
6164
totalExperience:
62-
type: integer
65+
type: number
66+
format: integer
6367
description: The total amount of experience earned.
6468
gameMode:
6569
type: string

src/main/resources/assets/webapi/swagger/definitions/ServerInfo.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,16 @@ properties:
55
type: string
66
description: The message of the day set on the server.
77
players:
8-
type: integer
8+
type: number
9+
format: integer
910
description: The amount of players currently playing on the server
1011
maxPlayers:
11-
type: integer
12+
type: number
13+
format: integer
1214
description: The maximum amount of players allowed on the server
1315
uptimeTicks:
14-
type: integer
16+
type: number
17+
format: integer
1518
description: The number of ticks the server has been running
1619
tps:
1720
type: number
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
title: UpdatePlayerRequest
2+
type: object
3+
properties:
4+
world:
5+
type: string
6+
description: The UUID or name of the world that the player is moved to.
7+
position:
8+
$ref: "./Vector3.yaml"
9+
velocity:
10+
$ref: "./Vector3.yaml"
11+
rotation:
12+
$ref: "./Vector3.yaml"
13+
scale:
14+
$ref: "./Vector3.yaml"
15+
foodLevel:
16+
type: number
17+
format: integer
18+
description: The new food level of the player.
19+
exhaustion:
20+
type: number
21+
format: double
22+
description: The new exhaustion level of the player.
23+
saturation:
24+
type: number
25+
format: double
26+
description: The new saturation level of the player.
27+
totalExperience:
28+
type: number
29+
format: integer
30+
description: The total amount of experience the player has. This implicitly also sets the level.
31+
level:
32+
type: number
33+
format: integer
34+
description: The current level of the player. This is also defined by the total amount of experience the player has.
35+
experienceSinceLevel:
36+
type: number
37+
format: integer
38+
description: The amount of experience since the last level up that the player has collected.
39+
health:
40+
type: number
41+
format: double
42+
description: The current amount of health the player has.
43+
maxHealth:
44+
type: number
45+
format: double
46+
description: The total amount of health the player can have at maximum.
47+
damage:
48+
title: DamageRequest
49+
type: object
50+
properties:
51+
amount:
52+
type: number
53+
description: The amount of damage to deal to the player.
54+
type:
55+
type: string
56+
description: The type of damage being dealt. Check `/registry/org.spongepowered.api.event.cause.entity.damage`.

src/main/resources/assets/webapi/swagger/paths/block_one.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ get:
1212
required: true
1313
- name: x
1414
in: path
15-
type: integer
15+
type: string
1616
description: The x-coordinate of the block.
1717
required: true
1818
- name: y
1919
in: path
20-
type: integer
20+
type: string
2121
description: The y-coordinate of the block.
2222
required: true
2323
- name: z
2424
in: path
25-
type: integer
25+
type: string
2626
description: The z-coordinate of the block.
2727
required: true
2828
tags:

0 commit comments

Comments
 (0)