Added support for /ignore, improved unlols
This commit is contained in:
parent
2f83a90553
commit
1d1b3453b3
4 changed files with 45 additions and 22 deletions
|
@ -19,11 +19,13 @@ import buttondevteam.chat.commands.UnlolCommand;
|
|||
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
|
||||
import buttondevteam.chat.formatting.*;
|
||||
import buttondevteam.lib.TBMCChatEvent;
|
||||
import buttondevteam.lib.TBMCChatEventBase;
|
||||
import buttondevteam.lib.TBMCCoreAPI;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.TellrawSerializableEnum;
|
||||
import buttondevteam.lib.player.TBMCPlayer;
|
||||
import buttondevteam.lib.player.TBMCPlayerBase;
|
||||
import lombok.val;
|
||||
import buttondevteam.chat.listener.PlayerListener;
|
||||
import buttondevteam.lib.chat.*;
|
||||
|
||||
|
@ -90,7 +92,7 @@ public class ChatProcessing {
|
|||
if (player != null && PluginMain.essentials.getUser(player).isMuted())
|
||||
return true;
|
||||
|
||||
doFunStuff(sender, message);
|
||||
doFunStuff(sender, e, message);
|
||||
|
||||
ChatPlayer mp = null;
|
||||
if (player != null)
|
||||
|
@ -132,6 +134,8 @@ public class ChatProcessing {
|
|||
Objective obj = PluginMain.SB.getObjective(channel.ID);
|
||||
int score = -1;
|
||||
for (Player p : Bukkit.getOnlinePlayers()) {
|
||||
if (PluginMain.essentials.getUser(p).isIgnoredPlayer(PluginMain.essentials.getUser(player)))
|
||||
continue;
|
||||
final int mcScore = VanillaUtils.getMCScoreIfChatOn(p, e);
|
||||
obj.getScore(p.getName())
|
||||
.setScore(p.getUniqueId().equals(player == null ? null : player.getUniqueId()) // p.UniqueID==player?.UniqueID
|
||||
|
@ -303,22 +307,24 @@ public class ChatProcessing {
|
|||
return formatters;
|
||||
}
|
||||
|
||||
static void doFunStuff(CommandSender sender, String message) {
|
||||
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
|
||||
if (PlayerListener.ActiveF && !PlayerListener.Fs.contains(sender) && message.equalsIgnoreCase("F"))
|
||||
PlayerListener.Fs.add(sender);
|
||||
|
||||
String msg = message.toLowerCase();
|
||||
if (msg.contains("lol")) {
|
||||
UnlolCommand.Lastlolornot = true;
|
||||
UnlolCommand.Lastlol = sender;
|
||||
} else {
|
||||
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
|
||||
boolean add = false;
|
||||
if (add = msg.contains("lol"))
|
||||
lld.setLolornot(true);
|
||||
else {
|
||||
for (int i = 0; i < PlayerListener.LaughStrings.length; i++) {
|
||||
if (msg.contains(PlayerListener.LaughStrings[i])) {
|
||||
UnlolCommand.Lastlol = sender;
|
||||
UnlolCommand.Lastlolornot = false;
|
||||
if (add = msg.contains(PlayerListener.LaughStrings[i])) {
|
||||
lld.setLolornot(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (add)
|
||||
UnlolCommand.Lastlol.put(event.getChannel(), lld);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -337,7 +337,7 @@ public class PluginMain extends JavaPlugin { // Translated to Java: 2015.07.15.
|
|||
if (town == null)
|
||||
return new RecipientTestResult("You aren't in a town.");
|
||||
Nation nation = null;
|
||||
int index = -1;
|
||||
int index;
|
||||
if (nationchat) {
|
||||
if (town.hasNation())
|
||||
nation = town.getNation();
|
||||
|
|
|
@ -1,19 +1,24 @@
|
|||
package buttondevteam.chat.commands;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import buttondevteam.lib.TBMCChatEventBase;
|
||||
import buttondevteam.lib.chat.Channel;
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
||||
import lombok.Data;
|
||||
|
||||
@CommandClass(modOnly = false)
|
||||
public final class UnlolCommand extends TBMCCommandBase {
|
||||
|
||||
public static CommandSender Lastlol = null;
|
||||
public static boolean Lastlolornot;
|
||||
public static Map<Channel, LastlolData> Lastlol = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
|
@ -25,16 +30,26 @@ public final class UnlolCommand extends TBMCCommandBase {
|
|||
|
||||
@Override
|
||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
||||
if (Lastlol != null) {
|
||||
if (Lastlol instanceof Player)
|
||||
((Player) Lastlol)
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 2 * 20, 5, false, false));
|
||||
String msg = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName())
|
||||
+ (Lastlolornot ? " unlolled " : " unlaughed ")
|
||||
+ (Lastlol instanceof Player ? ((Player) Lastlol).getDisplayName() : Lastlol.getName());
|
||||
Bukkit.broadcastMessage(msg);
|
||||
Lastlol = null;
|
||||
}
|
||||
LastlolData lol = Lastlol.values().stream().filter(lld -> lld.Chatevent.shouldSendTo(sender))
|
||||
.max((lld1, lld2) -> Long.compare(lld1.Loltime, lld2.Loltime)).orElse(null);
|
||||
if (lol == null)
|
||||
return true;
|
||||
if (lol.Lolowner instanceof Player)
|
||||
((Player) lol.Lolowner)
|
||||
.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 2 * 20, 5, false, false));
|
||||
String msg = (sender instanceof Player ? ((Player) sender).getDisplayName() : sender.getName())
|
||||
+ (lol.Lolornot ? " unlolled " : " unlaughed ")
|
||||
+ (lol.Lolowner instanceof Player ? ((Player) lol.Lolowner).getDisplayName() : lol.Lolowner.getName());
|
||||
Bukkit.broadcastMessage(msg);
|
||||
Lastlol.remove(lol.Chatevent.getChannel());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class LastlolData {
|
||||
private boolean Lolornot;
|
||||
private final CommandSender Lolowner;
|
||||
private final TBMCChatEventBase Chatevent;
|
||||
private final long Loltime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import buttondevteam.chat.ChatPlayer;
|
|||
import buttondevteam.chat.FlairStates;
|
||||
import buttondevteam.chat.PlayerJoinTimerTask;
|
||||
import buttondevteam.chat.PluginMain;
|
||||
import buttondevteam.chat.commands.UnlolCommand;
|
||||
import buttondevteam.lib.player.TBMCPlayerJoinEvent;
|
||||
import buttondevteam.lib.player.TBMCPlayerLoadEvent;
|
||||
import buttondevteam.lib.player.TBMCPlayerSaveEvent;
|
||||
|
@ -111,6 +112,7 @@ public class PlayerJoinLeaveListener implements Listener {
|
|||
}
|
||||
if (deletenick != null)
|
||||
PlayerListener.nicknames.remove(deletenick);
|
||||
UnlolCommand.Lastlol.values().removeIf(lld -> lld.getLolowner().equals(event.getPlayer()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue