Fix issues with 1.17 Paper
This commit is contained in:
parent
b33d0685c1
commit
1abdd0ac7f
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>FPChat</artifactId>
|
<artifactId>FPChat</artifactId>
|
||||||
<version>1.1.4</version>
|
<version>1.1.6</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
|
4
pom.xml
4
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>FPChat</artifactId>
|
<artifactId>FPChat</artifactId>
|
||||||
<version>1.1.4</version>
|
<version>1.1.6</version>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
|
@ -77,7 +77,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zaxxer</groupId>
|
<groupId>com.zaxxer</groupId>
|
||||||
<artifactId>HikariCP</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<version>3.4.5</version>
|
<version>4.0.3</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
package com.fpghoti.fpchatx.chat;
|
package com.fpghoti.fpchatx.chat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.fpghoti.fpchatx.FPChat;
|
import com.fpghoti.fpchatx.FPChat;
|
||||||
|
import com.fpghoti.fpchatx.event.ShoutChannelChatEvent;
|
||||||
import com.fpghoti.fpchatx.player.FPlayer;
|
import com.fpghoti.fpchatx.player.FPlayer;
|
||||||
|
|
||||||
public class ShoutChannel extends ChatChannel{
|
public class ShoutChannel extends ChatChannel{
|
||||||
|
@ -147,12 +153,22 @@ public class ShoutChannel extends ChatChannel{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String msg, FPlayer from) {
|
public void sendMessage(String msg, FPlayer from) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
plugin.log(Level.INFO, "Shout: " + msg);
|
plugin.log(Level.INFO, "Shout: " + msg);
|
||||||
|
Set<Player> recipients = new HashSet<Player>();
|
||||||
for(FPlayer p : FPlayer.getPlayers()) {
|
for(FPlayer p : FPlayer.getPlayers()) {
|
||||||
if(p.isShoutVisible() && !p.isIgnoring(from)) {
|
if(p.isShoutVisible() && !p.isIgnoring(from)) {
|
||||||
p.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4&lS&r&8]&r") + msg);
|
recipients.add(p.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
ShoutChannelChatEvent event = new ShoutChannelChatEvent(true, from.getPlayer(), msg, recipients, this);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
for(Player recipient : recipients) {
|
||||||
|
recipient.sendMessage(ChatColor.translateAlternateColorCodes('&', "&8[&4&lS&r&8]&r") + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,15 +2,20 @@ package com.fpghoti.fpchatx.chat;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
import com.fpghoti.fpchatx.FPChat;
|
import com.fpghoti.fpchatx.FPChat;
|
||||||
import com.fpghoti.fpchatx.config.ChannelFile;
|
import com.fpghoti.fpchatx.config.ChannelFile;
|
||||||
|
import com.fpghoti.fpchatx.event.StandardChannelChatEvent;
|
||||||
import com.fpghoti.fpchatx.player.FPlayer;
|
import com.fpghoti.fpchatx.player.FPlayer;
|
||||||
import com.fpghoti.fpchatx.util.Util;
|
import com.fpghoti.fpchatx.util.Util;
|
||||||
|
|
||||||
|
@ -322,22 +327,32 @@ public class StandardChannel extends ChatChannel{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String msg, FPlayer from) {
|
public void sendMessage(String msg, FPlayer from) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
Player pf = Util.getEP(from.getName());
|
Player pf = Util.getEP(from.getName());
|
||||||
plugin.log(Level.INFO, name + ": " + msg);
|
plugin.log(Level.INFO, name + ": " + msg);
|
||||||
|
Set<Player> recipients = new HashSet<Player>();
|
||||||
for(FPlayer p : FPlayer.getPlayers()) {
|
for(FPlayer p : FPlayer.getPlayers()) {
|
||||||
if(p.getChannels().contains(name) && !p.isIgnoring(from)) {
|
if(p.getChannels().contains(name) && !p.isIgnoring(from)) {
|
||||||
if(hasRadius) {
|
if(hasRadius) {
|
||||||
Player pp = Util.getEP(p.getName());
|
Player pp = Util.getEP(p.getName());
|
||||||
if(pp.getWorld() == pf.getWorld()) {
|
if(pp.getWorld() == pf.getWorld()) {
|
||||||
if(pp.getLocation().distance(pf.getLocation()) < chatRadius){
|
if(pp.getLocation().distance(pf.getLocation()) < chatRadius){
|
||||||
p.sendMessage(msg);
|
recipients.add(p.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}else {
|
}else {
|
||||||
p.sendMessage(msg);
|
recipients.add(p.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
StandardChannelChatEvent event = new StandardChannelChatEvent(true, from.getPlayer(), msg, recipients, this);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
for(Player recipient : recipients) {
|
||||||
|
recipient.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ChannelFile file) {
|
public void update(ChannelFile file) {
|
||||||
|
|
|
@ -1,13 +1,18 @@
|
||||||
package com.fpghoti.fpchatx.chat;
|
package com.fpghoti.fpchatx.chat;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import com.fpghoti.fpchatx.FPChat;
|
import com.fpghoti.fpchatx.FPChat;
|
||||||
|
import com.fpghoti.fpchatx.event.TempChannelChatEvent;
|
||||||
import com.fpghoti.fpchatx.player.FPlayer;
|
import com.fpghoti.fpchatx.player.FPlayer;
|
||||||
|
|
||||||
public class TempChannel extends ChatChannel{
|
public class TempChannel extends ChatChannel{
|
||||||
|
@ -146,12 +151,22 @@ public class TempChannel extends ChatChannel{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void sendMessage(String msg, FPlayer from) {
|
public void sendMessage(String msg, FPlayer from) {
|
||||||
|
CompletableFuture.runAsync(() -> {
|
||||||
plugin.log(Level.INFO, "[TC] " + name + ": " + msg);
|
plugin.log(Level.INFO, "[TC] " + name + ": " + msg);
|
||||||
|
Set<Player> recipients = new HashSet<Player>();
|
||||||
for(FPlayer p : FPlayer.getPlayers()) {
|
for(FPlayer p : FPlayer.getPlayers()) {
|
||||||
if(p.getTempChannels().contains(name) && !p.isIgnoring(from)) {
|
if(p.getTempChannels().contains(name) && !p.isIgnoring(from)) {
|
||||||
p.sendMessage(msg);
|
recipients.add(p.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TempChannelChatEvent event = new TempChannelChatEvent(true, from.getPlayer(), msg, recipients, this);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if(!event.isCancelled()) {
|
||||||
|
for(Player recipient : recipients) {
|
||||||
|
recipient.sendMessage(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,23 @@
|
||||||
|
package com.fpghoti.fpchatx.event;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
import com.fpghoti.fpchatx.chat.ChatChannel;
|
||||||
|
|
||||||
|
public abstract class FPChatEvent extends AsyncPlayerChatEvent {
|
||||||
|
|
||||||
|
private ChatChannel channel;
|
||||||
|
|
||||||
|
public FPChatEvent(boolean async, Player who, String message, Set<Player> players, ChatChannel channel) {
|
||||||
|
super(async, who, message, players);
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ChatChannel getChannel() {
|
||||||
|
return channel;
|
||||||
|
};
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.fpghoti.fpchatx.event;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.fpghoti.fpchatx.chat.ShoutChannel;
|
||||||
|
|
||||||
|
public class ShoutChannelChatEvent extends FPChatEvent {
|
||||||
|
|
||||||
|
private ShoutChannel channel;
|
||||||
|
|
||||||
|
public ShoutChannelChatEvent(boolean async, Player who, String message, Set<Player> players, ShoutChannel channel) {
|
||||||
|
super(async, who, message, players, channel);
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShoutChannel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.fpghoti.fpchatx.event;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.fpghoti.fpchatx.chat.StandardChannel;
|
||||||
|
|
||||||
|
public class StandardChannelChatEvent extends FPChatEvent {
|
||||||
|
|
||||||
|
private StandardChannel channel;
|
||||||
|
|
||||||
|
public StandardChannelChatEvent(boolean async, Player who, String message, Set<Player> players, StandardChannel channel) {
|
||||||
|
super(async, who, message, players, channel);
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public StandardChannel getChannel() {
|
||||||
|
return this.channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,22 @@
|
||||||
|
package com.fpghoti.fpchatx.event;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import com.fpghoti.fpchatx.chat.TempChannel;
|
||||||
|
|
||||||
|
public class TempChannelChatEvent extends FPChatEvent {
|
||||||
|
|
||||||
|
private TempChannel channel;
|
||||||
|
|
||||||
|
public TempChannelChatEvent(boolean async, Player who, String message, Set<Player> players, TempChannel channel) {
|
||||||
|
super(async, who, message, players, channel);
|
||||||
|
this.channel = channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public TempChannel getChannel() {
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -13,12 +13,33 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import com.fpghoti.fpchatx.FPChat;
|
import com.fpghoti.fpchatx.FPChat;
|
||||||
import com.fpghoti.fpchatx.chat.ChatChannel;
|
import com.fpghoti.fpchatx.chat.ChatChannel;
|
||||||
|
import com.fpghoti.fpchatx.event.FPChatEvent;
|
||||||
import com.fpghoti.fpchatx.player.FPlayer;
|
import com.fpghoti.fpchatx.player.FPlayer;
|
||||||
|
|
||||||
public class PlayerListener implements Listener {
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
private boolean enabled = true;
|
private boolean enabled = true;
|
||||||
|
|
||||||
|
// @EventHandler (priority = EventPriority.HIGH)
|
||||||
|
// public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
|
// if(enabled) {
|
||||||
|
// if (event.isCancelled()) {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// Player sender = event.getPlayer();
|
||||||
|
// FPlayer p = FPlayer.getPlayer(sender);
|
||||||
|
// if(p.toTalk() && p.getTalkChannel() != null) {
|
||||||
|
// p.setTalk(false);
|
||||||
|
// ChatChannel c = p.getTalkChannel();
|
||||||
|
// p.setTalkChannel(null);
|
||||||
|
// p.chat(c, event.getMessage());
|
||||||
|
// }else {
|
||||||
|
// p.chat(event.getMessage());
|
||||||
|
// }
|
||||||
|
// event.setCancelled(true);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
@EventHandler (priority = EventPriority.HIGH)
|
@EventHandler (priority = EventPriority.HIGH)
|
||||||
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
public void onPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
if(enabled) {
|
if(enabled) {
|
||||||
|
@ -27,6 +48,7 @@ public class PlayerListener implements Listener {
|
||||||
}
|
}
|
||||||
Player sender = event.getPlayer();
|
Player sender = event.getPlayer();
|
||||||
FPlayer p = FPlayer.getPlayer(sender);
|
FPlayer p = FPlayer.getPlayer(sender);
|
||||||
|
if(!(event instanceof FPChatEvent)) {
|
||||||
if(p.toTalk() && p.getTalkChannel() != null) {
|
if(p.toTalk() && p.getTalkChannel() != null) {
|
||||||
p.setTalk(false);
|
p.setTalk(false);
|
||||||
ChatChannel c = p.getTalkChannel();
|
ChatChannel c = p.getTalkChannel();
|
||||||
|
@ -38,6 +60,7 @@ public class PlayerListener implements Listener {
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler (priority = EventPriority.NORMAL)
|
@EventHandler (priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class MySQLConnection{
|
||||||
port = config.getPort();
|
port = config.getPort();
|
||||||
hikari = new HikariDataSource();
|
hikari = new HikariDataSource();
|
||||||
hikari.setMaximumPoolSize(10);
|
hikari.setMaximumPoolSize(10);
|
||||||
hikari.setDataSourceClassName("com.mysql.jdbc.jdbc2.optional.MysqlDataSource");
|
hikari.setDataSourceClassName("com.mysql.cj.jdbc.MysqlDataSource");
|
||||||
hikari.addDataSourceProperty("serverName", host);
|
hikari.addDataSourceProperty("serverName", host);
|
||||||
hikari.addDataSourceProperty("user", user);
|
hikari.addDataSourceProperty("user", user);
|
||||||
hikari.addDataSourceProperty("password", password);
|
hikari.addDataSourceProperty("password", password);
|
||||||
|
@ -55,7 +55,9 @@ public class MySQLConnection{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally {
|
}finally {
|
||||||
try {
|
try {
|
||||||
|
if(connection != null) {
|
||||||
connection.close();
|
connection.close();
|
||||||
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
|
@ -441,6 +441,21 @@ public class FPlayer {
|
||||||
channel.sendMessage(formatChat(channel,msg), this);
|
channel.sendMessage(formatChat(channel,msg), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public void chat(String msg) {
|
||||||
|
// if(toShout) {
|
||||||
|
// toShout = false;
|
||||||
|
// ChatChannel.getShout().sendMessage(formatChat(ChatChannel.getShout(),msg), this);
|
||||||
|
// if(FPChat.getPlugin().getMainConfig().shoutCooldownEnabled()) {
|
||||||
|
// shoutCooldown = FPChat.getPlugin().getMainConfig().getShoutSeconds();
|
||||||
|
// }
|
||||||
|
// }else if(tempspeak) {
|
||||||
|
// getPrimaryTempChannel().sendMessage(formatChat(getPrimaryTempChannel(),msg), this);
|
||||||
|
// }else {
|
||||||
|
// getPrimaryChannel().sendMessage(formatChat(msg), this);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
public void chat(String msg) {
|
public void chat(String msg) {
|
||||||
if(toShout) {
|
if(toShout) {
|
||||||
toShout = false;
|
toShout = false;
|
||||||
|
@ -454,7 +469,6 @@ public class FPlayer {
|
||||||
getPrimaryChannel().sendMessage(formatChat(msg), this);
|
getPrimaryChannel().sendMessage(formatChat(msg), this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean shout(String message) {
|
public boolean shout(String message) {
|
||||||
if(!hushed && FPChat.getPlugin().getMainConfig().shoutCooldownEnabled() && shoutCooldown > 0) {
|
if(!hushed && FPChat.getPlugin().getMainConfig().shoutCooldownEnabled() && shoutCooldown > 0) {
|
||||||
int i = shoutCooldown;
|
int i = shoutCooldown;
|
||||||
|
|
Loading…
Reference in New Issue