- Added Portugal Portuguese
- Fixed SmartClear from saying type to confirm when force is specified - Logs halt to console - Equivalent notification for server being resumed + email notifications for server resumption - Fixed SmartNotifier not providing chunk information as well as making the entire process asynchronous
This commit is contained in:
1 parent
dd2f650185
commit
062f374b45
8 files changed
+86
-79
No files matched your search
-2
@@ -84,8 +84,6 @@ public class PerformanceTweaksConfiguration {
|
||||
} else {
|
||||
if (value == null) {
|
||||
Logger.warn("Null value for " + confSection);
|
||||
} else if (value.getClass() == null) {
|
||||
Logger.warn("Null class for " + confSection);
|
||||
} else {
|
||||
Logger.warn("Unknown type for " + confSection + ": " + value.getClass());
|
||||
}
|
||||
|
||||
+7
-8
@@ -5,7 +5,6 @@ import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.TextComponent;
|
||||
import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.event.ClickEvent;
|
||||
import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.event.HoverEvent;
|
||||
import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.format.NamedTextColor;
|
||||
import com.neomechanical.neoconfig.neoutils.kyori.adventure.text.format.TextDecoration;
|
||||
import com.neomechanical.neoconfig.neoutils.messages.MessageUtil;
|
||||
import com.neomechanical.neoperformance.commands.chunks.ChunkTeleportCommand;
|
||||
import com.neomechanical.neoperformance.utils.messages.Messages;
|
||||
@@ -46,15 +45,15 @@ public class ChunksNotifier {
|
||||
Entity entityToLocate = entities[0];
|
||||
Location location = new Location(world, Math.round(entityToLocate.getLocation().getX()), Math.round(entityToLocate.getLocation().getY()),
|
||||
Math.round(entityToLocate.getLocation().getZ()));
|
||||
message.append(Component.text(" Chunk: ").color(color).decorate(TextDecoration.BOLD))
|
||||
.append(Component.text(location.getX() + " " + location.getZ()).color(color).decorate(TextDecoration.BOLD))
|
||||
.append(Component.text(" - Entities: ").color(color).decorate(TextDecoration.BOLD))
|
||||
.append(Component.text(String.valueOf(chunk.getEntities().length)).color(color).decorate(TextDecoration.BOLD));
|
||||
message.append(Component.text(" Chunk: ").color(color))
|
||||
.append(Component.text(location.getX() + " " + location.getZ()).color(color)
|
||||
.append(Component.text(" - Entities: ").color(color))
|
||||
.append(Component.text(String.valueOf(chunk.getEntities().length)).color(color)));
|
||||
if (world == null) {
|
||||
message.append(Component.text(" - World: ").color(color).decorate(TextDecoration.BOLD));
|
||||
message.append(Component.text(chunk.getWorld().getName()).color(color).decorate(TextDecoration.BOLD));
|
||||
message.append(Component.text(" - World: ").color(color));
|
||||
message.append(Component.text(chunk.getWorld().getName()).color(color));
|
||||
}
|
||||
message.color(color).decorate(TextDecoration.BOLD);
|
||||
message.color(color);
|
||||
//Append new line
|
||||
if (chunks.indexOf(chunk) != chunks.size() - 1) {
|
||||
message.append(Component.newline());
|
||||
|
||||
+3
-5
@@ -3,10 +3,8 @@ package com.neomechanical.neoperformance.performance.smart.smartNotifier;
|
||||
import com.neomechanical.neoperformance.performance.smart.smartNotifier.managers.LagData;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public abstract class DataGetter {
|
||||
public abstract void generate();
|
||||
|
||||
public abstract LagData get(Player player);
|
||||
|
||||
public abstract Integer getNotifySize();
|
||||
public abstract CompletableFuture<LagData> get(Player player);
|
||||
}
|
||||
-1
@@ -24,7 +24,6 @@ public class LagChecker {
|
||||
public void run() {
|
||||
//Generate data
|
||||
LagDataManager lagDataManager = new LagDataManager(plugin);
|
||||
lagDataManager.generateAll();
|
||||
List<? extends Player> recipients = Bukkit.getOnlinePlayers().stream().filter(p -> p.hasPermission("neoperformance.smartnotify") || p.isOp()).collect(Collectors.toList());
|
||||
for (Player recipient : recipients) {
|
||||
LagReportBuilder lagReportBuilder = new LagReport().reportBuilder();
|
||||
|
||||
+22
-19
@@ -11,11 +11,10 @@ import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class ChunkData extends DataGetter {
|
||||
private List<Chunk> chunks = new ArrayList<>();
|
||||
private final NeoPerformance plugin;
|
||||
|
||||
public ChunkData(NeoPerformance plugin) {
|
||||
@@ -23,25 +22,29 @@ public class ChunkData extends DataGetter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
public CompletableFuture<LagData> get(Player player) {
|
||||
CompletableFuture<List<Chunk>> chunksFuture = new CompletableFuture<>();
|
||||
|
||||
World[] worlds = Bukkit.getWorlds().toArray(new World[0]);
|
||||
new ChunksScanner(plugin).getChunksWithMostEntities(1, result -> chunks = result, worlds);
|
||||
}
|
||||
|
||||
@Override
|
||||
public LagData get(Player player) {
|
||||
if (chunks.isEmpty() || chunks.get(0).getEntities().length < plugin.getDataManager().getLagNotifierData().getEntitiesInChunkNotify()) {
|
||||
return null;
|
||||
}
|
||||
TextComponent.Builder builder = ChunksNotifier.getChatData(chunks, null, player);
|
||||
if (builder.children().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new LagData(player, "Chunks", builder);
|
||||
}
|
||||
new ChunksScanner(plugin).getChunksWithMostEntities(1, chunksFuture::complete, worlds);
|
||||
|
||||
@Override
|
||||
public Integer getNotifySize() {
|
||||
return plugin.getDataManager().getLagNotifierData().getEntitiesInChunkNotify();
|
||||
return chunksFuture.thenCompose(chunks -> {
|
||||
CompletableFuture<LagData> lagDataFuture = new CompletableFuture<>();
|
||||
|
||||
if (chunks.isEmpty() || chunks.get(0).getEntities().length < plugin.getDataManager().getLagNotifierData().getEntitiesInChunkNotify()) {
|
||||
lagDataFuture.completeExceptionally(new RuntimeException("No data to report"));
|
||||
} else {
|
||||
TextComponent.Builder builder = ChunksNotifier.getChatData(chunks, null, player);
|
||||
if (builder.children().isEmpty()) {
|
||||
lagDataFuture.completeExceptionally(new RuntimeException("No data to report"));
|
||||
} else {
|
||||
LagData lagData = new LagData(player, "Chunks", builder);
|
||||
lagDataFuture.complete(lagData);
|
||||
}
|
||||
}
|
||||
|
||||
return lagDataFuture;
|
||||
});
|
||||
}
|
||||
}
|
||||
+6
-13
@@ -11,25 +11,21 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class EntityClusterData extends DataGetter {
|
||||
private final DataManager dataManager;
|
||||
private List<List<Entity>> clusters = new ArrayList<>();
|
||||
|
||||
public EntityClusterData(DataManager dataManager) {
|
||||
this.dataManager = dataManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generate() {
|
||||
public CompletableFuture<LagData> get(Player player) {
|
||||
CompletableFuture<LagData> future = new CompletableFuture<>();
|
||||
List<List<Entity>> clusters;
|
||||
clusters = SmartScanner.scan(10, dataManager.getLagNotifierData().getClusterSizeNotify(),
|
||||
dataManager.getCommandData(), Bukkit.getWorlds().toArray(new World[0]));
|
||||
}
|
||||
|
||||
@Override
|
||||
public LagData get(Player player) {
|
||||
if (clusters.isEmpty() || clusters.get(0).size() < dataManager.getLagNotifierData().getClusterSizeNotify()) {
|
||||
return null;
|
||||
}
|
||||
@@ -37,11 +33,8 @@ public class EntityClusterData extends DataGetter {
|
||||
if (builder.children().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return new LagData(player, "Entity Clusters", builder);
|
||||
}
|
||||
future.complete(new LagData(player, "Entity Clusters", builder));
|
||||
return future;
|
||||
|
||||
@Override
|
||||
public Integer getNotifySize() {
|
||||
return dataManager.getLagNotifierData().getClusterSizeNotify();
|
||||
}
|
||||
}
|
||||
+22
-11
@@ -8,6 +8,8 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class LagDataManager {
|
||||
List<DataGetter> dataGetters = new ArrayList<>();
|
||||
@@ -17,19 +19,28 @@ public class LagDataManager {
|
||||
dataGetters.add(new EntityClusterData(plugin.getDataManager()));
|
||||
}
|
||||
|
||||
public void generateAll() {
|
||||
public CompletableFuture<List<LagData>> getAllLagData(Player player) {
|
||||
// Create a list to store individual CompletableFuture instances
|
||||
List<CompletableFuture<LagData>> futureList = new ArrayList<>();
|
||||
|
||||
// Iterate through the dataGetters and add each CompletableFuture to the list
|
||||
for (DataGetter dataGetter : dataGetters) {
|
||||
if (dataGetter.getNotifySize() > 0) {
|
||||
dataGetter.generate();
|
||||
}
|
||||
CompletableFuture<LagData> individualFuture = dataGetter.get(player);
|
||||
futureList.add(individualFuture);
|
||||
}
|
||||
|
||||
// Use CompletableFuture.allOf to combine all individual CompletableFutures into a single CompletableFuture<Void>
|
||||
CompletableFuture<Void> allOfFuture = CompletableFuture.allOf(
|
||||
futureList.toArray(new CompletableFuture[0])
|
||||
);
|
||||
|
||||
// Use thenApply to get the results of all individual CompletableFutures
|
||||
|
||||
return allOfFuture.thenApply(
|
||||
v -> futureList.stream()
|
||||
.map(CompletableFuture::join) // Get the result of each CompletableFuture
|
||||
.collect(Collectors.toList())
|
||||
);
|
||||
}
|
||||
|
||||
public List<LagData> getAllLagData(Player player) {
|
||||
List<LagData> lagDataList = new ArrayList<>();
|
||||
for (DataGetter dataGetter : dataGetters) {
|
||||
lagDataList.add(dataGetter.get(player));
|
||||
}
|
||||
return lagDataList;
|
||||
}
|
||||
}
|
||||
+26
-20
@@ -8,33 +8,39 @@ import com.neomechanical.neoperformance.utils.messages.Messages;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class LagReportBuilder {
|
||||
final TextComponent.Builder builder = Component.text();
|
||||
CompletableFuture<TextComponent.Builder> builderCompletableFuture = new CompletableFuture<>();
|
||||
|
||||
public void addData(List<LagData> dataList) {
|
||||
for (LagData data : dataList) {
|
||||
//Null means there is no data to report
|
||||
if (data == null) {
|
||||
continue;
|
||||
}
|
||||
TextComponent.Builder dataComponent = data.getMessageData();
|
||||
builder.append(Component.text(" ")).append(Component.text("[")).append(Component.text(data.getDataName()))
|
||||
.append(Component.text("]"))
|
||||
.append(Component.newline());
|
||||
builder.append(dataComponent);
|
||||
if (dataList.indexOf(data) != dataList.size() - 1) {
|
||||
public void addData(CompletableFuture<List<LagData>> dataListFuture) {
|
||||
builderCompletableFuture = dataListFuture.thenApply(dataList -> {
|
||||
TextComponent.Builder builder = Component.text();
|
||||
for (LagData data : dataList) {
|
||||
// Null means there is no data to report
|
||||
if (data == null) {
|
||||
return builder; // Return original builder unchanged
|
||||
}
|
||||
TextComponent.Builder dataComponent = data.getMessageData();
|
||||
builder.append(Component.text(" ")).append(Component.text("[")).append(Component.text(data.getDataName()))
|
||||
.append(Component.text("]"))
|
||||
.append(Component.newline());
|
||||
builder.append(dataComponent);
|
||||
builder.append(Component.newline());
|
||||
}
|
||||
}
|
||||
return builder;
|
||||
});
|
||||
}
|
||||
|
||||
public void sendReport(Player player) {
|
||||
TextComponent message = builder.build();
|
||||
if (!message.children().isEmpty()) {
|
||||
MessageUtil.send(player, Messages.MAIN_LAG_REPORT_PREFIX);
|
||||
MessageUtil.sendMM(player, message);
|
||||
MessageUtil.send(player, Messages.MAIN_SUFFIX);
|
||||
}
|
||||
builderCompletableFuture.thenApply(builder -> {
|
||||
TextComponent message = builder.build();
|
||||
if (!message.children().isEmpty()) {
|
||||
MessageUtil.send(player, Messages.MAIN_LAG_REPORT_PREFIX);
|
||||
MessageUtil.sendMM(player, message);
|
||||
MessageUtil.send(player, Messages.MAIN_SUFFIX);
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user