This repository has been archived by the owner on Dec 5, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
72 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/main/java/me/arasple/mc/trchat/chat/listeners/ListenerTrChatInfo.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package me.arasple.mc.trchat.chat.listeners; | ||
|
||
import io.izzel.taboolib.module.inject.TListener; | ||
import io.izzel.taboolib.module.locale.TLocale; | ||
import io.izzel.taboolib.util.Strings; | ||
import io.izzel.taboolib.util.lite.SoundPack; | ||
import me.arasple.mc.trchat.TrChat; | ||
import me.arasple.mc.trchat.chat.ChatFormats; | ||
import me.arasple.mc.trchat.filter.ChatFilter; | ||
import me.arasple.mc.trchat.func.ChatFunctions; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.EventPriority; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.AsyncPlayerChatEvent; | ||
import org.bukkit.event.player.PlayerCommandPreprocessEvent; | ||
|
||
/** | ||
* @author Arasple | ||
* @date 2019/11/30 21:56 | ||
*/ | ||
@TListener | ||
public class ListenerTrChatInfo implements Listener { | ||
|
||
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true) | ||
public void onChat(AsyncPlayerChatEvent e) { | ||
e.setCancelled(react(e.getPlayer(), e.getMessage().startsWith("#") ? e.getMessage().substring(1) : null)); | ||
|
||
if ("#TRCHAT-RELOAD".equals(e.getMessage()) && e.getPlayer().hasPermission("trchat.admin")) { | ||
ChatFormats.loadFormats(e.getPlayer()); | ||
ChatFilter.loadFilter(true, e.getPlayer()); | ||
ChatFunctions.loadFunctions(e.getPlayer()); | ||
e.setCancelled(true); | ||
} | ||
} | ||
|
||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) | ||
public void onCommand(PlayerCommandPreprocessEvent e) { | ||
e.setCancelled(react(e.getPlayer(), e.getMessage().substring(1))); | ||
} | ||
|
||
private boolean react(Player p, String message) { | ||
if (!Strings.isBlank(message) && ("trchatr".equalsIgnoreCase(message) || "trixeychat".equalsIgnoreCase(message))) { | ||
TLocale.Display.sendTitle(p, "§3§lTr§b§lChat", "§7Designed by §6Arasple", 10, 35, 10); | ||
TLocale.Display.sendActionBar(p, Strings.replaceWithOrder( | ||
"§2Running version §av{0}§7", | ||
TrChat.getTrVersion() | ||
)); | ||
new SoundPack("BLOCK_NOTE_BLOCK_PLING-1-2").play(p); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters