Skip to content

Commit

Permalink
Merge branch 'WiIIiam278:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
WinTone01 authored Apr 9, 2024
2 parents 930a214 + 746d0bb commit 8d178e3
Show file tree
Hide file tree
Showing 64 changed files with 652 additions and 248 deletions.
7 changes: 4 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -209,15 +209,16 @@ logger.lifecycle("Building HuskHomes ${version} by William278")

@SuppressWarnings('GrMethodMayBeStatic')
def versionMetadata() {
if (grgit == null) {
return '-' + System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown'
}

// Get if there is a tag for this commit
def tag = grgit.tag.list().find { it.commit.id == grgit.head().id }
if (tag != null) {
return ''
}

// Otherwise, get the last commit hash and if it's a clean head
if (grgit == null) {
return '-' + System.getenv("GITHUB_RUN_NUMBER") ? 'build.' + System.getenv("GITHUB_RUN_NUMBER") : 'unknown'
}
return '-' + grgit.head().abbreviatedId + (grgit.status().clean ? '' : '-indev')
}
10 changes: 5 additions & 5 deletions bukkit/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@ dependencies {

implementation 'org.bstats:bstats-bukkit:3.0.2'
implementation 'io.papermc:paperlib:1.0.8'
implementation 'space.arim.morepaperlib:morepaperlib:0.4.3'
implementation 'space.arim.morepaperlib:morepaperlib:0.4.4'
implementation 'me.lucko:commodore:2.2'
implementation 'net.kyori:adventure-platform-bukkit:4.3.2'

compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT'
compileOnly 'org.jetbrains:annotations:24.1.0'
compileOnly 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
compileOnly 'net.william278:minedown:1.8.2'
compileOnly 'net.william278:DesertWell:2.0.4'
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
compileOnly 'me.clip:placeholderapi:2.11.5'
compileOnly('net.essentialsx:EssentialsX:2.20.1') {
exclude group: 'org.spigotmc', module: 'spigot-api'
}
compileOnly 'org.projectlombok:lombok:1.18.30'
compileOnly 'org.projectlombok:lombok:1.18.32'

testImplementation 'com.github.seeseemelk:MockBukkit-v1.17:1.13.0'
testImplementation 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
testImplementation 'net.william278:minedown:1.8.2'
testImplementation 'net.kyori:adventure-platform-bukkit:4.3.2'
testImplementation 'org.apache.commons:commons-text:1.11.0'
testImplementation "redis.clients:jedis:${jedis_version}"
testImplementation "org.xerial:sqlite-jdbc:${sqlite_driver_version}"
testImplementation "com.mysql:mysql-connector-j:${mysql_driver_version}"

annotationProcessor 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
}

shadowJar {
Expand Down
18 changes: 18 additions & 0 deletions bukkit/src/main/java/net/william278/huskhomes/user/BukkitUser.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

import java.util.Map;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
import java.util.logging.Level;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -106,6 +107,23 @@ public Map<String, Boolean> getPermissions() {
));
}

@Override
public CompletableFuture<Void> dismount() {
final CompletableFuture<Void> future = new CompletableFuture<>();
((BukkitHuskHomes) plugin).getScheduler().entitySpecificScheduler(player).run(
() -> {
player.leaveVehicle();
player.eject();
future.complete(null);
},
() -> {
plugin.log(Level.WARNING, "User offline when dismounting: " + player.getName());
future.complete(null);
}
);
return future;
}

