Skip to content

Commit

Permalink
v1.6.2
Browse files Browse the repository at this point in the history
Auto check update
Fix bug in detecting other command
Replace '"' with "'" in plugin.yml
Rename some class
  • Loading branch information
hank9999 committed May 3, 2020
1 parent 5950472 commit cda96b4
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 86 deletions.
64 changes: 32 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,66 +49,66 @@ function:
message:
broadcast:
admin:
- "&2[&dKeywordBlock&2] &9%player_name% &btry to send blocked word &c%player_message%"
- '&2[&dKeywordBlock&2] &9%player_name% &btry to send blocked word &c%player_message%'
warn:
player:
- "&2[&dKeywordBlock&2] &c%player_message% include blocked word"
- "&2[&dKeywordBlock&2] &cDo not try to send blocked word"
- '&2[&dKeywordBlock&2] &c%player_message% include blocked word'
- '&2[&dKeywordBlock&2] &cDo not try to send blocked word'

# Mute
mute:
# After how many times, mute
times: 3
# mute commnd
command: "mute %player% 30min Please mind your words"
command: 'mute %player% 30min Please mind your words'
# mute message
message:
- "&2[&dKeywordBlock&2] &cYou were muted. Please mind your words."
- '&2[&dKeywordBlock&2] &cYou were muted. Please mind your words.'

# detect other command
detect_other:
# command list
command:
- "/tell"
- "/msg"
- "/t"
- "/r"
- '/tell'
- '/msg'
- '/t'
- '/r'

# keywordblock commands language
command_lang:
# plugin name
keywordblock_name: "&2[&dKeywordBlock&2]"
keywordblock_name: '&2[&dKeywordBlock&2]'
help:
- "&rUse &7/keywordblock help &rto get help"
- "&rUse &7/keywordblock reload &rto reload"
- "&rUse &7/keywordblock list &rto get list"
- "&rUse &7/keywordblock add <keyword> &rto add"
- "&rUse &7/keywordblock del <keyword> &rto del"
- '&rUse &7/keywordblock help &rto get help'
- '&rUse &7/keywordblock reload &rto reload'
- '&rUse &7/keywordblock list &rto get list'
- '&rUse &7/keywordblock add <keyword> &rto add'
- '&rUse &7/keywordblock del <keyword> &rto del'
reload:
- "&rReload Config"
- '&rReload Config'
list:
prefix:
- "&rKeyword List:"
- '&rKeyword List:'
empty:
- "&3Null"
- '&3Null'
add:
without_key:
- "&rPlease add with keyword"
- '&rPlease add with keyword'
exists:
- "&rThis keyword already exists"
- '&rThis keyword already exists'
success:
- "&radd a keyword"
- '&radd a keyword'
del:
without_key:
- "&rPlease del with keyword"
- '&rPlease del with keyword'
not_exist:
- "&rThis keyword is not exist"
- '&rThis keyword is not exist'
success:
- "&rdel a keyword"
- '&rdel a keyword'
unknown:
- "&cUnknown Command"
- '&cUnknown Command'
no_perm:
- "&r&cYou do not have permission to use this command"
- '&r&cYou do not have permission to use this command'

# Keyword list
words: []
Expand Down Expand Up @@ -173,17 +173,17 @@ mute:
# 多少次之后禁言
times: 3
# 执行指令
command: "mute %player% 30min 注意文明用语"
command: 'mute %player% 30min 注意文明用语'
message:
- "&2[&d关键词屏蔽&2] &c你被禁言了 请注意文明用语"
- '&2[&d关键词屏蔽&2] &c你被禁言了 请注意文明用语'

# 检测其他指令
detect_other:
command:
- "/tell"
- "/msg"
- "/t"
- "/r"
- '/tell'
- '/msg'
- '/t'
- '/r'

# 指令返回的消息
command_lang:
Expand Down
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.1</version>
<version>1.6.2</version>
<packaging>jar</packaging>

<name>KeywordBlock</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.github.hank9999.keywordblock;
package com.github.hank9999.keywordblock.Commands;

