mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Cleanup
This commit is contained in:
parent
56cace9402
commit
6b778f425a
@ -1909,7 +1909,7 @@ public class Player extends LivingEntity implements CommandSender {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset data from the current block the player is mining.
|
* Reset data from the current block the player is mining.
|
||||||
* If the currently mined block (or if there isn't any) is not a CustomBlock, nothing append
|
* If the currently mined block (or if there isn't any) is not a {@link CustomBlock}, nothing happen
|
||||||
*/
|
*/
|
||||||
public void resetTargetBlock() {
|
public void resetTargetBlock() {
|
||||||
if (targetCustomBlock != null) {
|
if (targetCustomBlock != null) {
|
||||||
@ -1962,18 +1962,21 @@ public class Player extends LivingEntity implements CommandSender {
|
|||||||
* @return a {@link PlayerInfoPacket} to add the player
|
* @return a {@link PlayerInfoPacket} to add the player
|
||||||
*/
|
*/
|
||||||
protected PlayerInfoPacket getAddPlayerToList() {
|
protected PlayerInfoPacket getAddPlayerToList() {
|
||||||
final String textures = skin == null ? "" : skin.getTextures();
|
|
||||||
final String signature = skin == null ? null : skin.getSignature();
|
|
||||||
|
|
||||||
PlayerInfoPacket playerInfoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.ADD_PLAYER);
|
PlayerInfoPacket playerInfoPacket = new PlayerInfoPacket(PlayerInfoPacket.Action.ADD_PLAYER);
|
||||||
|
|
||||||
PlayerInfoPacket.AddPlayer addPlayer =
|
PlayerInfoPacket.AddPlayer addPlayer =
|
||||||
new PlayerInfoPacket.AddPlayer(getUuid(), getUsername(), getGameMode(), getLatency());
|
new PlayerInfoPacket.AddPlayer(getUuid(), getUsername(), getGameMode(), getLatency());
|
||||||
addPlayer.displayName = displayName;
|
addPlayer.displayName = displayName;
|
||||||
|
|
||||||
PlayerInfoPacket.AddPlayer.Property prop =
|
// Skin support
|
||||||
new PlayerInfoPacket.AddPlayer.Property("textures", textures, signature);
|
if (skin != null) {
|
||||||
addPlayer.properties.add(prop);
|
final String textures = skin.getTextures();
|
||||||
|
final String signature = skin.getSignature();
|
||||||
|
|
||||||
|
PlayerInfoPacket.AddPlayer.Property prop =
|
||||||
|
new PlayerInfoPacket.AddPlayer.Property("textures", textures, signature);
|
||||||
|
addPlayer.properties.add(prop);
|
||||||
|
}
|
||||||
|
|
||||||
playerInfoPacket.playerInfos.add(addPlayer);
|
playerInfoPacket.playerInfos.add(addPlayer);
|
||||||
return playerInfoPacket;
|
return playerInfoPacket;
|
||||||
|
@ -54,9 +54,9 @@ public class PlayerSkin {
|
|||||||
final JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
|
final JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
|
||||||
final JsonArray propertiesArray = jsonObject.get("properties").getAsJsonArray();
|
final JsonArray propertiesArray = jsonObject.get("properties").getAsJsonArray();
|
||||||
|
|
||||||
Iterator<JsonElement> iterator = propertiesArray.iterator();
|
final Iterator<JsonElement> iterator = propertiesArray.iterator();
|
||||||
while (iterator.hasNext()) {
|
while (iterator.hasNext()) {
|
||||||
JsonObject propertyObject = iterator.next().getAsJsonObject();
|
final JsonObject propertyObject = iterator.next().getAsJsonObject();
|
||||||
final String name = propertyObject.get("name").getAsString();
|
final String name = propertyObject.get("name").getAsString();
|
||||||
if (!name.equals("textures"))
|
if (!name.equals("textures"))
|
||||||
continue;
|
continue;
|
||||||
@ -82,7 +82,7 @@ public class PlayerSkin {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
final String response = URLUtils.getText(url);
|
final String response = URLUtils.getText(url);
|
||||||
JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
|
final JsonObject jsonObject = JsonParser.parseString(response).getAsJsonObject();
|
||||||
final String uuid = jsonObject.get("id").getAsString();
|
final String uuid = jsonObject.get("id").getAsString();
|
||||||
return fromUuid(uuid);
|
return fromUuid(uuid);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
@ -64,13 +64,13 @@ public class PlayerDiggingListener {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Player is not mining a custom block, be sure that he doesn't have the effect
|
// Player is not mining a custom block, be sure that he doesn't have the effect
|
||||||
removeEffect(player);
|
player.resetTargetBlock();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case CANCELLED_DIGGING:
|
case CANCELLED_DIGGING:
|
||||||
// Remove custom block target
|
// Remove custom block target
|
||||||
removeEffect(player);
|
player.resetTargetBlock();
|
||||||
|
|
||||||
sendAcknowledgePacket(player, blockPosition, blockStateId,
|
sendAcknowledgePacket(player, blockPosition, blockStateId,
|
||||||
ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING, true);
|
ClientPlayerDiggingPacket.Status.CANCELLED_DIGGING, true);
|
||||||
@ -119,7 +119,7 @@ public class PlayerDiggingListener {
|
|||||||
|
|
||||||
private static void breakBlock(Instance instance, Player player, BlockPosition blockPosition) {
|
private static void breakBlock(Instance instance, Player player, BlockPosition blockPosition) {
|
||||||
// Finished digging, remove effect if any
|
// Finished digging, remove effect if any
|
||||||
removeEffect(player);
|
player.resetTargetBlock();
|
||||||
|
|
||||||
// Unverified block break, client is fully responsive
|
// Unverified block break, client is fully responsive
|
||||||
instance.breakBlock(player, blockPosition);
|
instance.breakBlock(player, blockPosition);
|
||||||
@ -148,10 +148,6 @@ public class PlayerDiggingListener {
|
|||||||
player.getPlayerConnection().sendPacket(entityEffectPacket);
|
player.getPlayerConnection().sendPacket(entityEffectPacket);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeEffect(Player player) {
|
|
||||||
player.resetTargetBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void sendAcknowledgePacket(Player player, BlockPosition blockPosition, int blockStateId,
|
private static void sendAcknowledgePacket(Player player, BlockPosition blockPosition, int blockStateId,
|
||||||
ClientPlayerDiggingPacket.Status status, boolean success) {
|
ClientPlayerDiggingPacket.Status status, boolean success) {
|
||||||
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();
|
AcknowledgePlayerDiggingPacket acknowledgePlayerDiggingPacket = new AcknowledgePlayerDiggingPacket();
|
||||||
|
Loading…
Reference in New Issue
Block a user