Skip to content

Commit

Permalink
fix [bug] async task use bukkit api
Browse files Browse the repository at this point in the history
  • Loading branch information
hank9999 committed May 2, 2020
1 parent f6b8806 commit 5950472
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.hank9999</groupId>
<artifactId>KeywordBlock</artifactId>
<version>1.6.0</version>
<version>1.6.1</version>
<packaging>jar</packaging>

<name>KeywordBlock</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,20 @@ public void onChat(AsyncPlayerChatEvent event) {
if (KeywordBlock.plugin.times.get(username).intValue() >= KeywordBlock.plugin.getConfig().getInt("mute.times")) {
for (String mute_message : KeywordBlock.plugin.getConfig().getStringList("mute.message")) {
player.sendMessage(Lib.color_translate(mute_message));
KeywordBlock.plugin.getServer().dispatchCommand(KeywordBlock.plugin.getServer().getConsoleSender(),
Objects.requireNonNull(Objects.requireNonNull(KeywordBlock.plugin.getConfig().getString("mute.command")).replaceAll("%player%", username)));
new BukkitRunnable() {
@Override
public void run() {
KeywordBlock.plugin.getServer().dispatchCommand(
KeywordBlock.plugin.getServer().getConsoleSender(),
Objects.requireNonNull(
Objects.requireNonNull(
KeywordBlock.plugin.getConfig().getString("mute.command")
).replaceAll("%player%", username)
)
);
}
}.runTask(KeywordBlock.plugin);

}
KeywordBlock.plugin.times.remove(username);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,14 @@ public void onCommands(PlayerCommandPreprocessEvent e) {
if (KeywordBlock.plugin.times.get(username).intValue() >= KeywordBlock.plugin.getConfig().getInt("mute.times")) {
for (String mute_message : KeywordBlock.plugin.getConfig().getStringList("mute.message")) {
player.sendMessage(Lib.color_translate(mute_message));
KeywordBlock.plugin.getServer().dispatchCommand(KeywordBlock.plugin.getServer().getConsoleSender(),
Objects.requireNonNull(Objects.requireNonNull(KeywordBlock.plugin.getConfig().getString("mute.command")).replaceAll("%player%", username)));
KeywordBlock.plugin.getServer().dispatchCommand(
KeywordBlock.plugin.getServer().getConsoleSender(),
Objects.requireNonNull(
Objects.requireNonNull(
KeywordBlock.plugin.getConfig().getString("mute.command")
).replaceAll("%player%", username)
)
);
}
KeywordBlock.plugin.times.remove(username);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
import com.github.hank9999.keywordblock.Event.CommandPreprocessEvent;
import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.Timer;
import java.util.concurrent.atomic.AtomicInteger;

public final class KeywordBlock extends JavaPlugin {
Expand Down Expand Up @@ -52,7 +54,7 @@ public void onEnable() {
getLogger().info(ChatColor.GOLD + "Version v" + getDescription().getVersion());

new Update_Checker(this, 78091).getVersion(version -> {
if (this.getDescription().getVersion().equalsIgnoreCase(version)) {
if (("v" + this.getDescription().getVersion()).equalsIgnoreCase(version)) {
getLogger().info(ChatColor.AQUA + "There is not a new update available.");
} else {
getLogger().info(ChatColor.AQUA + "There is a new update " + version + " available.");
Expand Down

0 comments on commit 5950472

Please sign in to comment.