update finish method

This commit is contained in:
Izzel_Aliz 2017-05-11 13:12:37 +08:00
parent bb38b69ad7
commit 3b0f87afbc
6 changed files with 18 additions and 27 deletions

View File

@ -19,9 +19,6 @@ locale: 'US'
lang: 'en' lang: 'en'
#This controls the message when left click a bug #This controls the message when left click a bug
auto-sendback-msg: '&eThanks for your reporting' auto-sendback-msg: '&eThanks for your reporting'
#This controls the stop sign of reporting
#Only support number,english letter,some punctuation
stop-sign: '#end#'
#Report Alias #Report Alias
alias: 'r' alias: 'r'
#If you use bungeecord, please set this to true and set database to mysql #If you use bungeecord, please set this to true and set database to mysql

View File

@ -3,9 +3,9 @@ rep-suc: '&e成功提交,编号#%serial%'
get-help: '&e使用&a/bug help &f获得更多帮助' get-help: '&e使用&a/bug help &f获得更多帮助'
must-player-run: '&c这个命令必须由玩家使用!' must-player-run: '&c这个命令必须由玩家使用!'
input-bug-info: '&e请输入你要提交的内容' input-bug-info: '&e请输入你要提交的内容'
continue-input: '&e请继续提交,输入&a #end# &f完成提交' continue-input: '&e请继续提交,移动以完成提交'
illegal-char: '&c你的输入含有非法字符,请检查并重新提交!' illegal-char: '&c你的输入含有非法字符,请检查并重新提交!'
not-complete: '&c请先完成提交! 输入&a #end#&c 即可' not-complete: '&c请先完成提交!'
gui-name: '&c浏览全部' gui-name: '&c浏览全部'
history-name: '&b历史记录' history-name: '&b历史记录'
last-page: '&e上一页' last-page: '&e上一页'

View File

@ -3,9 +3,9 @@ rep-suc: '&eSuccessfully report bug serial #%serial%'
get-help: '&eUse &a/bug help &fto get help' get-help: '&eUse &a/bug help &fto get help'
must-player-run: '&cThis command must be run as player!' must-player-run: '&cThis command must be run as player!'
input-bug-info: '&ePlease input bug information. You can divide it in several parts if its too long.' input-bug-info: '&ePlease input bug information. You can divide it in several parts if its too long.'
continue-input: '&eContinue input and use &a%stopsign% &fto stop this input' continue-input: '&eContinue input and try to move to stop this input'
illegal-char: '&cYour input contains illegal character, please check and retry!' illegal-char: '&cYour input contains illegal character, please check and retry!'
not-complete: '&cPlease finish reporting first! Chat with&a %stopsign%&c may help' not-complete: '&cPlease finish reporting first!'
gui-name: '&cBug View' gui-name: '&cBug View'
history-name: '&bHistory View' history-name: '&bHistory View'
last-page: '&eLast Page' last-page: '&eLast Page'

View File

@ -1,6 +1,6 @@
name: BugRepGUI name: BugRepGUI
main: com.ilummc.bugrepgui.Main main: com.ilummc.bugrepgui.Main
version: 1.6 version: 1.7
author: IzzelAliz author: IzzelAliz
website: https://www.spigotmc.org/resources/bugreportgui-better-than-rating.35119/ website: https://www.spigotmc.org/resources/bugreportgui-better-than-rating.35119/
commands: commands:

View File

