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