More components, broadcasts #98

Merged
NorbiPeti merged 13 commits from dev into master 2019-03-17 01:28:22 +00:00
6 changed files with 129 additions and 84 deletions
Showing only changes of commit 26b44fbfe1 - Show all commits

View file

@ -40,5 +40,34 @@
<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" />
<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>
</module>

View file

@ -1,5 +1,6 @@
package buttondevteam.chat;
import buttondevteam.chat.components.fun.FunComponent;
import buttondevteam.chat.components.fun.UnlolCommand;
import buttondevteam.chat.commands.ucmds.admin.DebugCommand;
import buttondevteam.chat.formatting.ChatFormatter;
@ -7,6 +8,7 @@ import buttondevteam.chat.formatting.TellrawEvent;
import buttondevteam.chat.formatting.TellrawPart;
import buttondevteam.chat.formatting.TellrawSerializer;
import buttondevteam.chat.listener.PlayerListener;
import buttondevteam.core.ComponentManager;
import buttondevteam.core.component.channel.Channel;
import buttondevteam.lib.TBMCChatEvent;
import buttondevteam.lib.TBMCChatEventBase;
@ -296,12 +298,8 @@ public class ChatProcessing {
}
ChatPlayer mpp = TBMCPlayer.getPlayer(nottest ? p.getUniqueId() : new UUID(0, 0), ChatPlayer.class);
if (nottest) {
if (PluginMain.Instance.notificationSound().get().length() == 0)
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());
}
playPingSound(p);
}
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
}).priority(Priority.High).type(ChatFormatter.Type.Excluder).build());
@ -316,12 +314,8 @@ public class ChatProcessing {
+ match.toLowerCase() + " but was reported as online.");
return "§c" + match + "§r";
}
if (PluginMain.Instance.notificationSound().get().length() == 0)
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();
playPingSound(p);
return PluginMain.essentials.getUser(p).getNickname();
}
error.accept("Player nicknamed " + match.toLowerCase()
+ " not found in nickname map but was reported as online.");
@ -331,24 +325,16 @@ public class ChatProcessing {
return formatters;
}
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
if (PlayerListener.ActiveF && !PlayerListener.Fs.contains(sender) && message.equalsIgnoreCase("F"))
PlayerListener.Fs.add(sender);
private static void playPingSound(Player p) {
if (PluginMain.Instance.notificationSound().get().length() == 0)
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();
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 < PlayerListener.LaughStrings.length; i++) {
if (add = msg.contains(PlayerListener.LaughStrings[i])) {
lld.setLolornot(false);
break;
}
}
}
if (add)
UnlolCommand.Lastlol.put(event.getChannel(), lld);
static void doFunStuff(CommandSender sender, TBMCChatEventBase event, String message) {
val fc=ComponentManager.getIfEnabled(FunComponent.class);
if(fc!=null) fc.onChat(sender, event, message);
}
}

View file

@ -84,7 +84,7 @@ public class PluginMain extends ButtonPlugin { // Translated to Java: 2015.07.15
private boolean setupPermissions() {
RegisteredServiceProvider<Permission> permissionProvider = getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.permission.Permission.class);
.getRegistration(net.milkbowl.vault.permission.Permission.class);
if (permissionProvider != null) {
permission = permissionProvider.getProvider();
}
@ -93,7 +93,7 @@ public class PluginMain extends ButtonPlugin { // Translated to Java: 2015.07.15
private boolean setupEconomy() {
RegisteredServiceProvider<Economy> economyProvider = getServer().getServicesManager()
.getRegistration(net.milkbowl.vault.economy.Economy.class);
.getRegistration(net.milkbowl.vault.economy.Economy.class);
if (economyProvider != null) {
economy = economyProvider.getProvider();
}

View file

@ -1,18 +1,87 @@
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.player.TBMCPlayer;
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
protected void enable() {
val pc = new PressCommand();
registerCommand(pc);
registerListener(pc);
registerCommand(command=new UnlolCommand());
registerListener(this);
}
@Override
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);
}
}
}

View file

@ -2,8 +2,7 @@ package buttondevteam.chat.components.fun;
import buttondevteam.core.component.channel.Channel;
import buttondevteam.lib.TBMCChatEventBase;
import buttondevteam.lib.chat.CommandClass;
import buttondevteam.lib.chat.TBMCCommandBase;
import buttondevteam.lib.chat.*;
import lombok.Data;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@ -15,21 +14,18 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Map;
@CommandClass(modOnly = false)
public final class UnlolCommand extends TBMCCommandBase {
@CommandClass(modOnly = false, helpText = {
"§6---- Unlol/unlaugh ----",
"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",
"Note that you can only unlaugh laughs that weren't unlaughed before"
})
public final class UnlolCommand extends ICommand2MC {
public static Map<Channel, LastlolData> Lastlol = new HashMap<>();
public 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",
"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" };
}
@Override
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))
.max(Comparator.comparingLong(lld -> lld.Loltime)).orElse(null);
if (lol == null)

View file

@ -5,6 +5,7 @@ import buttondevteam.chat.ChatProcessing;
import buttondevteam.chat.PluginMain;
import buttondevteam.chat.commands.ucmds.HistoryCommand;
import buttondevteam.chat.components.flair.FlairComponent;
import buttondevteam.chat.components.fun.FunComponent;
import buttondevteam.chat.components.towncolors.TownColorComponent;
import buttondevteam.core.ComponentManager;
import buttondevteam.core.component.channel.Channel;
@ -38,9 +39,7 @@ import org.bukkit.event.server.ServerCommandEvent;
import org.bukkit.help.HelpTopic;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.scheduler.BukkitTask;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Map.Entry;
import java.util.Random;
@ -53,8 +52,6 @@ public class PlayerListener implements Listener {
*/
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)
public void onPlayerChat(AsyncPlayerChatEvent event) {
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
@SuppressWarnings("deprecation")
public void onVotifierEvent(VotifierEvent event) { //TODO: Move to teh Core eh