Skip to content

Commit 3f3a442

Browse files
committed
Merge master into dev/v3
1 parent 31d8f30 commit 3f3a442

26 files changed

Lines changed: 105 additions & 109 deletions

buildsystem-api/javadoc/overview.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
BuildSystem is a utility plugin targeted towards build-teams.
44
It allows worlds to be easily managed and also provides handy tools to assist with building.
55
</p>
6-
<h4>Useful Links</h4>
6+
<h1>Useful Links</h1>
77
<ul>
88
<li><a target="_top" href="https://buildsystem.eintosti.de">Project Website</a></li>
99
<li><a target="_top" href="https://github.com/thomasmny/BuildSystem">Source Code</a></li>

buildsystem-api/src/main/java/de/eintosti/buildsystem/api/world/BuildWorld.java

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -59,38 +59,21 @@ public interface BuildWorld {
5959
boolean hasCreator();
6060

6161
/**
62-
* Get the name of the player who created the world.
62+
* Get the world's creator.
6363
* <p>
64-
* In older versions of the plugin, the creator was not saved which is why {@code null} can be returned.
64+
* Must not be set.
6565
*
66-
* @return The name of the player who created the world
66+
* @return The builder who created the world, if set, otherwise {@code null}
6767
*/
6868
@Nullable
69-
String getCreator();
69+
Builder getCreator();
7070

7171
/**
72-
* Set the name of the creator.
72+
* Set the creator.
7373
*
74-
* @param creator The name of the creator
74+
* @param creator The creator
7575
*/
76-
void setCreator(String creator);
77-
78-
/**
79-
* Get the unique-id of the player who created the world.
80-
* <p>
81-
* In older versions of the plugin, the creator was not saved which is why {@code null} can be returned.
82-
*
83-
* @return The unique-id of the player who created the world
84-
*/
85-
@Nullable
86-
UUID getCreatorId();
87-
88-
/**
89-
* Set the unique-id of the creator.
90-
*
91-
* @param creatorId The unique-id of the creator
92-
*/
93-
void setCreatorId(UUID creatorId);
76+
void setCreator(Builder creator);
9477

9578
/**
9679
* Gets whether the given player is the creator of the world.

buildsystem-api/src/main/java/de/eintosti/buildsystem/api/world/Builder.java

Lines changed: 46 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,56 @@
1818
package de.eintosti.buildsystem.api.world;
1919

2020
import org.bukkit.entity.Player;
21+
import org.jetbrains.annotations.Nullable;
2122

2223
import java.util.UUID;
2324

2425
public interface Builder {
2526

27+
/**
28+
* Creates a new {@link Builder} instance with the given uuid and name.
29+
*
30+
* @param uuid The uuid
31+
* @param name The name
32+
* @return The builder
33+
*/
34+
static Builder of(UUID uuid, String name) {
35+
return new BuilderImpl(uuid, name);
36+
}
37+
38+
/**
39+
* Creates a new {@link Builder} instance using the given player.
40+
*
41+
* @param player The player
42+
* @return The builder
43+
*/
44+
static Builder of(Player player) {
45+
return of(player.getUniqueId(), player.getName());
46+
}
47+
48+
/**
49+
* Creates a new {@link Builder} instance using a serialized string.
50+
* <p>
51+
* The format of the string must be {@code <uuid>,<name>}.
52+
*
53+
* @param serialized The serialized builder
54+
* @return The builder if all the input is valid, otherwise {@code null}
55+
*/
56+
@Nullable
57+
static Builder deserialize(@Nullable String serialized) {
58+
if (serialized == null) {
59+
return null;
60+
}
61+
62+
String[] parts = serialized.split(BuilderImpl.SEPARATOR);
63+
if (parts.length != 2) {
64+
return null;
65+
}
66+
67+
return of(UUID.fromString(parts[0]), parts[1]);
68+
}
69+
70+
2671
/**
2772
* Returns a unique and persistent id for the builder.
2873
* <p>
@@ -31,7 +76,7 @@ public interface Builder {
3176
* @return The uuid
3277
* @see Player#getUniqueId()
3378
*/
34-
UUID getUuid();
79+
UUID getUniqueId();
3580

3681
/**
3782
* Gets the name of the builder.

buildsystem-core/src/main/java/de/eintosti/buildsystem/world/CraftBuilder.java renamed to buildsystem-api/src/main/java/de/eintosti/buildsystem/api/world/BuilderImpl.java

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,24 @@
1515
* You should have received a copy of the GNU General Public License
1616
* along with this program. If not, see <https://www.gnu.org/licenses/>.
1717
*/
18-
package de.eintosti.buildsystem.world;
19-
20-
import de.eintosti.buildsystem.api.world.Builder;
21-
import org.bukkit.entity.Player;
18+
package de.eintosti.buildsystem.api.world;
2219

2320
import java.util.UUID;
2421

25-
public class CraftBuilder implements Builder {
22+
final class BuilderImpl implements Builder {
23+
24+
public static final String SEPARATOR = ",";
2625

2726
private final UUID uuid;
2827
private String name;
2928

30-
public CraftBuilder(Player player) {
31-
this.uuid = player.getUniqueId();
32-
this.name = player.getName();
33-
}
34-
35-
public CraftBuilder(UUID uuid, String name) {
29+
BuilderImpl(UUID uuid, String name) {
3630
this.uuid = uuid;
3731
this.name = name;
3832
}
3933

4034
@Override
41-
public UUID getUuid() {
35+
public UUID getUniqueId() {
4236
return uuid;
4337
}
4438

@@ -54,6 +48,6 @@ public void setName(String name) {
5448

5549
@Override
5650
public String toString() {
57-
return uuid.toString() + "," + name;
51+
return uuid.toString() + SEPARATOR + name;
5852
}
5953
}

buildsystem-api/src/main/java/de/eintosti/buildsystem/api/world/WorldManager.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,12 @@ public interface WorldManager {
112112
*
113113
* @param worldName The name of the world to import
114114
* @param creator The builder who should be set as the creator
115+
* @param worldType
115116
* @param generator The generator type used by the world
116117
* @param generatorName The name of the custom generator if generator type is {@link Generator#CUSTOM}
117118
* @return {@code true} if the world was successfully imported, otherwise {@code false}
118119
*/
119-
boolean importWorld(String worldName, Builder creator, Generator generator, String generatorName);
120+
boolean importWorld(String worldName, Builder creator, WorldType worldType, Generator generator, String generatorName);
120121

121122
/**
122123
* Delete an existing {@link BuildWorld}.

buildsystem-api/src/main/java/de/eintosti/buildsystem/api/world/data/WorldType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.bukkit.World.Environment;
2121

2222
public enum WorldType {
23+
2324
/**
2425
* The equivalent to a default Minecraft world with {@link Environment#NORMAL}.
2526
*/

buildsystem-core/src/main/java/de/eintosti/buildsystem/command/SkullCommand.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package de.eintosti.buildsystem.command;
1919

2020
import com.cryptomorin.xseries.profiles.objects.Profileable;
21-
import de.eintosti.buildsystem.BuildSystem;
2221
import de.eintosti.buildsystem.BuildSystemPlugin;
2322
import de.eintosti.buildsystem.Messages;
2423
import de.eintosti.buildsystem.util.InventoryUtils;

buildsystem-core/src/main/java/de/eintosti/buildsystem/command/subcommand/worlds/AddBuilderSubCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@
2121
import de.eintosti.buildsystem.BuildSystemPlugin;
2222
import de.eintosti.buildsystem.Messages;
2323
import de.eintosti.buildsystem.api.world.BuildWorld;
24+
import de.eintosti.buildsystem.api.world.Builder;
2425
import de.eintosti.buildsystem.command.subcommand.Argument;
2526
import de.eintosti.buildsystem.command.subcommand.SubCommand;
2627
import de.eintosti.buildsystem.tabcomplete.WorldsTabComplete;
2728
import de.eintosti.buildsystem.util.PlayerChatInput;
2829
import de.eintosti.buildsystem.util.UUIDFetcher;
2930
import de.eintosti.buildsystem.world.BuildWorldManager;
30-
import de.eintosti.buildsystem.world.CraftBuilder;
3131
import org.bukkit.Bukkit;
3232
import org.bukkit.entity.Player;
3333

buildsystem-core/src/main/java/de/eintosti/buildsystem/command/subcommand/worlds/ImportAllSubCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@
1919

2020
import de.eintosti.buildsystem.BuildSystemPlugin;
2121
import de.eintosti.buildsystem.Messages;
22+
import de.eintosti.buildsystem.api.world.Builder;
2223
import de.eintosti.buildsystem.api.world.generator.Generator;
2324
import de.eintosti.buildsystem.command.subcommand.Argument;
2425
import de.eintosti.buildsystem.command.subcommand.SubCommand;
2526
import de.eintosti.buildsystem.tabcomplete.WorldsTabComplete;
2627
import de.eintosti.buildsystem.util.ArgumentParser;
2728
import de.eintosti.buildsystem.util.UUIDFetcher;
2829
import de.eintosti.buildsystem.world.BuildWorldManager;
29-
import de.eintosti.buildsystem.world.CraftBuilder;
3030
import org.bukkit.Bukkit;
3131
import org.bukkit.entity.Player;
3232

buildsystem-core/src/main/java/de/eintosti/buildsystem/command/subcommand/worlds/ImportSubCommand.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,15 @@
2020
import de.eintosti.buildsystem.BuildSystemPlugin;
2121
import de.eintosti.buildsystem.Messages;
2222
import de.eintosti.buildsystem.api.world.BuildWorld;
23+
import de.eintosti.buildsystem.api.world.Builder;
24+
import de.eintosti.buildsystem.api.world.data.WorldType;
2325
import de.eintosti.buildsystem.api.world.generator.Generator;
2426
import de.eintosti.buildsystem.command.subcommand.Argument;
2527
import de.eintosti.buildsystem.command.subcommand.SubCommand;
2628
import de.eintosti.buildsystem.tabcomplete.WorldsTabComplete;
2729
import de.eintosti.buildsystem.util.ArgumentParser;
2830
import de.eintosti.buildsystem.util.UUIDFetcher;
2931
import de.eintosti.buildsystem.world.BuildWorldManager;
30-
import de.eintosti.buildsystem.world.CraftBuilder;
31-
import de.eintosti.buildsystem.world.BuildWorld;
32-
import de.eintosti.buildsystem.world.Builder;
33-
import de.eintosti.buildsystem.world.WorldManager;
34-
import de.eintosti.buildsystem.world.data.WorldType;
35-
import de.eintosti.buildsystem.world.generator.Generator;
3632
import org.bukkit.Bukkit;
3733
import org.bukkit.entity.Player;
3834

@@ -140,7 +136,7 @@ public void execute(Player player, String[] args) {
140136
}
141137

142138
Messages.sendMessage(player, "worlds_import_started", new AbstractMap.SimpleEntry<>("%world%", worldName));
143-
if (worldManager.importWorld(player, worldName, creator, generator, generatorName, true, worldType)) {
139+
if (worldManager.importWorld(player, worldName, creator, worldType, generator, generatorName, true)) {
144140
Messages.sendMessage(player, "worlds_import_finished");
145141
}
146142
}

0 commit comments

Comments
 (0)