19 |
|
|
20 |
import java.io.IOException; |
import java.io.IOException; |
21 |
import java.io.File; |
import java.io.File; |
|
import java.io.RandomAccessFile; |
|
|
|
|
22 |
|
|
23 |
|
import java.util.Collection; |
24 |
|
import java.io.*; |
25 |
|
|
26 |
public class MotdHandler implements Listener, CommandExecutor { |
public class MotdHandler implements Listener, CommandExecutor { |
27 |
|
|
31 |
this.plugin = plugin; |
this.plugin = plugin; |
32 |
} |
} |
33 |
|
|
34 |
|
private String colors(String str) { |
35 |
|
return ChatColor.translateAlternateColorCodes('&', str ); |
36 |
|
} |
37 |
|
|
38 |
private void readMotdFile(CommandSender player) { |
private void readMotdFile(CommandSender player) { |
39 |
File motd = new File(plugin.getDataFolder(), "motd.txt"); |
File motd = new File(plugin.getDataFolder(), "motd.txt"); |
40 |
if (motd.exists()) { |
if (motd.exists()) { |
41 |
try { |
try { |
42 |
RandomAccessFile raf = new RandomAccessFile(motd,"r"); |
BufferedReader in = new BufferedReader( new InputStreamReader( new FileInputStream( motd) ) ); |
43 |
String line; |
String line; |
44 |
while ( (line=raf.readLine()) != null) { |
while ( (line=in.readLine()) != null) { |
45 |
line = line.trim(); |
line = line.trim(); |
46 |
if (line.startsWith("#")) { |
if (line.startsWith("#")) { |
47 |
continue; |
continue; |
48 |
} |
} |
49 |
if (line.length() > 0) { |
if (line.length() > 0) { |
50 |
|
line = colors(line); |
51 |
player.sendMessage( line ); |
player.sendMessage( line ); |
52 |
} |
} |
53 |
} |
} |
54 |
raf.close(); |
in.close(); |
55 |
} catch (IOException e) { |
} catch (IOException e) { |
56 |
plugin.getLogger().severe("Could not read motd.txt:" + e.getMessage() ); |
plugin.getLogger().severe("Could not read motd.txt:" + e.getMessage() ); |
57 |
} |
} |
72 |
////////////////////////////////////////////////////// |
////////////////////////////////////////////////////// |
73 |
|
|
74 |
|
|
|
Player players[] = plugin.getServer().getOnlinePlayers(); |
|
75 |
|
|
76 |
StringBuilder sb = new StringBuilder(); |
StringBuilder sb = new StringBuilder(); |
77 |
for (Player player : players) { |
for (Player player : plugin.getServer().getOnlinePlayers() ) { |
78 |
sb.append(", "); |
sb.append(", "); |
79 |
sb.append( player.getName() ); |
sb.append( player.getName() ); |
80 |
} |
} |