Added "speakrandom" permission and command that will randomly send one of the configuration file-defined Herobrine chat messages to the specified user.
This commit is contained in:
parent
c7ae3e5b59
commit
7d8a81cd18
@ -8,7 +8,7 @@ import net.theprogrammersworld.herobrine.Herobrine;
|
||||
|
||||
public class Message {
|
||||
|
||||
public static void SendMessage(Player player) {
|
||||
public static void sendRandomMessage(Player player) {
|
||||
if (Herobrine.getPluginCore().getConfigDB().SendMessages == true) {
|
||||
|
||||
int count = Herobrine.getPluginCore().getConfigDB().useMessages.size();
|
||||
|
@ -55,7 +55,7 @@ public class Attack extends Core {
|
||||
|
||||
PluginCore.HerobrineNPC.moveTo(tploc);
|
||||
|
||||
Message.SendMessage(AICore.PlayerTarget);
|
||||
Message.sendRandomMessage(AICore.PlayerTarget);
|
||||
|
||||
StartHandler();
|
||||
|
||||
|
@ -49,7 +49,7 @@ public class Totem extends Core {
|
||||
&& ploc.getX() - 10 < loc.getX() && ploc.getZ() + 10 > loc.getZ()
|
||||
&& ploc.getZ() - 10 < loc.getZ()) {
|
||||
|
||||
Message.SendMessage(onlinePlayer);
|
||||
Message.sendRandomMessage(onlinePlayer);
|
||||
if (PluginCore.getConfigDB().UsePotionEffects) {
|
||||
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
|
||||
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
|
||||
@ -97,7 +97,7 @@ public class Totem extends Core {
|
||||
&& ploc.getZ() - 20 < loc.getZ()
|
||||
) {
|
||||
|
||||
Message.SendMessage(onlinePlayer);
|
||||
Message.sendRandomMessage(onlinePlayer);
|
||||
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.CONFUSION, 1000, 1));
|
||||
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000, 1));
|
||||
onlinePlayer.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 1000, 1));
|
||||
|
@ -21,8 +21,8 @@ public class CmdExecutor implements CommandExecutor {
|
||||
private Logger log = null;
|
||||
private HashMap<String, SubCommand> subCommands = new HashMap<String, SubCommand>();
|
||||
private String[] helpCommandOrder = {
|
||||
"reload", "cancel", "allworlds", "position", "attack", "haunt", "heads",
|
||||
"bury", "curse", "burn", "pyramid", "cave", "temple", "graveyard" };
|
||||
"reload", "cancel", "allworlds", "position", "attack", "haunt", "heads", "bury",
|
||||
"curse", "burn", "pyramid", "cave", "temple", "graveyard", "speakrandom" };
|
||||
|
||||
public CmdExecutor(Herobrine p) {
|
||||
log = Herobrine.log;
|
||||
@ -41,6 +41,7 @@ public class CmdExecutor implements CommandExecutor {
|
||||
subCommands.put("allworlds", new CmdAllWorlds(p, log));
|
||||
subCommands.put("position", new CmdPosition(p, log));
|
||||
subCommands.put("heads", new CmdHeads(p, log));
|
||||
subCommands.put("speakrandom", new CmdSpeakRandom(p, log));
|
||||
}
|
||||
|
||||
public void ShowHelp(Player player) {
|
||||
|
@ -0,0 +1,50 @@
|
||||
package net.theprogrammersworld.herobrine.commands;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import net.theprogrammersworld.herobrine.Herobrine;
|
||||
import net.theprogrammersworld.herobrine.AI.Message;
|
||||
|
||||
public class CmdSpeakRandom extends SubCommand {
|
||||
|
||||
public CmdSpeakRandom(Herobrine plugin, Logger log) {
|
||||
super(plugin, log);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(Player player, String[] args) {
|
||||
if (args.length > 1) {
|
||||
Player target = Bukkit.getServer().getPlayer(args[1]);
|
||||
|
||||
if (target == null) {
|
||||
sendMessage(player, ChatColor.RED + "[Herobrine] Herobrine cannot send a random message to " + args[1] + " because they are offline.");
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!target.isOnline()) {
|
||||
sendMessage(player, ChatColor.RED + "[Herobrine] Herobrine cannot send a random message to " + args[1] + " because they are offline.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Message.sendRandomMessage(target);
|
||||
sendMessage(player, ChatColor.RED + "[Herobrine] Herobrine sent a random message to " + args[1] + ".");
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String help() {
|
||||
return ChatColor.GREEN + "/herobrine speakrandom <player>";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String helpDesc() {
|
||||
return ChatColor.GREEN + "Sends a random message from Herobrine defined in the configuration file to the player";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user