Compare commits

...

3 Commits

7 changed files with 38 additions and 30 deletions

View File

@ -336,7 +336,7 @@ public interface SuggestionsSupplier<S> {
/** /**
* List of all possible duration unit symbols for suggestions. * List of all possible duration unit symbols for suggestions.
*/ */
public static final List<String> DURATION_SUFFIXES = List.of("y", "mo", "w", "d", "h", "m", "s"); List<String> DURATION_SUFFIXES = List.of("y", "mo", "w", "d", "h", "m", "s");
private static void scanAndRemovePastSuffixes(List<String> suffixes, String foundSuffix) { private static void scanAndRemovePastSuffixes(List<String> suffixes, String foundSuffix) {

View File

@ -310,9 +310,7 @@ public abstract class BackupProcess implements Comparable<BackupProcess>, Runnab
return false; return false;
if (!isDirty()) if (!isDirty())
return false; return false;
if (getNext() > System.currentTimeMillis()) return getNext() <= System.currentTimeMillis();
return false;
return true;
} }

View File

@ -12,8 +12,8 @@ import static fr.pandacube.lib.util.ThrowableUtil.wrapReflectEx;
@ConcreteWrapper(GameVersion.__concrete.class) @ConcreteWrapper(GameVersion.__concrete.class)
public interface GameVersion extends ReflectWrapperI { public interface GameVersion extends ReflectWrapperI {
public static final ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("com.mojang.bridge.game.GameVersion")); ReflectClass<?> REFLECT = wrapEx(() -> Reflect.ofClass("com.mojang.bridge.game.GameVersion"));
public static final ReflectMethod<?> getWorldVersion = wrapEx(() -> REFLECT.method("getWorldVersion")); ReflectMethod<?> getWorldVersion = wrapEx(() -> REFLECT.method("getWorldVersion"));
default int getWorldVersion() { default int getWorldVersion() {
return (int) wrapReflectEx(() -> getWorldVersion.invoke(__getRuntimeInstance())); return (int) wrapReflectEx(() -> getWorldVersion.invoke(__getRuntimeInstance()));

View File

@ -20,10 +20,12 @@ public class CollectionTag extends ReflectWrapperTyped<AbstractList<?>> implemen
return wrap(__getRuntimeInstance().get(i), Tag.class); return wrap(__getRuntimeInstance().get(i), Tag.class);
} }
@SuppressWarnings("unchecked")
public Tag set(int i, Tag t) { public Tag set(int i, Tag t) {
return wrap(((AbstractList<Object>)__getRuntimeInstance()).set(i, unwrap(t)), Tag.class); return wrap(((AbstractList<Object>)__getRuntimeInstance()).set(i, unwrap(t)), Tag.class);
} }
@SuppressWarnings("unchecked")
public void add(int i, Tag t) { public void add(int i, Tag t) {
((AbstractList<Object>)__getRuntimeInstance()).add(i, unwrap(t)); ((AbstractList<Object>)__getRuntimeInstance()).add(i, unwrap(t));
} }

View File

@ -1,15 +1,9 @@
package fr.pandacube.lib.paper.util; package fr.pandacube.lib.paper.util;
import java.util.Arrays; import com.destroystokyo.paper.Namespaced;
import java.util.Collection; import com.google.common.collect.Streams;
import java.util.Collections; import fr.pandacube.lib.chat.Chat;
import java.util.List; import net.kyori.adventure.text.Component;
import java.util.Set;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import fr.pandacube.lib.chat.ChatStatic;
import fr.pandacube.lib.util.Log;
import net.kyori.adventure.text.ComponentLike; import net.kyori.adventure.text.ComponentLike;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -18,13 +12,12 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.Damageable; import org.bukkit.inventory.meta.Damageable;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import com.google.common.collect.Streams; import java.util.Arrays;
import java.util.Collection;
import fr.pandacube.lib.chat.Chat; import java.util.Collections;
import fr.pandacube.lib.chat.Chat.FormatableChat; import java.util.List;
import net.kyori.adventure.text.Component; import java.util.Set;
import net.kyori.adventure.text.format.TextDecoration; import java.util.function.Consumer;
import net.kyori.adventure.text.format.TextDecoration.State;
import static fr.pandacube.lib.chat.ChatStatic.chatComponent; import static fr.pandacube.lib.chat.ChatStatic.chatComponent;
@ -182,11 +175,19 @@ public class ItemStackBuilder {
} }
public ItemStackBuilder canDestroy(Set<Material> destroyable) { public ItemStackBuilder canDestroy(Set<Material> destroyable) {
return meta(m -> m.setCanDestroy(destroyable)); return canDestroy(destroyable.stream().map(m -> (Namespaced) m.getKey()).toList());
} }
public ItemStackBuilder canPlaceOn(Set<Material> placeOn) { public ItemStackBuilder canPlaceOn(Set<Material> placeOn) {
return meta(m -> m.setCanPlaceOn(placeOn)); return canPlaceOn(placeOn.stream().map(m -> (Namespaced) m.getKey()).toList());
}
public ItemStackBuilder canDestroy(Collection<Namespaced> destroyable) {
return meta(m -> m.setDestroyableKeys(destroyable));
}
public ItemStackBuilder canPlaceOn(Collection<Namespaced> placeOn) {
return meta(m -> m.setPlaceableKeys(placeOn));
} }
public ItemStackBuilder damage(int d) { public ItemStackBuilder damage(int d) {

View File

@ -179,7 +179,7 @@ public class TimeUtil {
/** /**
* Seconds precision for relative display. * Seconds precision for relative display.
*/ */
SECONDS; SECONDS
} }
/** /**

View File

@ -43,13 +43,20 @@ public abstract class AbstractClientWS implements AbstractWS {
Listener.super.onOpen(webSocket); Listener.super.onOpen(webSocket);
} }
StringBuilder partialData = new StringBuilder();
@Override @Override
public CompletionStage<?> onText(WebSocket webSocket, CharSequence data, boolean last) { public CompletionStage<?> onText(WebSocket webSocket, CharSequence data, boolean last) {
partialData.append(data.toString());
if (last) {
try { try {
AbstractClientWS.this.handleReceivedMessage(data.toString()); AbstractClientWS.this.handleReceivedMessage(partialData.toString());
} catch (Exception e) { } catch (Exception e) {
logError("Error handling reception of text.", e); logError("Error handling reception of text.", e);
} }
partialData = new StringBuilder();
}
return Listener.super.onText(webSocket, data, last); return Listener.super.onText(webSocket, data, last);
} }