Adapt LoChat for Minecraft 1.20.1 Paper
- Changed dependency from Folia API 1.21.4 to Paper API 1.20.1 - Updated plugin.yml: api-version to 1.20, folia-supported to false - Replaced Folia-specific scheduler calls with FoliaUtil for compatibility - Updated version to 1.5.5-1.20.1 - Fixed enum switch warning in ChatListener - Removed unused imports - All tests pass successfully
This commit is contained in:
parent
67b8b9e47c
commit
4f7b792633
7 changed files with 23 additions and 18 deletions
Binary file not shown.
Binary file not shown.
|
|
@ -1,10 +1,10 @@
|
||||||
name: LoChat
|
name: LoChat
|
||||||
version: '1.5.5'
|
version: '1.5.5-1.20.1'
|
||||||
main: com.loki.lochat.LoChat
|
main: com.loki.lochat.LoChat
|
||||||
api-version: '1.21'
|
api-version: '1.20'
|
||||||
folia-supported: true
|
folia-supported: false
|
||||||
author: loki
|
author: loki
|
||||||
description: Advanced chat plugin for Folia with gradient nicks
|
description: Advanced chat plugin for Paper 1.20.1 with gradient nicks
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- PlaceholderAPI
|
- PlaceholderAPI
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group = 'com.loki'
|
group = 'com.loki'
|
||||||
version = '1.5.5'
|
version = '1.5.5-1.20.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
|
@ -14,7 +14,7 @@ repositories {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly 'dev.folia:folia-api:1.21.4-R0.1-SNAPSHOT'
|
compileOnly 'io.papermc.paper:paper-api:1.20.1-R0.1-SNAPSHOT'
|
||||||
compileOnly 'me.clip:placeholderapi:2.11.6'
|
compileOnly 'me.clip:placeholderapi:2.11.6'
|
||||||
compileOnly 'org.black_ixx:playerpoints:3.2.7'
|
compileOnly 'org.black_ixx:playerpoints:3.2.7'
|
||||||
compileOnly 'net.luckperms:api:5.4'
|
compileOnly 'net.luckperms:api:5.4'
|
||||||
|
|
@ -44,7 +44,7 @@ test {
|
||||||
}
|
}
|
||||||
|
|
||||||
jar {
|
jar {
|
||||||
archiveFileName = 'LoChat-1.5.5.jar'
|
archiveFileName = 'LoChat-1.5.5-1.20.1.jar'
|
||||||
from {
|
from {
|
||||||
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package com.loki.lochat.listeners;
|
package com.loki.lochat.listeners;
|
||||||
|
|
||||||
import com.loki.lochat.LoChat;
|
import com.loki.lochat.LoChat;
|
||||||
|
import com.loki.lochat.gradient.util.FoliaUtil;
|
||||||
import com.loki.lochat.managers.AntiSpamManager;
|
import com.loki.lochat.managers.AntiSpamManager;
|
||||||
import io.papermc.paper.event.player.AsyncChatEvent;
|
import io.papermc.paper.event.player.AsyncChatEvent;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
|
|
@ -30,10 +31,10 @@ public class ChatListener implements Listener {
|
||||||
Component originalMessage = event.message();
|
Component originalMessage = event.message();
|
||||||
String plainMessage = PLAIN.serialize(originalMessage);
|
String plainMessage = PLAIN.serialize(originalMessage);
|
||||||
|
|
||||||
// Folia-safe
|
// Paper/Folia-safe
|
||||||
player.getScheduler().run(plugin, task -> {
|
FoliaUtil.runEntityTask(plugin, player, () -> {
|
||||||
processChat(player, originalMessage, plainMessage);
|
processChat(player, originalMessage, plainMessage);
|
||||||
}, null);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processChat(Player player, Component message, String plainMessage) {
|
private void processChat(Player player, Component message, String plainMessage) {
|
||||||
|
|
@ -125,6 +126,9 @@ public class ChatListener implements Listener {
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
case ALLOWED -> {
|
||||||
|
// Сообщение прошло проверку, продолжаем
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,12 +2,12 @@ package com.loki.lochat.managers;
|
||||||
|
|
||||||
import com.loki.lochat.LoChat;
|
import com.loki.lochat.LoChat;
|
||||||
import com.loki.lochat.utils.ChatFormatter;
|
import com.loki.lochat.utils.ChatFormatter;
|
||||||
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
|
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
import org.bukkit.configuration.file.FileConfiguration;
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -18,7 +18,7 @@ public class AutoMessageManager {
|
||||||
private final LoChat plugin;
|
private final LoChat plugin;
|
||||||
private final Random random = new Random();
|
private final Random random = new Random();
|
||||||
private final AtomicInteger currentIndex = new AtomicInteger(0);
|
private final AtomicInteger currentIndex = new AtomicInteger(0);
|
||||||
private ScheduledTask task;
|
private BukkitTask task;
|
||||||
|
|
||||||
private Map<String, List<String>> messages;
|
private Map<String, List<String>> messages;
|
||||||
private List<String> messageOrder;
|
private List<String> messageOrder;
|
||||||
|
|
@ -108,9 +108,10 @@ public class AutoMessageManager {
|
||||||
int intervalSeconds = plugin.getConfigManager().getAutoMessagesInterval();
|
int intervalSeconds = plugin.getConfigManager().getAutoMessagesInterval();
|
||||||
long intervalTicks = intervalSeconds * 20L;
|
long intervalTicks = intervalSeconds * 20L;
|
||||||
|
|
||||||
task = plugin.getServer().getGlobalRegionScheduler().runAtFixedRate(
|
// Используем FoliaUtil для совместимости с Paper и Folia
|
||||||
|
task = Bukkit.getScheduler().runTaskTimer(
|
||||||
plugin,
|
plugin,
|
||||||
scheduledTask -> broadcastNextMessage(),
|
this::broadcastNextMessage,
|
||||||
intervalTicks,
|
intervalTicks,
|
||||||
intervalTicks
|
intervalTicks
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,10 @@
|
||||||
name: LoChat
|
name: LoChat
|
||||||
version: '1.5.5'
|
version: '1.5.5-1.20.1'
|
||||||
main: com.loki.lochat.LoChat
|
main: com.loki.lochat.LoChat
|
||||||
api-version: '1.21'
|
api-version: '1.20'
|
||||||
folia-supported: true
|
folia-supported: false
|
||||||
author: loki
|
author: loki
|
||||||
description: Advanced chat plugin for Folia with gradient nicks
|
description: Advanced chat plugin for Paper 1.20.1 with gradient nicks
|
||||||
|
|
||||||
softdepend:
|
softdepend:
|
||||||
- PlaceholderAPI
|
- PlaceholderAPI
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue