3
3
import org .bukkit .configuration .file .FileConfiguration ;
4
4
import net .md_5 .bungee .api .chat .BaseComponent ;
5
5
import org .bukkit .plugin .java .JavaPlugin ;
6
- import org .bukkit .command .CommandSender ;
7
- import org .bukkit .command .Command ;
8
6
import org .bukkit .entity .Player ;
9
7
import java .util .HashMap ;
10
8
import org .bukkit .Bukkit ;
9
+ import org .bukkit .command .Command ;
10
+ import org .bukkit .command .CommandSender ;
11
+
11
12
import java .util .Map ;
12
13
13
14
public class Main extends JavaPlugin {
@@ -16,6 +17,7 @@ public class Main extends JavaPlugin {
16
17
17
18
public FileConfiguration config ;
18
19
private LanguageManager languageManager ;
20
+ public CommandTNTReporter commandTNTReporter ;
19
21
private WarnAdmin warnAdmin ;
20
22
21
23
@ Override
@@ -47,36 +49,14 @@ public void onEnable() {
47
49
if (config .getBoolean ("interruptExplosion" )) {
48
50
getServer ().getPluginManager ().registerEvents (new EventPrimedTNT (this , warnAdmin ), this );
49
51
}
50
- }
51
52
52
- // Send warning messages to administrators.
53
- @ Override
54
- public void onDisable () {
55
- getLogger ().info ("TNT Reporter is disabled." );
53
+ commandTNTReporter = new CommandTNTReporter (this );
54
+ getCommand ("tntreporter" ).setExecutor (commandTNTReporter );
56
55
}
57
56
58
- // Send warning messages to administrators.
59
57
@ Override
60
58
public boolean onCommand (CommandSender sender , Command command , String label , String [] args ) {
61
- if (command .getName ().equalsIgnoreCase ("tntreporter report" )) {
62
- sender .sendMessage ("TNT Report:" );
63
- sender .sendMessage ("TNT broken by players:" );
64
- for (Map .Entry <String , Integer > entry : tntBrokenByPlayers .entrySet ()) {
65
- String playerName = entry .getKey ();
66
- int tntBroken = entry .getValue ();
67
- sender .sendMessage (playerName + ": " + tntBroken );
68
- }
69
-
70
- sender .sendMessage ("TNT placed by players:" );
71
- for (Map .Entry <String , Integer > entry : tntPlacedByPlayers .entrySet ()) {
72
- String playerName = entry .getKey ();
73
- int tntPlaced = entry .getValue ();
74
- sender .sendMessage (playerName + ": " + tntPlaced );
75
- }
76
-
77
- return true ;
78
- } else if (command .getName ().equalsIgnoreCase ("tntreporter reload" ) && sender .hasPermission ("tntreporter.reload" )) {
79
- // Reload the configuration file.
59
+ if (args .length == 1 && args [0 ].equalsIgnoreCase ("reload" )) {
80
60
reloadConfig ();
81
61
config = getConfig ();
82
62
sender .sendMessage ("TNT Reporter configuration reloaded." );
@@ -85,6 +65,11 @@ public boolean onCommand(CommandSender sender, Command command, String label, St
85
65
return false ;
86
66
}
87
67
68
+ @ Override
69
+ public void onDisable () {
70
+ getLogger ().info ("TNT Reporter is disabled." );
71
+ }
72
+
88
73
// Send warning messages to administrators.
89
74
public void sendWarnToAdmin (BaseComponent ... components ) {
90
75
for (Player player : Bukkit .getOnlinePlayers ()) {
@@ -93,4 +78,4 @@ public void sendWarnToAdmin(BaseComponent... components) {
93
78
}
94
79
}
95
80
}
96
- }
81
+ }
0 commit comments