@ -20,6 +20,7 @@ public class EventListener implements org.bukkit.event.Listener {
this.alias = msg; this.alias = msg;
return this; return this;
} }
@EventHandler @EventHandler
public void onCommand(PlayerCommandPreprocessEvent evt) { public void onCommand(PlayerCommandPreprocessEvent evt) {
if (evt.getMessage().equalsIgnoreCase("/"+alias)) { if (evt.getMessage().equalsIgnoreCase("/"+alias)) {
@ -40,32 +41,19 @@ public class EventListener implements org.bukkit.event.Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = false)
public void onChat(AsyncPlayerChatEvent evt) { public void onChat(AsyncPlayerChatEvent evt) {
String regex2 = "[^']+"; String regex2 = "[^']+";
String regex = Storage.getConfig().getString("stop-sign");
String regex3 = Storage.transfer(regex);
Pattern pattern2 = Pattern.compile(regex2); Pattern pattern2 = Pattern.compile(regex2);
Matcher m2 = pattern2.matcher(evt.getMessage()); Matcher m2 = pattern2.matcher(evt.getMessage());
if (Storage.map.containsKey(evt.getPlayer().getUniqueId().toString())) { if (Storage.map.containsKey(evt.getPlayer().getUniqueId().toString())) {
evt.setCancelled(true); evt.setCancelled(true);
if (m2.matches() && (!evt.getMessage().matches(regex3))) { if (m2.matches()) {
Bug bug = Storage.map.get(evt.getPlayer().getUniqueId().toString()); Bug bug = Storage.map.get(evt.getPlayer().getUniqueId().toString());
bug.append(evt.getMessage()); bug.append(evt.getMessage());
evt.getPlayer().sendMessage(Storage.getMsg("continue-input").replaceAll("%stopsign%", regex)); evt.getPlayer().sendMessage(Storage.getMsg("continue-input"));
return; return;
} else if (!evt.getMessage().matches(regex3)) { } else {
Storage.send(evt.getPlayer(), "illegal-char"); Storage.send(evt.getPlayer(), "illegal-char");
return; return;
} }
if (evt.getMessage().matches(regex3)) {
Bug bug = Storage.map.get(evt.getPlayer().getUniqueId().toString());
Database.insert(bug);
evt.getPlayer().sendMessage(Storage.getPrefix()
+ Storage.getMsg("rep-suc").replaceAll("%serial%", Database.getSerial(evt.getPlayer())));
if (!Storage.getConfig().getBoolean("use-bungee")) {
Notify.notifyt(evt.getPlayer());
}
Storage.map.remove(evt.getPlayer().getUniqueId().toString());
return;
}
} }
if (Storage.back.containsKey(evt.getPlayer().getUniqueId().toString())) { if (Storage.back.containsKey(evt.getPlayer().getUniqueId().toString())) {
evt.setCancelled(true); evt.setCancelled(true);
@ -84,8 +72,15 @@ public class EventListener implements org.bukkit.event.Listener {
public void onMove(PlayerMoveEvent evt) { public void onMove(PlayerMoveEvent evt) {
if (Storage.map.containsKey(evt.getPlayer().getUniqueId().toString())) { if (Storage.map.containsKey(evt.getPlayer().getUniqueId().toString())) {
evt.setCancelled(true); evt.setCancelled(true);
evt.getPlayer().sendMessage(Storage.getMsg("not-complete").replaceAll("%stopsign%", Bug bug = Storage.map.get(evt.getPlayer().getUniqueId().toString());
Storage.getConfig().getString("stop-sign"))); Database.insert(bug);
evt.getPlayer().sendMessage(Storage.getPrefix()
+ Storage.getMsg("rep-suc").replaceAll("%serial%", Database.getSerial(evt.getPlayer())));
if (!Storage.getConfig().getBoolean("use-bungee")) {
Notify.notifyt(evt.getPlayer());
}
Storage.map.remove(evt.getPlayer().getUniqueId().toString());
return;
} }
} }

View File

@ -17,7 +17,6 @@ public class Main extends JavaPlugin {
this); this);
getCommand("bug").setExecutor(new cmdExe()); getCommand("bug").setExecutor(new cmdExe());
getCommand("bugrepgui").setExecutor(new cmdExe()); getCommand("bugrepgui").setExecutor(new cmdExe());
this.getCommand(alias).setExecutor(new cmdExe());
if (this.getConfig().getBoolean("check-update")) if (this.getConfig().getBoolean("check-update"))
UpdateChecker.check(this.getDescription().getVersion(), this.getDescription().getWebsite()); UpdateChecker.check(this.getDescription().getVersion(), this.getDescription().getWebsite());
} }