More components, broadcasts #98
6 changed files with 129 additions and 84 deletions
|
@ -40,5 +40,34 @@
|
||||||
<orderEntry type="library" name="Maven: org.anjocaido:EssentialsGroupManager:2.10.1" level="project" />
|
<orderEntry type="library" name="Maven: org.anjocaido:EssentialsGroupManager:2.10.1" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:ButtonCore:master-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: net.sourceforge.htmlcleaner:htmlcleaner:2.16" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.jdom:jdom2:2.0.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.reflections:reflections:0.9.10" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.javassist:javassist:3.19.0-GA" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.code.findbugs:annotations:2.0.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.TBMCPlugins.ButtonCore:Towny:8d3b6b6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.vexsoftware:nuvotifier-universal:2.3.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.milkbowl:VaultAPI:master-68f14eca20-1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.16" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.12.2-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.webbukkit:Dynmap-Towny:master-0.60-g924051d-7" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.github.webbukkit:Dynmap:v2.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.nijikokun.bukkit:Permissions:3.1.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: ru.tehkode:PermissionsEx:1.19.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: de.bananaco:bPermissions:2.9.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.platymuus.bukkit.permissions:PermissionsBukkit:1.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.anjocaido:EssentialsGroupManager:2.10.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
|
@ -1,5 +1,6 @@
|
||||||
package buttondevteam.chat;
|
package buttondevteam.chat;
|
||||||
|
|
||||||
|
import buttondevteam.chat.components.fun.FunComponent;
|
||||||
import buttondevteam.chat.components.fun.UnlolCommand;
|
import buttondevteam.chat.components.fun.UnlolCommand;
|
||||||
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
|
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
|
||||||
import buttondevteam.chat.formatting.ChatFormatter;
|
import buttondevteam.chat.formatting.ChatFormatter;
|
||||||
|
@ -7,6 +8,7 @@ import buttondevteam.chat.formatting.TellrawEvent;
|
||||||
import buttondevteam.chat.formatting.TellrawPart;
|
import buttondevteam.chat.formatting.TellrawPart;
|
||||||
import buttondevteam.chat.formatting.TellrawSerializer;
|
import buttondevteam.chat.formatting.TellrawSerializer;
|
||||||
import buttondevteam.chat.listener.PlayerListener;
|
import buttondevteam.chat.listener.PlayerListener;
|
||||||
|
import buttondevteam.core.ComponentManager;
|
||||||
import buttondevteam.core.component.channel.Channel;
|
import buttondevteam.core.component.channel.Channel;
|
||||||
import buttondevteam.lib.TBMCChatEvent;
|
import buttondevteam.lib.TBMCChatEvent;
|
||||||
import buttondevteam.lib.TBMCChatEventBase;
|
import buttondevteam.lib.TBMCChatEventBase;
|
||||||
|
@ -296,11 +298,7 @@ public class ChatProcessing {
|
||||||
}
|
}
|
||||||
ChatPlayer mpp = TBMCPlayer.getPlayer(nottest ? p.getUniqueId() : new UUID(0, 0), ChatPlayer.class);
|
ChatPlayer mpp = TBMCPlayer.getPlayer(nottest ? p.getUniqueId() : new UUID(0, 0), ChatPlayer.class);
|
||||||
if (nottest) {
|
if (nottest) {
|
||||||
if (PluginMain.Instance.notificationSound().get().length() == 0)
|
playPingSound(p);
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
|
|
||||||
else
|
|
||||||
p.playSound(p.getLocation(), PluginMain.Instance.notificationSound().get(), 1.0f,
|
|
||||||
PluginMain.Instance.notificationPitch().get());
|
|
||||||
}
|
}
|
||||||
String color = String.format("§%x", (mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
String color = String.format("§%x", (mpp.GetFlairColor() == 0x00 ? 0xb : mpp.GetFlairColor()));
|
||||||
return color + (nottest ? p.getName() : pn.get()) + "§r"; //Fix name casing, except when testing
|
return color + (nottest ? p.getName() : pn.get()) + "§r"; //Fix name casing, except when testing
|
||||||
|
@ -316,11 +314,7 @@ public class ChatProcessing {
|
||||||
+ match.toLowerCase() + " but was reported as online.");
|
+ match.toLowerCase() + " but was reported as online.");
|
||||||
return "§c" + match + "§r";
|
return "§c" + match + "§r";
|
||||||
}
|
}
|
||||||
if (PluginMain.Instance.notificationSound().get().length() == 0)
|
playPingSound(p);
|
||||||
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
|
|
||||||
else
|
|
||||||
p.playSound(p.getLocation(), PluginMain.Instance.notificationSound().get(), 1.0f,
|
|
||||||
PluginMain.Instance.notificationPitch().get());
|
|
||||||
return PluginMain.essentials.getUser(p).getNickname();
|
return PluginMain.essentials.getUser(p).getNickname();
|
||||||
}
|
}
|
||||||
error.accept("Player nicknamed " + match.toLowerCase()
|
error.accept("Player nicknamed " + match.toLowerCase()
|
||||||
|
@ -331,24 +325,16 @@ public class ChatProcessing {
|
||||||
return formatters;
|
return formatters;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
|
private static void playPingSound(Player p) {
|
||||||
if (PlayerListener.ActiveF && !PlayerListener.Fs.contains(sender) && message.equalsIgnoreCase("F"))
|
if (PluginMain.Instance.notificationSound().get().length() == 0)
|
||||||
PlayerListener.Fs.add(sender);
|
p.playSound(p.getLocation(), Sound.ENTITY_ARROW_HIT_PLAYER, 1.0f, 0.5f); // TODO: Airhorn
|
||||||
|
else
|
||||||
|
p.playSound(p.getLocation(), PluginMain.Instance.notificationSound().get(), 1.0f,
|
||||||
|
PluginMain.Instance.notificationPitch().get());
|
||||||
|
}
|
||||||
|
|
||||||
String msg = message.toLowerCase();
|
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
|
||||||
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
|
val fc=ComponentManager.getIfEnabled(FunComponent.class);
|
||||||
boolean add;
|
if(fc!=null) fc.onChat(sender, event, message);
|
||||||
if (add = msg.contains("lol"))
|
|
||||||
lld.setLolornot(true);
|
|
||||||
else {
|
|
||||||
for (int i = 0; i < PlayerListener.LaughStrings.length; i++) {
|
|
||||||
if (add = msg.contains(PlayerListener.LaughStrings[i])) {
|
|
||||||
lld.setLolornot(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (add)
|
|
||||||
UnlolCommand.Lastlol.put(event.getChannel(), lld);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,87 @@
|
||||||
package buttondevteam.chat.components.fun;
|
package buttondevteam.chat.components.fun;
|
||||||
|
|
||||||
|
import buttondevteam.chat.ChatPlayer;
|
||||||
|
import buttondevteam.chat.PluginMain;
|
||||||
|
import buttondevteam.lib.TBMCChatEventBase;
|
||||||
import buttondevteam.lib.architecture.Component;
|
import buttondevteam.lib.architecture.Component;
|
||||||
|
import buttondevteam.lib.player.TBMCPlayer;
|
||||||
import lombok.val;
|
import lombok.val;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class FunComponent extends Component {
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class FunComponent extends Component implements Listener {
|
||||||
|
private final static String[] LaughStrings = new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"};
|
||||||
|
private boolean ActiveF = false;
|
||||||
|
private ChatPlayer FPlayer = null;
|
||||||
|
private BukkitTask Ftask = null;
|
||||||
|
private ArrayList<CommandSender> Fs = new ArrayList<>();
|
||||||
|
private UnlolCommand command;
|
||||||
@Override
|
@Override
|
||||||
protected void enable() {
|
protected void enable() {
|
||||||
val pc = new PressCommand();
|
val pc = new PressCommand();
|
||||||
registerCommand(pc);
|
registerCommand(pc);
|
||||||
registerListener(pc);
|
registerListener(pc);
|
||||||
|
registerCommand(command=new UnlolCommand());
|
||||||
|
registerListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void disable() {
|
protected void disable() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onChat(CommandSender sender, TBMCChatEventBase event, String message) {
|
||||||
|
if (ActiveF && !Fs.contains(sender) && message.equalsIgnoreCase("F"))
|
||||||
|
Fs.add(sender);
|
||||||
|
|
||||||
|
String msg = message.toLowerCase();
|
||||||
|
val lld = new UnlolCommand.LastlolData(sender, event, System.nanoTime());
|
||||||
|
boolean add;
|
||||||
|
if (add = msg.contains("lol"))
|
||||||
|
lld.setLolornot(true);
|
||||||
|
else {
|
||||||
|
for (int i = 0; i < LaughStrings.length; i++) {
|
||||||
|
if (add = msg.contains(LaughStrings[i])) {
|
||||||
|
lld.setLolornot(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (add)
|
||||||
|
command.Lastlol.put(event.getChannel(), lld);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||||
|
// MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity());
|
||||||
|
if (/* (mgp != null && !mgp.isInMinigame()) && */ new Random().nextBoolean()) { // Don't store Fs for NPCs
|
||||||
|
Runnable tt = () -> {
|
||||||
|
if (ActiveF) {
|
||||||
|
ActiveF = false;
|
||||||
|
if (FPlayer != null && FPlayer.FCount().get() < Integer.MAX_VALUE - 1)
|
||||||
|
FPlayer.FCount().set(FPlayer.FCount().get() + Fs.size());
|
||||||
|
Bukkit.broadcastMessage("§b" + Fs.size() + " " + (Fs.size() == 1 ? "person" : "people")
|
||||||
|
+ " paid their respects.§r");
|
||||||
|
Fs.clear();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
if (Ftask != null) {
|
||||||
|
Ftask.cancel();
|
||||||
|
tt.run(); //Finish previous one
|
||||||
|
}
|
||||||
|
ActiveF = true;
|
||||||
|
Fs.clear();
|
||||||
|
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId(), ChatPlayer.class);
|
||||||
|
FPlayer.FDeaths().set(FPlayer.FDeaths().get() + 1);
|
||||||
|
Bukkit.broadcastMessage("§bPress F to pay respects.§r");
|
||||||
|
Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, tt, 15 * 20);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,7 @@ package buttondevteam.chat.components.fun;
|
||||||
|
|
||||||
import buttondevteam.core.component.channel.Channel;
|
import buttondevteam.core.component.channel.Channel;
|
||||||
import buttondevteam.lib.TBMCChatEventBase;
|
import buttondevteam.lib.TBMCChatEventBase;
|
||||||
import buttondevteam.lib.chat.CommandClass;
|
import buttondevteam.lib.chat.*;
|
||||||
import buttondevteam.lib.chat.TBMCCommandBase;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -15,21 +14,18 @@ import java.util.Comparator;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@CommandClass(modOnly = false)
|
@CommandClass(modOnly = false, helpText = {
|
||||||
public final class UnlolCommand extends TBMCCommandBase {
|
"§6---- Unlol/unlaugh ----",
|
||||||
|
|
||||||
public static Map<Channel, LastlolData> Lastlol = new HashMap<>();
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] GetHelpText(String alias) {
|
|
||||||
return new String[] { "§6---- Unlol/unlaugh ----",
|
|
||||||
"This command is based on a joke between NorbiPeti and Ghostise",
|
"This command is based on a joke between NorbiPeti and Ghostise",
|
||||||
"It will make the last person saying one of the recognized laugh strings blind for a few seconds",
|
"It will make the last person saying one of the recognized laugh strings blind for a few seconds",
|
||||||
"Note that you can only unlaugh laughs that weren't unlaughed before" };
|
"Note that you can only unlaugh laughs that weren't unlaughed before"
|
||||||
}
|
})
|
||||||
|
public final class UnlolCommand extends ICommand2MC {
|
||||||
|
|
||||||
@Override
|
public Map<Channel, LastlolData> Lastlol = new HashMap<>();
|
||||||
public boolean OnCommand(CommandSender sender, String alias, String[] args) {
|
|
||||||
|
@Command2.Subcommand
|
||||||
|
public boolean def(CommandSender sender) {
|
||||||
LastlolData lol = Lastlol.values().stream().filter(lld -> lld.Chatevent.shouldSendTo(sender))
|
LastlolData lol = Lastlol.values().stream().filter(lld -> lld.Chatevent.shouldSendTo(sender))
|
||||||
.max(Comparator.comparingLong(lld -> lld.Loltime)).orElse(null);
|
.max(Comparator.comparingLong(lld -> lld.Loltime)).orElse(null);
|
||||||
if (lol == null)
|
if (lol == null)
|
||||||
|
|
|
@ -5,6 +5,7 @@ import buttondevteam.chat.ChatProcessing;
|
||||||
import buttondevteam.chat.PluginMain;
|
import buttondevteam.chat.PluginMain;
|
||||||
import buttondevteam.chat.commands.ucmds.HistoryCommand;
|
import buttondevteam.chat.commands.ucmds.HistoryCommand;
|
||||||
import buttondevteam.chat.components.flair.FlairComponent;
|
import buttondevteam.chat.components.flair.FlairComponent;
|
||||||
|
import buttondevteam.chat.components.fun.FunComponent;
|
||||||
import buttondevteam.chat.components.towncolors.TownColorComponent;
|
import buttondevteam.chat.components.towncolors.TownColorComponent;
|
||||||
import buttondevteam.core.ComponentManager;
|
import buttondevteam.core.ComponentManager;
|
||||||
import buttondevteam.core.component.channel.Channel;
|
import buttondevteam.core.component.channel.Channel;
|
||||||
|
@ -38,9 +39,7 @@ import org.bukkit.event.server.ServerCommandEvent;
|
||||||
import org.bukkit.help.HelpTopic;
|
import org.bukkit.help.HelpTopic;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
@ -53,8 +52,6 @@ public class PlayerListener implements Listener {
|
||||||
*/
|
*/
|
||||||
public static BiMap<String, UUID> nicknames = HashBiMap.create();
|
public static BiMap<String, UUID> nicknames = HashBiMap.create();
|
||||||
|
|
||||||
public final static String[] LaughStrings = new String[]{"xd", "lel", "lawl", "kek", "lmao", "hue", "hah", "rofl"};
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
if (event.isCancelled())
|
if (event.isCancelled())
|
||||||
|
@ -164,38 +161,6 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ActiveF = false;
|
|
||||||
public static ChatPlayer FPlayer = null;
|
|
||||||
public static BukkitTask Ftask = null;
|
|
||||||
public static ArrayList<CommandSender> Fs = new ArrayList<>();
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
|
||||||
// MinigamePlayer mgp = Minigames.plugin.pdata.getMinigamePlayer(e.getEntity());
|
|
||||||
if (/* (mgp != null && !mgp.isInMinigame()) && */ new Random().nextBoolean()) { // Don't store Fs for NPCs
|
|
||||||
Runnable tt = () -> {
|
|
||||||
if (ActiveF) {
|
|
||||||
ActiveF = false;
|
|
||||||
if (FPlayer != null && FPlayer.FCount().get() < Integer.MAX_VALUE - 1)
|
|
||||||
FPlayer.FCount().set(FPlayer.FCount().get() + Fs.size());
|
|
||||||
Bukkit.broadcastMessage("§b" + Fs.size() + " " + (Fs.size() == 1 ? "person" : "people")
|
|
||||||
+ " paid their respects.§r");
|
|
||||||
Fs.clear();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
if (Ftask != null) {
|
|
||||||
Ftask.cancel();
|
|
||||||
tt.run(); //Finish previous one
|
|
||||||
}
|
|
||||||
ActiveF = true;
|
|
||||||
Fs.clear();
|
|
||||||
FPlayer = TBMCPlayer.getPlayer(e.getEntity().getUniqueId(), ChatPlayer.class);
|
|
||||||
FPlayer.FDeaths().set(FPlayer.FDeaths().get() + 1);
|
|
||||||
Bukkit.broadcastMessage("§bPress F to pay respects.§r");
|
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(PluginMain.Instance, tt, 15 * 20);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
public void onVotifierEvent(VotifierEvent event) { //TODO: Move to teh Core eh
|
public void onVotifierEvent(VotifierEvent event) { //TODO: Move to teh Core eh
|
||||||
|
|
Loading…
Reference in a new issue