import com.github.hank9999.keywordblock.KeywordBlock;
import com.github.hank9999.keywordblock.Libs.Lib;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
Expand All @@ -9,21 +11,23 @@
import java.util.List;
import java.util.stream.Collectors;

public class KeywordBlock_Command implements TabExecutor {
public class Main_Command implements TabExecutor {

private String[] Commands = {"help", "reload", "list", "add", "del"};
private final String[] Commands = {"help", "reload", "list", "add", "del"};

@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (command.getName().equalsIgnoreCase("keywordblock")) {
String keywordblock_name = KeywordBlock.plugin.getConfig().getString("command_lang.keywordblock_name");
if (strings.length == 0) {
commandSender.sendMessage(Lib.color_translate("====================="));
commandSender.sendMessage(Lib.color_translate(" &2[&dKeywordBlock&2]"));
commandSender.sendMessage(Lib.color_translate(" &bVersion: &6v" + KeywordBlock.plugin.getDescription().getVersion()));
commandSender.sendMessage(Lib.color_translate(" &3Author: &4hank9999"));
commandSender.sendMessage(Lib.color_translate("====================="));
return true;
}
if (commandSender.hasPermission("KeywordBlock.admin")) {
if (strings.length == 0) {
for (String message : KeywordBlock.plugin.getConfig().getStringList("command_lang.help")) {
commandSender.sendMessage(Lib.color_translate(keywordblock_name + " " + message));
}
return true;
}
if (strings[0].equalsIgnoreCase("help")) {
for (String message : KeywordBlock.plugin.getConfig().getStringList("command_lang.help")) {
commandSender.sendMessage(Lib.color_translate(keywordblock_name + " " + message));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.hank9999.keywordblock.Event;

import com.github.hank9999.keywordblock.KeywordBlock;
import com.github.hank9999.keywordblock.Lib;
import com.github.hank9999.keywordblock.Libs.Lib;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.github.hank9999.keywordblock.Event;

import com.github.hank9999.keywordblock.KeywordBlock;
import com.github.hank9999.keywordblock.Lib;
import com.github.hank9999.keywordblock.Libs.Lib;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
Expand Down Expand Up @@ -95,8 +95,8 @@ public void onCommands(PlayerCommandPreprocessEvent e) {
break;
}
}
break;
}
break;
}
}
}
Expand Down
18 changes: 6 additions & 12 deletions src/main/java/com/github/hank9999/keywordblock/KeywordBlock.java
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
package com.github.hank9999.keywordblock;

import com.github.hank9999.keywordblock.Commands.Main_Command;
import com.github.hank9999.keywordblock.Event.ChatEvent;
import com.github.hank9999.keywordblock.Event.CommandPreprocessEvent;
import com.github.hank9999.keywordblock.Update.Timer_Update;
import com.github.hank9999.keywordblock.bStats.MetricsLite;
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 @@ -41,8 +42,8 @@ public void onEnable() {
getLogger().info(ChatColor.GOLD + "Other Command Disable");
}

Objects.requireNonNull(getServer().getPluginCommand("keywordblock")).setExecutor(new KeywordBlock_Command());
Objects.requireNonNull(getServer().getPluginCommand("keywordblock")).setTabCompleter(new KeywordBlock_Command());
Objects.requireNonNull(getServer().getPluginCommand("keywordblock")).setExecutor(new Main_Command());
Objects.requireNonNull(getServer().getPluginCommand("keywordblock")).setTabCompleter(new Main_Command());
try {
MetricsLite metrics = new MetricsLite(this, 7376);
getLogger().info(ChatColor.GOLD + "bStats Metrics Enable");
Expand All @@ -53,14 +54,7 @@ public void onEnable() {
getLogger().info(ChatColor.BLUE + "Keywoord Plugin Enable");
getLogger().info(ChatColor.GOLD + "Version v" + getDescription().getVersion());

new Update_Checker(this, 78091).getVersion(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.");
getLogger().info(ChatColor.AQUA + "See it in https://www.spigotmc.org/resources/keywordblock.78091/");
}
});
new Timer_Update();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.hank9999.keywordblock;
package com.github.hank9999.keywordblock.Libs;

import org.bukkit.ChatColor;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.github.hank9999.keywordblock.Update;

import com.github.hank9999.keywordblock.KeywordBlock;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;

import java.util.Timer;
import java.util.TimerTask;

public class Timer_Update {
private boolean is_first = true;

public Timer_Update() {
final Timer timer = new Timer(true); // We use a timer cause the Bukkit scheduler is affected by server lags
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
if (!KeywordBlock.plugin.isEnabled()) { // Plugin was disabled
timer.cancel();
return;
}
Bukkit.getScheduler().runTask(KeywordBlock.plugin, () -> Update_Check());
}
}, 0, 1000 * 60 * 60);
}

