Skip to content

Commit 96fc9d3

Browse files
committed
API#getProfile now fetches profile if not online
1 parent 20e1f93 commit 96fc9d3

File tree

4 files changed

+17
-10
lines changed

4 files changed

+17
-10
lines changed

Plugin/src/main/java/dev/lrxh/neptune/API.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.bukkit.entity.Player;
77

88
import java.util.UUID;
9+
import java.util.concurrent.CompletableFuture;
910

1011
public class API {
1112

@@ -17,7 +18,7 @@ public static Profile getProfile(Player player) {
1718
return ProfileService.get().getByUUID(player.getUniqueId());
1819
}
1920

20-
public static Profile getProfile(OfflinePlayer player) {
21-
return getProfile(player.getUniqueId());
21+
public static CompletableFuture<Profile> getProfile(OfflinePlayer player) {
22+
return ProfileService.get()._getProfile(player.getUniqueId());
2223
}
2324
}

Plugin/src/main/java/dev/lrxh/neptune/game/arena/menu/button/ArenaCreateButton.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import dev.lrxh.neptune.utils.CC;
88
import dev.lrxh.neptune.utils.ItemBuilder;
99
import dev.lrxh.neptune.utils.menu.Button;
10+
import org.bukkit.Location;
1011
import org.bukkit.Material;
1112
import org.bukkit.World;
1213
import org.bukkit.entity.Player;
@@ -21,12 +22,14 @@ public ArenaCreateButton(int slot) {
2122

2223
@Override
2324
public void onClick(ClickType type, Player player) {
24-
World world = Neptune.get().getCache().getSpawn().getWorld();
25-
if (world == null) {
25+
Location location = Neptune.get().getCache().getSpawn();
26+
if (location == null) {
2627
player.sendMessage(CC.error("Spawn world is not set!, use /neptune setspawn"));
2728
return;
2829
}
2930

31+
World world = location.getWorld();
32+
3033
if (player.getWorld().equals(world)) {
3134
player.sendMessage(CC.error("You cannot create an arena in the same world as the spawn!"));
3235
return;

Plugin/src/main/java/dev/lrxh/neptune/profile/ProfileService.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,7 @@ public CompletableFuture<Void> createProfile(Player player) {
3333
}
3434

3535
public CompletableFuture<Profile> createProfile(UUID uuid) {
36-
return Profile.create("username", uuid, plugin, true).thenApply(profile -> {
37-
return profile;
38-
});
36+
return Profile.create("username", uuid, plugin, true).thenApply(profile -> profile);
3937
}
4038

4139
public void removeProfile(UUID playerUUID) {
@@ -69,11 +67,13 @@ public Profile getByUUID(UUID playerUUID) {
6967

7068
@Override
7169
public CompletableFuture<IProfile> getProfile(UUID uuid) {
70+
return _getProfile(uuid).thenApply(p -> p);
71+
}
72+
73+
public CompletableFuture<Profile> _getProfile(UUID uuid) {
7274
Profile profile = getByUUID(uuid);
7375
return (profile != null)
7476
? CompletableFuture.completedFuture(profile)
75-
: createProfile(uuid).thenApply(p -> (IProfile) p);
77+
: createProfile(uuid).thenApply(p -> p);
7678
}
77-
78-
7979
}

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@
1010
---
1111

1212
## 💿 Installation
13+
1314
- Make sure you are using the latest [Paper](https://papermc.io/downloads/paper) version.
1415
- Download the latest [Github Actions](https://github.com/Solara-Development/Neptune/actions) build.
16+
1517
> [!NOTE]
1618
> A Github account may be required to download.
19+
1720
- Once downloaded, place the `.jar` file inside the `/plugins` directory on your server.
1821
- Restart your server
1922
- Then do `/neptune`

0 commit comments

Comments
 (0)