Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/warp-fix' into warp-fix
Browse files Browse the repository at this point in the history
# Conflicts:
#	eternalcore-core/src/main/java/com/eternalcode/core/feature/warp/WarpInventory.java
  • Loading branch information
Rollczi committed Jan 18, 2025
2 parents 172c2d6 + c519398 commit 95005c5
Show file tree
Hide file tree
Showing 71 changed files with 616 additions and 360 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ For Maven projects use:

For Gradle projects use:
```kts
compileOnly("com.eternalcode:eternalcore-api:1.5.1")
compileOnly("com.eternalcode:eternalcore-api:1.5.2")
```

For Maven projects use:
```xml
<dependency>
<groupId>com.eternalcode</groupId>
<artifactId>eternalcore-api</artifactId>
<version>1.5.1</version>
<version>1.5.2</version>
<scope>provided</scope>
</dependency>
```
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ object Versions {
const val CDN_CONFIGS = "1.14.6"

const val MARIA_DB = "3.5.1"
const val POSTGRESQL = "42.7.4"
const val POSTGRESQL = "42.7.5"
const val H2 = "2.3.232"
const val ORMLITE = "6.1"
const val HIKARI_CP = "6.2.1"
Expand All @@ -37,7 +37,7 @@ object Versions {

const val BSTATS = "3.1.0"

const val CAFFEINE = "3.1.8"
const val CAFFEINE = "3.2.0"

const val SPOTIFY_COMPLETABLE_FUTURES = "0.3.6"

Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/eternalcode-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.eternalcode"
version = "1.5.1"
version = "1.5.2"

checkstyle {
toolVersion = "10.21.1"
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/eternalcore-publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.eternalcode"
version = "1.5.1"
version = "1.5.2"

java {
withSourcesJar()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.eternalcode.core.feature.butcher;

import org.bukkit.entity.Entity;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;

public class ButcherEntityRemoveEvent extends Event implements Cancellable {

private static final HandlerList HANDLER_LIST = new HandlerList();

private boolean cancelled;
private final Entity entity;

public ButcherEntityRemoveEvent(Entity entity) {
this.entity = entity;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}

public Entity getEntity() {
return entity;
}

@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}

public static HandlerList getHandlerList() {
return HANDLER_LIST;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package com.eternalcode.core.feature.language;

import java.util.ArrayList;
import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.Set;

public class Language {

Expand All @@ -13,35 +14,37 @@ public class Language {
public static final Language DEFAULT = Language.fromLocale(Locale.ROOT);

private final String lang;
private final List<String> aliases;
private final Set<String> aliases;

public Language(String lang, List<String> aliases) {
this.lang = lang;
this.aliases = new ArrayList<>(aliases);
this.aliases = new LinkedHashSet<>(aliases);
}

public String getLang() {
return this.lang;
}

public List<String> getAliases() {
return Collections.unmodifiableList(this.aliases);
public Set<String> getAliases() {
return Collections.unmodifiableSet(this.aliases);
}

public boolean isEquals(Language other) {
if (this.lang.equals(other.lang)) {
return true;
}

for (String alias : this.aliases) {
if (alias.equals(other.lang)) {
return true;
}
if (this.lang.startsWith(other.lang) || other.lang.startsWith(this.lang)) {
return true;
}

for (String otherAlias : other.aliases) {
if (alias.equals(otherAlias)) {
return true;
}
if (this.aliases.contains(other.lang)) {
return true;
}

for (String otherAlias : other.aliases) {
if (this.aliases.contains(otherAlias)) {
return true;
}
}

Expand Down Expand Up @@ -71,7 +74,7 @@ public static Language fromLocale(Locale locale) {
}

public Locale toLocale() {
return new Locale(this.lang);
return Locale.of(this.lang);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.eternalcode.core.feature.language;

import java.util.UUID;

public interface LanguageProvider {

Language getDefaultLanguage(UUID player);

}
Original file line number Diff line number Diff line change
@@ -1,11 +1,20 @@
package com.eternalcode.core.feature.language;

import java.util.Locale;
import org.bukkit.entity.Player;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;

public interface LanguageService {

Locale getPlayerLanguage(Player player);
void setDefaultProvider(LanguageProvider defaultProvider);

LanguageProvider getDefaultProvider();

CompletableFuture<Language> getLanguage(UUID playerUniqueId);

Language getLanguageNow(UUID playerUniqueId);

CompletableFuture<Void> setLanguage(UUID playerUniqueId, Language language);

CompletableFuture<Void> setDefaultLanguage(UUID playerUniqueId);

void setPlayerLanguage(Player player, Locale locale);
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package com.eternalcode.core.feature.warp;

import org.bukkit.Location;
import org.jetbrains.annotations.ApiStatus.Experimental;

import java.util.Collection;
import java.util.Optional;
import org.jetbrains.annotations.ApiStatus.Experimental;

public interface WarpService {

Expand All @@ -18,7 +18,7 @@ public interface WarpService {
@Experimental
Warp removePermissions(String warp, String... permissions);

boolean isExist(String name);
boolean exists(String name);

Optional<Warp> findWarp(String name);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
package com.eternalcode.core.bridge.litecommand.argument;

import com.eternalcode.core.feature.language.Language;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.viewer.Viewer;
import com.eternalcode.core.viewer.ViewerService;
import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.argument.parser.ParseResult;
import dev.rollczi.litecommands.argument.resolver.ArgumentResolver;
import dev.rollczi.litecommands.invocation.Invocation;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public abstract class AbstractViewerArgument<T> extends ArgumentResolver<CommandSender, T> {

protected final ViewerService viewerService;
protected final TranslationManager translationManager;

protected AbstractViewerArgument(ViewerService viewerService, TranslationManager translationManager) {
this.viewerService = viewerService;
protected AbstractViewerArgument(TranslationManager translationManager) {
this.translationManager = translationManager;
}

@Override
protected ParseResult<T> parse(Invocation<CommandSender> invocation, Argument<T> context, String argument) {
Viewer viewer = this.viewerService.any(invocation.sender());
Translation translation = this.translationManager.getMessages(viewer.getLanguage());
if (invocation.sender() instanceof Player player) {
Translation translation = this.translationManager.getMessages(player.getUniqueId());
return this.parse(invocation, argument, translation);
}

Translation translation = this.translationManager.getMessages(Language.DEFAULT);
return this.parse(invocation, argument, translation);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.eternalcode.core.injector.annotations.lite.LiteArgument;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.viewer.ViewerService;
import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.argument.parser.ParseResult;
import dev.rollczi.litecommands.invocation.Invocation;
Expand All @@ -21,8 +20,8 @@
class EnchantmentArgument extends AbstractViewerArgument<Enchantment> {

@Inject
EnchantmentArgument(ViewerService viewerService, TranslationManager translationManager) {
super(viewerService, translationManager);
EnchantmentArgument(TranslationManager translationManager) {
super(translationManager);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.eternalcode.core.injector.annotations.lite.LiteArgument;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.viewer.ViewerService;
import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.argument.parser.ParseResult;
import dev.rollczi.litecommands.invocation.Invocation;
Expand All @@ -23,8 +22,8 @@ class GameModeArgument extends AbstractViewerArgument<GameMode> {
private final GameModeArgumentSettings gameModeArgumentSettings;

@Inject
GameModeArgument(ViewerService viewerService, TranslationManager translationManager, GameModeArgumentSettings gameModeArgumentSettings) {
super(viewerService, translationManager);
GameModeArgument(TranslationManager translationManager, GameModeArgumentSettings gameModeArgumentSettings) {
super(translationManager);
this.gameModeArgumentSettings = gameModeArgumentSettings;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import com.eternalcode.core.notice.NoticeTextType;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.viewer.ViewerService;
import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.argument.parser.ParseResult;
import dev.rollczi.litecommands.invocation.Invocation;
Expand All @@ -19,8 +18,8 @@
class NoticeTypeArgument extends AbstractViewerArgument<NoticeTextType> {

@Inject
NoticeTypeArgument(ViewerService viewerService, TranslationManager translationManager) {
super(viewerService, translationManager);
NoticeTypeArgument(TranslationManager translationManager) {
super(translationManager);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.eternalcode.core.injector.annotations.lite.LiteArgument;
import com.eternalcode.core.translation.Translation;
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.viewer.ViewerService;
import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.argument.parser.ParseResult;
import dev.rollczi.litecommands.invocation.Invocation;
Expand All @@ -25,12 +24,11 @@ public class PlayerArgument extends AbstractViewerArgument<Player> {

@Inject
public PlayerArgument(
ViewerService viewerService,
TranslationManager translationManager,
Server server,
VanishService vanishService
) {
super(viewerService, translationManager);
super(translationManager);
this.server = server;
this.vanishService = vanishService;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.eternalcode.core.translation.TranslationManager;
import com.eternalcode.core.user.User;
import com.eternalcode.core.user.UserManager;
import com.eternalcode.core.viewer.ViewerService;
import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.argument.parser.ParseResult;
import dev.rollczi.litecommands.invocation.Invocation;
Expand All @@ -23,8 +22,8 @@ class UserArgument extends AbstractViewerArgument<User> {
private final UserManager userManager;

@Inject
UserArgument(ViewerService viewerService, TranslationManager translationManager, Server server, UserManager userManager) {
super(viewerService, translationManager);
UserArgument(TranslationManager translationManager, Server server, UserManager userManager) {
super(translationManager);
this.server = server;
this.userManager = userManager;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class LocationsConfiguration implements ReloadableConfig {
public Position spawn = EMPTY_POSITION;

@Description("# Warps now are stored in warps.yml. This is deprecated.")
@Deprecated
@Deprecated(since = "1.5.1", forRemoval = true)
public Map<String, Position> warps = new HashMap<>();

@Description("# This is jail location, for your own safety, please don't touch it.")
Expand Down
Loading

0 comments on commit 95005c5

Please sign in to comment.