Merge remote-tracking branch 'upstream/master' into update-option-equals

This commit is contained in:
LeoDog896 2021-04-06 21:39:17 -04:00
commit 97cad24b14
5 changed files with 38 additions and 22 deletions

View File

@ -124,17 +124,17 @@ dependencies {
testCompileOnly "org.mockito:mockito-core:2.28.2"
// Netty
api 'io.netty:netty-handler:4.1.59.Final'
api 'io.netty:netty-codec:4.1.59.Final'
api 'io.netty:netty-transport-native-epoll:4.1.59.Final:linux-x86_64'
api 'io.netty:netty-transport-native-kqueue:4.1.59.Final:osx-x86_64'
api 'io.netty:netty-handler:4.1.63.Final'
api 'io.netty:netty-codec:4.1.63.Final'
api 'io.netty:netty-transport-native-epoll:4.1.63.Final:linux-x86_64'
api 'io.netty:netty-transport-native-kqueue:4.1.63.Final:osx-x86_64'
api 'io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.4.Final:linux-x86_64'
// https://mvnrepository.com/artifact/org.apache.commons/commons-text
compile group: 'org.apache.commons', name: 'commons-text', version: '1.9'
// https://mvnrepository.com/artifact/it.unimi.dsi/fastutil
api 'it.unimi.dsi:fastutil:8.5.2'
api 'it.unimi.dsi:fastutil:8.5.4'
// https://mvnrepository.com/artifact/com.google.code.gson/gson
api 'com.google.code.gson:gson:2.8.6'
@ -144,7 +144,7 @@ dependencies {
api 'com.github.Articdive:Jnoise:1.0.0'
// https://mvnrepository.com/artifact/org.rocksdb/rocksdbjni
api 'org.rocksdb:rocksdbjni:6.15.2'
api 'org.rocksdb:rocksdbjni:6.16.4'
// Logging
api 'org.apache.logging.log4j:log4j-core:2.14.0'
@ -167,7 +167,7 @@ dependencies {
implementation "com.velocitypowered:velocity-native:1.1.0-SNAPSHOT"
// Path finding
api 'com.github.MadMartian:hydrazine-path-finding:1.5.4'
api 'com.github.MadMartian:hydrazine-path-finding:1.6.0'
api "org.jetbrains.kotlin:kotlin-stdlib-jdk8:${project.kotlinVersion}"
api "org.jetbrains.kotlin:kotlin-reflect:${project.kotlinVersion}"

View File

@ -1,6 +1,7 @@
package net.minestom.server.entity.pathfinding;
import com.extollit.gaming.ai.path.HydrazinePathFinder;
import com.extollit.gaming.ai.path.PathOptions;
import com.extollit.gaming.ai.path.model.IPath;
import net.minestom.server.collision.CollisionUtils;
import net.minestom.server.entity.Entity;
@ -140,11 +141,14 @@ public class Navigator {
final Position targetPosition = position.clone();
final PathOptions pathOptions = new PathOptions()
.targetingStrategy(bestEffort ? PathOptions.TargetingStrategy.gravitySnap :
PathOptions.TargetingStrategy.none);
final IPath path = pathFinder.initiatePathTo(
targetPosition.getX(),
targetPosition.getY(),
targetPosition.getZ(),
bestEffort);
pathOptions);
this.path = path;
final boolean success = path != null;

View File

@ -45,6 +45,11 @@ public class PFPathingEntity implements IPathingEntity {
return (int) entity.getAliveTicks();
}
@Override
public boolean bound() {
return entity.hasVelocity();
}
@Override
public float searchRange() {
return searchRange;

View File

@ -11,6 +11,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Called every time a {@link Player} write and send something in the chat.
@ -19,14 +20,18 @@ import java.util.function.Function;
public class PlayerChatEvent extends PlayerEvent implements CancellableEvent {
private final Collection<Player> recipients;
private final Supplier<Component> defaultChatFormat;
private String message;
private Function<PlayerChatEvent, Component> chatFormat;
private boolean cancelled;
public PlayerChatEvent(@NotNull Player player, @NotNull Collection<Player> recipients, @NotNull String message) {
public PlayerChatEvent(@NotNull Player player, @NotNull Collection<Player> recipients,
@NotNull Supplier<Component> defaultChatFormat,
@NotNull String message) {
super(player);
this.recipients = new ArrayList<>(recipients);
this.defaultChatFormat = defaultChatFormat;
this.message = message;
}
@ -57,8 +62,7 @@ public class PlayerChatEvent extends PlayerEvent implements CancellableEvent {
*
* @return a modifiable list of message targets
*/
@NotNull
public Collection<Player> getRecipients() {
public @NotNull Collection<Player> getRecipients() {
return recipients;
}
@ -67,8 +71,7 @@ public class PlayerChatEvent extends PlayerEvent implements CancellableEvent {
*
* @return the sender's message
*/
@NotNull
public String getMessage() {
public @NotNull String getMessage() {
return message;
}
@ -88,11 +91,14 @@ public class PlayerChatEvent extends PlayerEvent implements CancellableEvent {
*
* @return the chat format which will be used, null if this is the default one
*/
@Nullable
public Function<PlayerChatEvent, Component> getChatFormatFunction() {
public @Nullable Function<@NotNull PlayerChatEvent, @NotNull Component> getChatFormatFunction() {
return chatFormat;
}
public @NotNull Supplier<@NotNull Component> getDefaultChatFormat() {
return defaultChatFormat;
}
@Override
public boolean isCancelled() {
return cancelled;

View File

@ -10,6 +10,7 @@ import net.minestom.server.network.ConnectionManager;
import net.minestom.server.network.packet.client.play.ClientChatMessagePacket;
import net.minestom.server.network.packet.server.play.ChatMessagePacket;
import net.minestom.server.utils.PacketUtils;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.function.Function;
@ -34,7 +35,8 @@ public class ChatMessageListener {
}
final Collection<Player> players = CONNECTION_MANAGER.getOnlinePlayers();
PlayerChatEvent playerChatEvent = new PlayerChatEvent(player, players, message);
String finalMessage = message;
PlayerChatEvent playerChatEvent = new PlayerChatEvent(player, players, () -> buildDefaultChatMessage(player, finalMessage), message);
// Call the event
player.callCancellableEvent(PlayerChatEvent.class, playerChatEvent, () -> {
@ -48,7 +50,7 @@ public class ChatMessageListener {
textObject = formatFunction.apply(playerChatEvent);
} else {
// Default format
textObject = buildDefaultChatMessage(playerChatEvent);
textObject = playerChatEvent.getDefaultChatFormat().get();
}
final Collection<Player> recipients = playerChatEvent.getRecipients();
@ -64,15 +66,14 @@ public class ChatMessageListener {
}
private static Component buildDefaultChatMessage(PlayerChatEvent chatEvent) {
final String username = chatEvent.getPlayer().getUsername();
private static @NotNull Component buildDefaultChatMessage(@NotNull Player player, @NotNull String message) {
final String username = player.getUsername();
return Component.translatable("chat.type.text")
.args(Component.text(username)
.insertion(username)
.clickEvent(ClickEvent.suggestCommand("/msg " + username + " "))
.hoverEvent(chatEvent.getPlayer()),
Component.text(chatEvent.getMessage())
.hoverEvent(player),
Component.text(message)
);
}