Adds commands and listeners
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
# PixelTalk
|
||||||
|
|
||||||
|
PixelTalk is a comprehensive socialization plugin for Minecraft teenagers, designed to encourage friendly interactions and maintain a healthy, moderated environment.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
- **Questionnaires**: New players must complete a profile setup on their first join (Preferred Language, Interests, Age 6-18).
|
||||||
|
- **Points System**: Players are assigned social points.
|
||||||
|
- Negative actions (e.g., PvP, Profanity) result in automatic deduction of points.
|
||||||
|
- If a player's points drop to 0, they receive an automatic temporary ban.
|
||||||
|
- **Reporting System**: Integrated `/report` command for players to alert moderators of misconduct.
|
||||||
|
- **PlasmoVoice Integration**: Automatically dumps audio recordings when a report is filed (optional).
|
||||||
|
- **MongoDB Storage**: Profiles, scores, and data are securely stored using MongoDB.
|
||||||
|
|
||||||
|
## Installation
|
||||||
|
1. Drop the compiled `PixelTalk.jar` into your server's `plugins` folder.
|
||||||
|
2. Configure your MongoDB connection and messages in `config.yml`.
|
||||||
|
3. (Optional) Install `PlasmoVoice` on your server for voice chat & audio dumping features.
|
||||||
|
4. Start the server!
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
# PixelTalk (עברית)
|
||||||
|
|
||||||
|
PixelTalk הוא תוסף (פלאגין) סוציאליזציה מקיף לשרתי מיינקראפט לבני נוער, שנועד לעודד אינטראקציות חברתיות חיוביות ולשמור על סביבה בטוחה ומפוקחת.
|
||||||
|
|
||||||
|
## תכונות מרכזיות
|
||||||
|
- **שאלון היכרות**: שחקנים חדשים נדרשים למלא פרופיל אישי בהתחברותם הראשונה (שפה מועדפת, תחומי עניין וגיל 6-18).
|
||||||
|
- **מערכת נקודות**: לכל שחקן יש נקודות חברתיות.
|
||||||
|
- פעולות שליליות לשחקנים אחרים (כגון קללות, או תקיפה ב-PvP) מפחיתות נקודות באופן אוטומטי.
|
||||||
|
- שחקן שמגיע ל-0 נקודות יקבל חסימה (Ban) זמנית מהשרת באופן אוטומטי.
|
||||||
|
- **מערכת דיווחים**: פקודת `/report` מאפשרת לשחקנים לדווח לצוות השרת על התנהגות בלתי הולמת.
|
||||||
|
- **תמיכה ב-PlasmoVoice (אופציונלי)**: במקרה של דיווח, הפלאגין יודע לשמור באופן אוטומטי הקלטות שמע לגיבוי.
|
||||||
|
- **אחסון MongoDB**: כל נתוני הפרופילים והניקוד נשמרים בצורה יעילה ומאובטחת במסד נתונים מסוג MongoDB.
|
||||||
|
|
||||||
|
## התקנה מומלצת
|
||||||
|
1. הוסיפו את הקובץ `PixelTalk.jar` המקומפל לתיקיית ה-`plugins` בשרת שלכם.
|
||||||
|
2. הגדירו את חיבור ה-MongoDB ושאר ההגדרות בקובץ `config.yml`.
|
||||||
|
3. (אופציונלי) התקינו את פלאגין ה-`PlasmoVoice` בשרת שלכם לתמיכה בניהול צ'אט קולי והקלטות שמע.
|
||||||
|
4. הפעילו את השרת!
|
||||||
@@ -11,10 +11,8 @@ repositories {
|
|||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
|
compileOnly("io.papermc.paper:paper-api:1.21.11-R0.1-SNAPSHOT")
|
||||||
// MongoDB driver (will be loaded at runtime via PluginLoader)
|
|
||||||
compileOnly("org.mongodb:mongodb-driver-sync:5.0.1")
|
compileOnly("org.mongodb:mongodb-driver-sync:5.0.1")
|
||||||
|
|
||||||
// PlasmoVoice API (optional)
|
|
||||||
compileOnly("su.plo.voice.api:server:2.1.8")
|
compileOnly("su.plo.voice.api:server:2.1.8")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -66,7 +66,6 @@ public class ReportCommand implements BasicCommand {
|
|||||||
}
|
}
|
||||||
String reason = reasonBuilder.toString().trim();
|
String reason = reasonBuilder.toString().trim();
|
||||||
|
|
||||||
// Log report
|
|
||||||
databaseManager.logReport(uuid, target.getUniqueId(), reason);
|
databaseManager.logReport(uuid, target.getUniqueId(), reason);
|
||||||
cooldowns.put(uuid, now);
|
cooldowns.put(uuid, now);
|
||||||
|
|
||||||
@@ -74,7 +73,6 @@ public class ReportCommand implements BasicCommand {
|
|||||||
voiceIntegration.dumpAudio(target.getUniqueId(), reason);
|
voiceIntegration.dumpAudio(target.getUniqueId(), reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Notify OPs
|
|
||||||
String opMsg = Messages.REPORT_NOTIFICATION_OP
|
String opMsg = Messages.REPORT_NOTIFICATION_OP
|
||||||
.replace("<reporter>", player.getName())
|
.replace("<reporter>", player.getName())
|
||||||
.replace("<target>", target.getName())
|
.replace("<target>", target.getName())
|
||||||
|
|||||||
@@ -18,8 +18,6 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
String lowerCaseMsg = message.toLowerCase();
|
String lowerCaseMsg = message.toLowerCase();
|
||||||
|
|
||||||
// Simple word checking.
|
|
||||||
// For a more advanced filter, regex boundaries should be used.
|
|
||||||
for (String word : badWords) {
|
for (String word : badWords) {
|
||||||
if (lowerCaseMsg.contains(word.toLowerCase())) {
|
if (lowerCaseMsg.contains(word.toLowerCase())) {
|
||||||
return true;
|
return true;
|
||||||
@@ -33,7 +31,6 @@ public class ProfanityFilter {
|
|||||||
|
|
||||||
String censored = message;
|
String censored = message;
|
||||||
for (String word : badWords) {
|
for (String word : badWords) {
|
||||||
// Case-insensitive replacement
|
|
||||||
censored = Pattern.compile(Pattern.quote(word), Pattern.CASE_INSENSITIVE).matcher(censored).replaceAll("***");
|
censored = Pattern.compile(Pattern.quote(word), Pattern.CASE_INSENSITIVE).matcher(censored).replaceAll("***");
|
||||||
}
|
}
|
||||||
return censored;
|
return censored;
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ public class ChatListener implements Listener {
|
|||||||
|
|
||||||
String plainMessage = PlainTextComponentSerializer.plainText().serialize(event.message());
|
String plainMessage = PlainTextComponentSerializer.plainText().serialize(event.message());
|
||||||
|
|
||||||
// Check if answering questionnaire
|
|
||||||
if (questionnaireManager.isAnswering(uuid)) {
|
if (questionnaireManager.isAnswering(uuid)) {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
PlayerData data = scoreManager.getPlayerData(uuid);
|
PlayerData data = scoreManager.getPlayerData(uuid);
|
||||||
|
|||||||
@@ -28,16 +28,13 @@ public class PlayerJoinListener implements Listener {
|
|||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
UUID uuid = player.getUniqueId();
|
UUID uuid = player.getUniqueId();
|
||||||
|
|
||||||
// 1. Load player data into cache
|
|
||||||
scoreManager.loadPlayer(uuid);
|
scoreManager.loadPlayer(uuid);
|
||||||
|
|
||||||
// 2. Check registration status
|
|
||||||
PlayerData data = scoreManager.getPlayerData(uuid);
|
PlayerData data = scoreManager.getPlayerData(uuid);
|
||||||
if (data != null && !data.isRegistered()) {
|
if (data != null && !data.isRegistered()) {
|
||||||
questionnaireManager.startQuestionnaire(player);
|
questionnaireManager.startQuestionnaire(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 3. Update their tab
|
|
||||||
tabManager.updatePlayerTab(player);
|
tabManager.updatePlayerTab(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ public class PlayerQuitListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
// Save to DB and remove from cache
|
|
||||||
scoreManager.unloadPlayer(event.getPlayer().getUniqueId());
|
scoreManager.unloadPlayer(event.getPlayer().getUniqueId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ public final class pixeltalk extends JavaPlugin {
|
|||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
saveDefaultConfig();
|
saveDefaultConfig();
|
||||||
|
|
||||||
// 1. Initialize Database
|
|
||||||
try {
|
try {
|
||||||
databaseManager = new DatabaseManager(getLogger(), getConfig());
|
databaseManager = new DatabaseManager(getLogger(), getConfig());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -34,13 +33,11 @@ public final class pixeltalk extends JavaPlugin {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Initialize Managers
|
|
||||||
scoreManager = new ScoreManager(databaseManager, getConfig());
|
scoreManager = new ScoreManager(databaseManager, getConfig());
|
||||||
QuestionnaireManager questionnaireManager = new QuestionnaireManager(databaseManager);
|
QuestionnaireManager questionnaireManager = new QuestionnaireManager(databaseManager);
|
||||||
TabManager tabManager = new TabManager(this, scoreManager);
|
TabManager tabManager = new TabManager(this, scoreManager);
|
||||||
ProfanityFilter profanityFilter = new ProfanityFilter(getConfig());
|
ProfanityFilter profanityFilter = new ProfanityFilter(getConfig());
|
||||||
|
|
||||||
// 3. Optional Voice Integration
|
|
||||||
if (Bukkit.getPluginManager().isPluginEnabled("PlasmoVoice")) {
|
if (Bukkit.getPluginManager().isPluginEnabled("PlasmoVoice")) {
|
||||||
getLogger().info("PlasmoVoice found! Enabling voice integration.");
|
getLogger().info("PlasmoVoice found! Enabling voice integration.");
|
||||||
try {
|
try {
|
||||||
@@ -51,13 +48,11 @@ public final class pixeltalk extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 4. Register Listeners
|
|
||||||
getServer().getPluginManager().registerEvents(new ChatListener(scoreManager, questionnaireManager, profanityFilter, getConfig()), this);
|
getServer().getPluginManager().registerEvents(new ChatListener(scoreManager, questionnaireManager, profanityFilter, getConfig()), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerJoinListener(scoreManager, questionnaireManager, tabManager), this);
|
getServer().getPluginManager().registerEvents(new PlayerJoinListener(scoreManager, questionnaireManager, tabManager), this);
|
||||||
getServer().getPluginManager().registerEvents(new PlayerQuitListener(scoreManager), this);
|
getServer().getPluginManager().registerEvents(new PlayerQuitListener(scoreManager), this);
|
||||||
getServer().getPluginManager().registerEvents(new PvPListener(scoreManager, getConfig()), this);
|
getServer().getPluginManager().registerEvents(new PvPListener(scoreManager, getConfig()), this);
|
||||||
|
|
||||||
// 5. Register Commands
|
|
||||||
this.getLifecycleManager().registerEventHandler(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, event -> {
|
this.getLifecycleManager().registerEventHandler(io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents.COMMANDS, event -> {
|
||||||
event.registrar().register("report", new ReportCommand(databaseManager, getConfig(), voiceIntegration));
|
event.registrar().register("report", new ReportCommand(databaseManager, getConfig(), voiceIntegration));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ public class VoiceIntegration {
|
|||||||
private final Plugin plugin;
|
private final Plugin plugin;
|
||||||
private final Logger logger;
|
private final Logger logger;
|
||||||
|
|
||||||
// UUID -> Ticks speaking
|
|
||||||
private final Map<UUID, Integer> speakingTime = new HashMap<>();
|
private final Map<UUID, Integer> speakingTime = new HashMap<>();
|
||||||
|
|
||||||
public VoiceIntegration(Plugin plugin, ScoreManager scoreManager, FileConfiguration config) {
|
public VoiceIntegration(Plugin plugin, ScoreManager scoreManager, FileConfiguration config) {
|
||||||
|
|||||||
Reference in New Issue
Block a user