Moved /me, /chat(/speak), /shrug, /say, /sayn, and the Normal Chat Event
into it's own module called Chat. Moved the Illumination Module into the Misc Module.
This commit is contained in:
37
src/com/redstoner/modules/chat/Chat.cmd
Normal file
37
src/com/redstoner/modules/chat/Chat.cmd
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
command me {
|
||||||
|
perm utils.me;
|
||||||
|
[string:text...] {
|
||||||
|
help /me's in chat.;
|
||||||
|
run me text;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command chat {
|
||||||
|
alias speak;
|
||||||
|
[string:message...] {
|
||||||
|
perm utils.chat;
|
||||||
|
run chat message;
|
||||||
|
help A way to speak in normal chat with normal formatting if you have ACT or CGT on.;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command shrug {
|
||||||
|
[string:message...] {
|
||||||
|
perm utils.shrug;
|
||||||
|
run shrug message;
|
||||||
|
help Appends the shrug emoticon to the end of your message.;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command say {
|
||||||
|
[string:message...] {
|
||||||
|
perm utils.say;
|
||||||
|
run say message;
|
||||||
|
help A replacement for the default say command to make the format be more consistant.;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
command sayn {
|
||||||
|
[string:name] [string:message...] {
|
||||||
|
perm utils.sayn;
|
||||||
|
type console;
|
||||||
|
run sayn name message;
|
||||||
|
help A replacement for the default say command to make the format be more consistant.;
|
||||||
|
}
|
||||||
|
}
|
||||||
90
src/com/redstoner/modules/chat/Chat.java
Normal file
90
src/com/redstoner/modules/chat/Chat.java
Normal file
@@ -0,0 +1,90 @@
|
|||||||
|
package com.redstoner.modules.chat;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
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 com.nemez.cmdmgr.Command;
|
||||||
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
|
import com.redstoner.annotations.Commands;
|
||||||
|
import com.redstoner.annotations.Version;
|
||||||
|
import com.redstoner.coremods.moduleLoader.ModuleLoader;
|
||||||
|
import com.redstoner.misc.CommandHolderType;
|
||||||
|
import com.redstoner.misc.Utils;
|
||||||
|
import com.redstoner.modules.Module;
|
||||||
|
import com.redstoner.modules.ignore.Ignore;
|
||||||
|
|
||||||
|
import net.nemez.chatapi.ChatAPI;
|
||||||
|
|
||||||
|
@Commands(CommandHolderType.File)
|
||||||
|
@AutoRegisterListener
|
||||||
|
@Version(major = 4, minor = 0, revision = 0, compatible = 4)
|
||||||
|
public class Chat implements Module, Listener{
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
String msg = event.getMessage();
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
if (player.hasPermission("utils.chat"))
|
||||||
|
Utils.broadcast(" " + Utils.getName(player), " §7→§r " + ChatAPI.colorify(player, msg),
|
||||||
|
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(player) : null);
|
||||||
|
else
|
||||||
|
player.sendMessage("§8[§cServer§8] You don't have permission to chat.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(hook = "me")
|
||||||
|
public boolean me(CommandSender sender, String text)
|
||||||
|
{
|
||||||
|
String name;
|
||||||
|
if (sender instanceof Player)
|
||||||
|
name = ((Player) sender).getDisplayName();
|
||||||
|
else
|
||||||
|
name = "§9" + sender.getName();
|
||||||
|
text = ChatAPI.colorify(sender, text);
|
||||||
|
Utils.broadcast(" §7- " + name + " §7⇦ ", text,
|
||||||
|
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(hook = "chat")
|
||||||
|
public boolean chat(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
String name = Utils.getName(sender);
|
||||||
|
Utils.broadcast(" " + name, " §7→§r " + ChatAPI.colorify(sender, message),
|
||||||
|
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(hook = "say")
|
||||||
|
public boolean say(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
String name = Utils.getName(sender);
|
||||||
|
Utils.broadcast(" §7[§9" + name.replaceAll("[^0-9a-zA-Z§&\\[\\]]", "") + "§7]: ",
|
||||||
|
"§r" + ChatAPI.colorify(null, message),
|
||||||
|
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(hook = "sayn")
|
||||||
|
public boolean say(CommandSender sender, String name, String message)
|
||||||
|
{
|
||||||
|
Utils.broadcast(" §7[§9" + ChatAPI.colorify(sender, name) + "§7]: ", "§r" + ChatAPI.colorify(null, message),
|
||||||
|
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(hook = "shrug")
|
||||||
|
public boolean shrug(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
String name = Utils.getName(sender);
|
||||||
|
Utils.broadcast(" " + name, " §7→§r " + ChatAPI.colorify(sender, message) + " ¯\\_(ツ)_/¯",
|
||||||
|
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,10 +8,6 @@ import org.bukkit.Bukkit;
|
|||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
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.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
|
|
||||||
import com.nemez.cmdmgr.Command;
|
import com.nemez.cmdmgr.Command;
|
||||||
@@ -26,27 +22,13 @@ import com.redstoner.misc.Utils;
|
|||||||
import com.redstoner.modules.Module;
|
import com.redstoner.modules.Module;
|
||||||
import com.redstoner.modules.datamanager.DataManager;
|
import com.redstoner.modules.datamanager.DataManager;
|
||||||
|
|
||||||
import net.nemez.chatapi.ChatAPI;
|
|
||||||
import net.nemez.chatapi.click.Message;
|
import net.nemez.chatapi.click.Message;
|
||||||
|
|
||||||
|
|
||||||
@Commands(CommandHolderType.File)
|
@Commands(CommandHolderType.File)
|
||||||
@AutoRegisterListener
|
@AutoRegisterListener
|
||||||
@Version(major = 4, minor = 0, revision = 0, compatible = 4)
|
@Version(major = 4, minor = 0, revision = 0, compatible = 4)
|
||||||
public class Ignore implements Module, Listener{
|
public class Ignore implements Module {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event)
|
|
||||||
{
|
|
||||||
Player player = event.getPlayer();
|
|
||||||
String msg = event.getMessage();
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
if (player.hasPermission("utils.chat"))
|
|
||||||
Utils.broadcast(" " + player.getDisplayName(), " §7→§r " + ChatAPI.colorify(player, msg), getIgnoredBy(player));
|
|
||||||
else
|
|
||||||
player.sendMessage("§8[§cServer§8] You don't have permission to chat.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(hook = "unignore", async = AsyncType.ALWAYS)
|
@Command(hook = "unignore", async = AsyncType.ALWAYS)
|
||||||
public boolean unignore(CommandSender sender, String player)
|
public boolean unignore(CommandSender sender, String player)
|
||||||
|
|||||||
@@ -1,50 +0,0 @@
|
|||||||
package com.redstoner.modules.illumination;
|
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffect;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.nemez.cmdmgr.Command;
|
|
||||||
import com.redstoner.annotations.Commands;
|
|
||||||
import com.redstoner.annotations.Version;
|
|
||||||
import com.redstoner.misc.CommandHolderType;
|
|
||||||
import com.redstoner.modules.Module;
|
|
||||||
|
|
||||||
@Commands(CommandHolderType.String)
|
|
||||||
@Version(major = 4, minor = 0, revision = 0, compatible = 4)
|
|
||||||
public class Illumination implements Module
|
|
||||||
{
|
|
||||||
PotionEffect effect = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false);
|
|
||||||
|
|
||||||
@Command(hook = "illuminate")
|
|
||||||
public void illuminate(CommandSender sender)
|
|
||||||
{
|
|
||||||
Player player = (Player) sender;
|
|
||||||
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION))
|
|
||||||
{
|
|
||||||
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
|
||||||
getLogger().message(sender, "Night Vision Disabled.");
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
player.addPotionEffect(effect, true);
|
|
||||||
getLogger().message(sender, "Night Vision Enabled.");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// @noformat
|
|
||||||
@Override
|
|
||||||
public String getCommandString()
|
|
||||||
{
|
|
||||||
return "command nightvision {\n" +
|
|
||||||
" [empty] {\n" +
|
|
||||||
" run illuminate;\n" +
|
|
||||||
" type player;\n" +
|
|
||||||
" help Gives the player infinte night vision;\n" +
|
|
||||||
" perm utils.illuminate;\n" +
|
|
||||||
" }\n" +
|
|
||||||
"}";
|
|
||||||
}
|
|
||||||
// @format
|
|
||||||
}
|
|
||||||
@@ -25,13 +25,6 @@ command ping {
|
|||||||
run ping2 password;
|
run ping2 password;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command me {
|
|
||||||
perm utils.me;
|
|
||||||
[string:text...] {
|
|
||||||
help /me's in chat.;
|
|
||||||
run me text;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
command sudo {
|
command sudo {
|
||||||
perm utils.sudo;
|
perm utils.sudo;
|
||||||
[string:name] [string:command...] {
|
[string:name] [string:command...] {
|
||||||
@@ -46,33 +39,12 @@ command hasperm {
|
|||||||
help Checks if a player has a given permission node or not. Returns \"true/false\" in chat. When -f is set, it returns it unformatted.;
|
help Checks if a player has a given permission node or not. Returns \"true/false\" in chat. When -f is set, it returns it unformatted.;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
command say {
|
command nightvision {
|
||||||
[string:message...] {
|
alias nv;
|
||||||
perm utils.say;
|
[empty] {
|
||||||
run say message;
|
run illuminate;
|
||||||
help A replacement for the default say command to make the format be more consistant.;
|
type player;
|
||||||
}
|
help Gives the player infinte night vision;
|
||||||
}
|
perm utils.illuminate;
|
||||||
command sayn {
|
}
|
||||||
[string:name] [string:message...] {
|
|
||||||
perm utils.sayn;
|
|
||||||
type console;
|
|
||||||
run sayn name message;
|
|
||||||
help A replacement for the default say command to make the format be more consistant.;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
command shrug {
|
|
||||||
[string:message...] {
|
|
||||||
perm utils.shrug;
|
|
||||||
run shrug message;
|
|
||||||
help Appends the shrug emoticon to the end of your message.;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
command chat {
|
|
||||||
alias speak;
|
|
||||||
[string:message...] {
|
|
||||||
perm utils.speak;
|
|
||||||
run chat message;
|
|
||||||
help A way to speak in normal chat with normal formatting if you have ACT or CGT on.;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -16,6 +16,8 @@ import org.bukkit.event.block.BlockFromToEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
|
|
||||||
@@ -23,12 +25,9 @@ import com.nemez.cmdmgr.Command;
|
|||||||
import com.redstoner.annotations.AutoRegisterListener;
|
import com.redstoner.annotations.AutoRegisterListener;
|
||||||
import com.redstoner.annotations.Commands;
|
import com.redstoner.annotations.Commands;
|
||||||
import com.redstoner.annotations.Version;
|
import com.redstoner.annotations.Version;
|
||||||
import com.redstoner.coremods.moduleLoader.ModuleLoader;
|
|
||||||
import com.redstoner.misc.CommandHolderType;
|
import com.redstoner.misc.CommandHolderType;
|
||||||
import com.redstoner.misc.Utils;
|
import com.redstoner.misc.Utils;
|
||||||
import com.redstoner.modules.Module;
|
import com.redstoner.modules.Module;
|
||||||
import com.redstoner.modules.ignore.Ignore;
|
|
||||||
|
|
||||||
import net.nemez.chatapi.ChatAPI;
|
import net.nemez.chatapi.ChatAPI;
|
||||||
import net.nemez.chatapi.click.Message;
|
import net.nemez.chatapi.click.Message;
|
||||||
|
|
||||||
@@ -170,56 +169,6 @@ public class Misc implements Module, Listener
|
|||||||
return ((CraftPlayer) player).getHandle().ping;
|
return ((CraftPlayer) player).getHandle().ping;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(hook = "me")
|
|
||||||
public boolean me(CommandSender sender, String text)
|
|
||||||
{
|
|
||||||
String name;
|
|
||||||
if (sender instanceof Player)
|
|
||||||
name = ((Player) sender).getDisplayName();
|
|
||||||
else
|
|
||||||
name = "§9" + sender.getName();
|
|
||||||
text = ChatAPI.colorify(sender, text);
|
|
||||||
Utils.broadcast(" §7- " + name + " §7⇦ ", text,
|
|
||||||
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(hook = "chat")
|
|
||||||
public boolean chat(CommandSender sender, String message)
|
|
||||||
{
|
|
||||||
String name = Utils.getName(sender);
|
|
||||||
Utils.broadcast(" " + name, " §7→§r " + ChatAPI.colorify(sender, message),
|
|
||||||
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(hook = "say")
|
|
||||||
public boolean say(CommandSender sender, String message)
|
|
||||||
{
|
|
||||||
String name = Utils.getName(sender);
|
|
||||||
Utils.broadcast(" §7[§9" + name.replaceAll("[^0-9a-zA-Z§&\\[\\]]", "") + "§7]: ",
|
|
||||||
"§r" + ChatAPI.colorify(null, message),
|
|
||||||
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(hook = "sayn")
|
|
||||||
public boolean say(CommandSender sender, String name, String message)
|
|
||||||
{
|
|
||||||
Utils.broadcast(" §7[§9" + ChatAPI.colorify(sender, name) + "§7]: ", "§r" + ChatAPI.colorify(null, message),
|
|
||||||
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(hook = "shrug")
|
|
||||||
public boolean shrug(CommandSender sender, String message)
|
|
||||||
{
|
|
||||||
String name = Utils.getName(sender);
|
|
||||||
Utils.broadcast(" " + name, " §7→§r " + ChatAPI.colorify(sender, message) + " ¯\\_(ツ)_/¯",
|
|
||||||
ModuleLoader.exists("Ignore")? Ignore.getIgnoredBy(sender) : null);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Command(hook = "sudo")
|
@Command(hook = "sudo")
|
||||||
public boolean sudo(CommandSender sender, String name, String command)
|
public boolean sudo(CommandSender sender, String name, String command)
|
||||||
{
|
{
|
||||||
@@ -311,4 +260,22 @@ public class Misc implements Module, Listener
|
|||||||
Bukkit.getPluginManager().callEvent(event);
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
return event.isCancelled();
|
return event.isCancelled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PotionEffect nightvision = new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, false, false);
|
||||||
|
|
||||||
|
@Command(hook = "illuminate")
|
||||||
|
public void illuminate(CommandSender sender)
|
||||||
|
{
|
||||||
|
Player player = (Player) sender;
|
||||||
|
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION))
|
||||||
|
{
|
||||||
|
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
|
||||||
|
getLogger().message(sender, "Night Vision Disabled.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.addPotionEffect(nightvision, true);
|
||||||
|
getLogger().message(sender, "Night Vision Enabled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user