mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Remove most unnecessary uses of google common
This commit is contained in:
parent
4db3b9317d
commit
0be2addbd8
@ -1,6 +1,5 @@
|
||||
package net.minestom.server;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import net.minestom.server.acquirable.Acquirable;
|
||||
import net.minestom.server.instance.Chunk;
|
||||
import net.minestom.server.instance.Instance;
|
||||
@ -34,8 +33,8 @@ public final class UpdateManager {
|
||||
// TODO make configurable
|
||||
private ThreadProvider threadProvider = new SingleThreadProvider();
|
||||
|
||||
private final Queue<LongConsumer> tickStartCallbacks = Queues.newConcurrentLinkedQueue();
|
||||
private final Queue<LongConsumer> tickEndCallbacks = Queues.newConcurrentLinkedQueue();
|
||||
private final Queue<LongConsumer> tickStartCallbacks = new ConcurrentLinkedQueue<>();
|
||||
private final Queue<LongConsumer> tickEndCallbacks = new ConcurrentLinkedQueue<>();
|
||||
private final List<Consumer<TickMonitor>> tickMonitors = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.event.HoverEvent;
|
||||
@ -53,6 +52,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
@ -127,7 +127,7 @@ public class Entity implements Viewable, Tickable, EventHandler<EntityEvent>, Da
|
||||
private final List<TimedPotion> effects = new CopyOnWriteArrayList<>();
|
||||
|
||||
// list of scheduled tasks to be executed during the next entity tick
|
||||
protected final Queue<Consumer<Entity>> nextTick = Queues.newConcurrentLinkedQueue();
|
||||
protected final Queue<Consumer<Entity>> nextTick = new ConcurrentLinkedQueue<>();
|
||||
|
||||
// Tick related
|
||||
private long ticks;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.entity;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import net.kyori.adventure.audience.MessageType;
|
||||
import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
@ -87,6 +86,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.UnaryOperator;
|
||||
|
||||
@ -119,7 +119,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
private final AtomicInteger teleportId = new AtomicInteger();
|
||||
private int receivedTeleportId;
|
||||
|
||||
private final Queue<ClientPlayPacket> packets = Queues.newConcurrentLinkedQueue();
|
||||
private final Queue<ClientPlayPacket> packets = new ConcurrentLinkedQueue<>();
|
||||
private final boolean levelFlat;
|
||||
private final PlayerSettings settings;
|
||||
private float exp;
|
||||
|
@ -24,7 +24,7 @@ public class DoNothingGoal extends GoalSelector {
|
||||
public DoNothingGoal(EntityCreature entityCreature, long time, float chance) {
|
||||
super(entityCreature);
|
||||
this.time = time;
|
||||
this.chance = MathUtils.clampFloat(chance, 0, 1);
|
||||
this.chance = MathUtils.clamp(chance, 0, 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
@ -47,6 +46,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
@ -98,7 +98,7 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
protected UUID uniqueId;
|
||||
|
||||
// list of scheduled tasks to be executed during the next instance tick
|
||||
protected final Queue<Consumer<Instance>> nextTick = Queues.newConcurrentLinkedQueue();
|
||||
protected final Queue<Consumer<Instance>> nextTick = new ConcurrentLinkedQueue<>();
|
||||
|
||||
// instance custom data
|
||||
private Data data;
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.scoreboard;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -22,6 +21,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArraySet;
|
||||
|
||||
/**
|
||||
@ -72,7 +72,7 @@ public class Team implements PacketGroupingAudience {
|
||||
*/
|
||||
private Component suffix;
|
||||
|
||||
private final Set<Player> playerMembers = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
private final Set<Player> playerMembers = ConcurrentHashMap.newKeySet();
|
||||
private boolean isPlayerMembersUpToDate;
|
||||
|
||||
// Adventure
|
||||
|
@ -47,10 +47,6 @@ public final class MathUtils {
|
||||
return Direction.HORIZONTAL[directionIndex];
|
||||
}
|
||||
|
||||
public static float clampFloat(float t, float a, float b) {
|
||||
return Math.max(a, Math.min(t, b));
|
||||
}
|
||||
|
||||
public static boolean isBetween(byte number, byte min, byte max) {
|
||||
return number >= min && number <= max;
|
||||
}
|
||||
@ -84,11 +80,15 @@ public final class MathUtils {
|
||||
}
|
||||
|
||||
public static int clamp(int value, int min, int max) {
|
||||
if (value < min) {
|
||||
return min;
|
||||
} else {
|
||||
return Math.min(value, max);
|
||||
}
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
public static float clamp(float value, float min, float max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
public static double clamp(double value, double min, double max) {
|
||||
return Math.min(Math.max(value, min), max);
|
||||
}
|
||||
|
||||
public static double mod(final double a, final double b) {
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.minestom.server.utils;
|
||||
|
||||
import com.google.common.primitives.Doubles;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.utils.clone.PublicCloneable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@ -167,7 +166,7 @@ public class Vector implements PublicCloneable<Vector> {
|
||||
* @return angle in radians
|
||||
*/
|
||||
public float angle(@NotNull Vector other) {
|
||||
double dot = Doubles.constrainToRange(dot(other) / (length() * other.length()), -1.0, 1.0);
|
||||
double dot = MathUtils.clamp(dot(other) / (length() * other.length()), -1.0, 1.0);
|
||||
|
||||
return (float) Math.acos(dot);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user