public void Update_Check() {
new Update_Checker(KeywordBlock.plugin, 78091).getVersion(version -> {
if (("v" + KeywordBlock.plugin.getDescription().getVersion()).equalsIgnoreCase(version)) {
if (is_first) {
KeywordBlock.plugin.getLogger().info(ChatColor.AQUA + "No new update available.");
is_first = false;
}
} else {
KeywordBlock.plugin.getLogger().info(ChatColor.AQUA + "A new update " + version + " available!");
KeywordBlock.plugin.getLogger().info(ChatColor.AQUA + "See it in https://www.spigotmc.org/resources/keywordblock.78091/");
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.hank9999.keywordblock;
package com.github.hank9999.keywordblock.Update;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.hank9999.keywordblock;
package com.github.hank9999.keywordblock.bStats;

import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
Expand Down
52 changes: 26 additions & 26 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,57 +8,57 @@ function:
message:
broadcast:
admin:
- "&2[&dKeywordBlock&2] &9%player_name% &btry to send blocked word &c%player_message%"
- '&2[&dKeywordBlock&2] &9%player_name% &btry to send blocked word &c%player_message%'
warn:
player:
- "&2[&dKeywordBlock&2] &c%player_message% include blocked word"
- "&2[&dKeywordBlock&2] &cDo not try to send blocked word"
- '&2[&dKeywordBlock&2] &c%player_message% include blocked word'
- '&2[&dKeywordBlock&2] &cDo not try to send blocked word'

mute:
times: 3
command: "mute %player% 30min Please mind your words"
command: 'mute %player% 30min Please mind your words'
message:
- "&2[&dKeywordBlock&2] &cYou were muted. Please mind your words."
- '&2[&dKeywordBlock&2] &cYou were muted. Please mind your words.'

detect_other:
command:
- "/tell"
- "/msg"
- "/t"
- "/r"
- '/tell'
- '/msg'
- '/t'
- '/r'

command_lang:
keywordblock_name: "&2[&dKeywordBlock&2]"
keywordblock_name: '&2[&dKeywordBlock&2]'
help:
- "&rUse &7/keywordblock help &rto get help"
- "&rUse &7/keywordblock reload &rto reload"
- "&rUse &7/keywordblock list &rto get list"
- "&rUse &7/keywordblock add <keyword> &rto add"
- "&rUse &7/keywordblock del <keyword> &rto del"
- '&rUse &7/keywordblock help &rto get help'
- '&rUse &7/keywordblock reload &rto reload'
- '&rUse &7/keywordblock list &rto get list'
- '&rUse &7/keywordblock add <keyword> &rto add'
- '&rUse &7/keywordblock del <keyword> &rto del'
reload:
- "&rReload Config"
- '&rReload Config'
list:
prefix:
- "&rKeyword List:"
- '&rKeyword List:'
empty:
- "&3Null"
- '&3Null'
add:
without_key:
- "&rPlease add with keyword"
- '&rPlease add with keyword'
exists:
- "&rThis keyword already exists"
- '&rThis keyword already exists'
success:
- "&radd a keyword"
- '&radd a keyword'
del:
without_key:
- "&rPlease del with keyword"
- '&rPlease del with keyword'
not_exist:
- "&rThis keyword is not exist"
- '&rThis keyword is not exist'
success:
- "&rdel a keyword"
- '&rdel a keyword'
unknown:
- "&cUnknown Command"
- '&cUnknown Command'
no_perm:
- "&r&cYou do not have permission to use this command"
- '&r&cYou do not have permission to use this command'

words: []

0 comments on commit cda96b4

Please sign in to comment.