@Override
public void teleportLocally(@NotNull Location location, boolean async) throws TeleportationException {
// Ensure the world exists
Expand Down
14 changes: 7 additions & 7 deletions common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ plugins {
}

dependencies {
api 'commons-io:commons-io:2.15.1'
api 'net.william278:minedown:1.8.2'
api 'net.william278:paginedown:1.1.2'
api 'net.william278:DesertWell:2.0.4'
api 'commons-io:commons-io:2.16.0'
api 'org.apache.commons:commons-text:1.11.0'
api 'de.themoep:minedown-adventure:1.7.2-SNAPSHOT'
api 'com.google.code.gson:gson:2.10.1'
api 'net.william278:PagineDown:1.1'
api 'net.william278:DesertWell:2.0.4'
api 'com.github.Exlll.ConfigLib:configlib-yaml:v4.5.0'
api('com.zaxxer:HikariCP:5.1.0') {
exclude module: 'slf4j-api'
Expand All @@ -26,12 +26,12 @@ dependencies {
compileOnly 'com.github.plan-player-analytics:Plan:5.5.2391'
compileOnly 'com.github.BlueMap-Minecraft:BlueMapAPI:2.6.0'
compileOnly 'us.dynmap:DynmapCoreAPI:3.4'
compileOnly 'maven.modrinth:pl3xmap:1.20.2-475'
compileOnly 'org.projectlombok:lombok:1.18.30'
compileOnly 'maven.modrinth:pl3xmap:1.20.4-489'
compileOnly 'org.projectlombok:lombok:1.18.32'

testImplementation 'com.github.plan-player-analytics:Plan:5.5.2391'
testImplementation 'com.github.yuriy-g:simple-java-plot:5c502c2e98'
testImplementation 'com.google.guava:guava:33.1.0-jre'

annotationProcessor 'org.projectlombok:lombok:1.18.30'
annotationProcessor 'org.projectlombok:lombok:1.18.32'
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
public class DelHomeCommand extends SavedPositionCommand<Home> {

public DelHomeCommand(@NotNull HuskHomes plugin) {
super("delhome", List.of(), Home.class, List.of(), plugin);
super("delhome", List.of(), PositionCommandType.HOME, List.of(), plugin);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class DelWarpCommand extends SavedPositionCommand<Warp> {

public DelWarpCommand(@NotNull HuskHomes plugin) {
super("delwarp", List.of(), Warp.class, List.of(), plugin);
super("delwarp", List.of(), PositionCommandType.WARP, List.of(), plugin);
setOperatorCommand(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,21 @@
import net.william278.huskhomes.util.ValidationException;
import org.jetbrains.annotations.NotNull;

import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.time.format.FormatStyle;
import java.util.*;
import java.util.regex.Pattern;

public class EditHomeCommand extends SavedPositionCommand<Home> {

public EditHomeCommand(@NotNull HuskHomes plugin) {
super("edithome", List.of(), Home.class, List.of("rename", "description", "relocate", "privacy"), plugin);
addAdditionalPermissions(arguments.stream().collect(HashMap::new, (m, e) -> m.put(e, false), HashMap::putAll));
super(
"edithome",
List.of(),
PositionCommandType.HOME,
List.of("rename", "description", "relocate", "privacy"),
plugin
);
}

@Override
Expand All @@ -60,14 +62,11 @@ public void execute(@NotNull CommandUser executor, @NotNull Home home, @NotNull
.forEach(executor::sendMessage);
return;
}

if (!arguments.contains(operation.get().toLowerCase())) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(executor::sendMessage);
if (isInvalidOperation(operation.get(), executor)) {
return;
}

switch (operation.get().toLowerCase()) {
switch (operation.get().toLowerCase(Locale.ENGLISH)) {
case "rename" -> setHomeName(executor, home, ownerEditing, args);
case "description" -> setHomeDescription(executor, home, ownerEditing, args);
case "relocate" -> setHomePosition(executor, home, ownerEditing);
Expand Down Expand Up @@ -247,8 +246,8 @@ private List<MineDown> getHomeEditorWindow(@NotNull Home home, boolean otherView
}

plugin.getLocales().getLocale("edit_home_menu_metadata_" + (!home.isPublic() ? "private" : "public"),
DateTimeFormatter.ofPattern("MMM dd yyyy, HH:mm")
.format(home.getMeta().getCreationTime().atZone(ZoneId.systemDefault())),
home.getMeta().getCreationTimestamp().format(DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)),
home.getUuid().toString().split(Pattern.quote("-"))[0],
home.getUuid().toString())
.ifPresent(messages::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,20 +27,24 @@
import net.william278.huskhomes.util.ValidationException;
import org.jetbrains.annotations.NotNull;

import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Optional;
import java.util.regex.Pattern;

public class EditWarpCommand extends SavedPositionCommand<Warp> {

public EditWarpCommand(@NotNull HuskHomes plugin) {
super("editwarp", List.of(), Warp.class, List.of("rename", "description", "relocate"), plugin);
super(
"editwarp",
List.of(),
PositionCommandType.WARP,
List.of("rename", "description", "relocate"),
plugin
);
setOperatorCommand(true);
addAdditionalPermissions(arguments.stream().collect(HashMap::new, (m, e) -> m.put(e, false), HashMap::putAll));
}

@Override
Expand All @@ -50,10 +54,7 @@ public void execute(@NotNull CommandUser executor, @NotNull Warp warp, @NotNull
getWarpEditorWindow(warp).forEach(executor::sendMessage);
return;
}

if (!arguments.contains(operation.get().toLowerCase())) {
plugin.getLocales().getLocale("error_invalid_syntax", getUsage())
.ifPresent(executor::sendMessage);
if (isInvalidOperation(operation.get(), executor)) {
return;
}

Expand Down Expand Up @@ -148,8 +149,8 @@ private List<MineDown> getWarpEditorWindow(@NotNull Warp warp) {
.ifPresent(messages::add);

plugin.getLocales().getLocale("edit_warp_menu_metadata",
DateTimeFormatter.ofPattern("MMM dd yyyy, HH:mm")
.format(warp.getMeta().getCreationTime().atZone(ZoneId.systemDefault())),
warp.getMeta().getCreationTimestamp().format(DateTimeFormatter
.ofLocalizedDateTime(FormatStyle.MEDIUM, FormatStyle.SHORT)),
warp.getUuid().toString().split(Pattern.quote("-"))[0],
warp.getUuid().toString())
.ifPresent(messages::add);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,9 @@

public abstract class HomeCommand extends SavedPositionCommand<Home> {

protected HomeCommand(@NotNull String name, @NotNull List<String> aliases, @NotNull HuskHomes plugin) {
super(name, aliases, Home.class, List.of("player"), plugin);
protected HomeCommand(@NotNull String name, @NotNull List<String> aliases, @NotNull PositionCommandType type,
@NotNull HuskHomes plugin) {
super(name, aliases, type, List.of("player"), plugin);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,13 +109,17 @@ private Optional<PaginatedList> generateList(@NotNull CommandUser executor, @Not
final PaginatedList homeList = PaginatedList.of(homes.stream().map(home ->
plugin.getLocales()
.getRawLocale("home_list_item",
Locales.escapeText(home.getName()), home.getSafeIdentifier(),
Locales.escapeText(home.getName()),
home.getSafeIdentifier(),
home.isPublic()
? plugin.getLocales().getRawLocale("home_is_public")
.orElse("Public")
: plugin.getLocales().getRawLocale("home_is_private")
.orElse("Private"),
Locales.escapeText(home.getMeta().getDescription()))
home.getMeta().getDescription().isBlank()
? plugin.getLocales().getNone()
: Locales.escapeText(home.getMeta().getDescription())
)
.orElse(home.getName())).sorted().collect(Collectors.toList()),
plugin.getLocales()
.getBaseList(plugin.getSettings().getGeneral().getListItemsPerPage())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ protected HuskHomesCommand(@NotNull HuskHomes plugin) {
this.updateChecker = plugin.getUpdateChecker();
this.aboutMenu = AboutMenu.builder()
.title(Component.text("HuskHomes"))
.description(Component.text("The powerful and intuitive homes, warps, and teleports plugin/mod"))
.description(Component.text("The powerful & intuitive homes, warps, and teleportation suite"))
.version(plugin.getVersion())
.credits("Author",
AboutMenu.Credit.of("William278").description("Click to visit website").url("https://william278.net"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
public class PrivateHomeCommand extends HomeCommand {

protected PrivateHomeCommand(@NotNull HuskHomes plugin) {
super("home", List.of(), plugin);
super("home", List.of(), PositionCommandType.HOME, plugin);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
package net.william278.huskhomes.command;

import net.william278.huskhomes.HuskHomes;
import net.william278.huskhomes.position.Home;
import net.william278.huskhomes.user.CommandUser;
import org.jetbrains.annotations.NotNull;

Expand All @@ -28,15 +29,15 @@
public class PublicHomeCommand extends HomeCommand implements TabProvider {

protected PublicHomeCommand(@NotNull HuskHomes plugin) {
super("phome", List.of("publichome"), plugin);
super("phome", List.of("publichome"), PositionCommandType.PUBLIC_HOME, plugin);
}

@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
// Display the public home list if no arguments are provided
if (args.length == 0) {
plugin.getCommand(PublicHomeListCommand.class)
.ifPresent(command -> command.showPublicHomeList(executor, 1));
.ifPresent(command -> command.showPublicHomeList(executor, null, 1));
return;
}
super.execute(executor, args);
Expand All @@ -46,7 +47,10 @@ public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
@NotNull
public List<String> suggest(@NotNull CommandUser executor, @NotNull String[] args) {
if (args.length <= 2) {
return filter(plugin.getManager().homes().getPublicHomeIdentifiers(), args);
if (args.length >= 1 && args[0].contains(Home.IDENTIFIER_DELIMITER)) {
return plugin.getManager().homes().getPublicHomeIdentifierNames();
}
return plugin.getManager().homes().getPublicHomeNames();
}
return List.of();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import net.william278.huskhomes.user.OnlineUser;
import net.william278.paginedown.PaginatedList;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.List;
import java.util.Optional;
Expand All @@ -40,19 +41,20 @@ protected PublicHomeListCommand(@NotNull HuskHomes plugin) {
@Override
public void execute(@NotNull CommandUser executor, @NotNull String[] args) {
final int pageNumber = parseIntArg(args, 0).orElse(1);
this.showPublicHomeList(executor, pageNumber);
this.showPublicHomeList(executor, null, pageNumber);
}

protected void showPublicHomeList(@NotNull CommandUser executor, int pageNumber) {
if (executor instanceof OnlineUser user && cachedLists.containsKey(user.getUuid())) {
public void showPublicHomeList(@NotNull CommandUser executor, @Nullable String nameFilter, int pageNumber) {
if (nameFilter == null && executor instanceof OnlineUser user && cachedLists.containsKey(user.getUuid())) {
executor.sendMessage(cachedLists.get(user.getUuid()).getNearestValidPage(pageNumber));
return;
}

final List<Home> homes = plugin.getDatabase().getPublicHomes();
final List<Home> homes = nameFilter == null ? plugin.getDatabase().getPublicHomes()
: plugin.getDatabase().getPublicHomes(nameFilter);
plugin.fireEvent(plugin.getViewHomeListEvent(homes, executor, true),
(event) -> this.generateList(executor, event.getHomes()).ifPresent(homeList -> {
if (executor instanceof OnlineUser onlineUser) {
if (nameFilter == null && executor instanceof OnlineUser onlineUser) {
cachedLists.put(onlineUser.getUuid(), homeList);
}
executor.sendMessage(homeList.getNearestValidPage(pageNumber));
Expand All @@ -69,9 +71,15 @@ private Optional<PaginatedList> generateList(@NotNull CommandUser executor, @Not
final PaginatedList homeList = PaginatedList.of(publicHomes.stream().map(home ->
plugin.getLocales()
.getRawLocale("public_home_list_item",
Locales.escapeText(home.getName()), home.getSafeIdentifier(),
publicHomes.stream()
.filter(h -> h.getName().equals(home.getName())).count() > 1
? home.getSafeIdentifier() : Locales.escapeText(home.getName()),
home.getSafeIdentifier(),
Locales.escapeText(home.getOwner().getUsername()),
Locales.escapeText(home.getMeta().getDescription()))
home.getMeta().getDescription().isBlank()
? plugin.getLocales().getNone()
: Locales.escapeText(home.getMeta().getDescription())
)
.orElse(home.getName())).sorted().collect(Collectors.toList()),
plugin.getLocales()
.getBaseList(plugin.getSettings().getGeneral().getListItemsPerPage())
Expand Down
Loading

0 comments on commit 8d178e3

Please sign in to comment.