Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.util.HashMap;
- public class MyListener extends PluginListener
- {
- static final Gethome plugin = new Gethome();
- HashMap<String, String> players = read("homes.txt");
- public boolean onCommand(Player player, String[] split) {
- if ((split[0].equals(plugin.getCommandName())) && (player.canUseCommand(plugin.getCommandName()))) {
- if (split.length == 1) {
- if (this.players.containsKey(player.getName()))
- player.notify("Votre home se trouve à " + (String)this.players.get(player.getName()));
- else
- player.notify("Vous n'avez pas enregistré d'home !");
- }
- else {
- player.notify("Syntaxe correcte : " + plugin.getCommandName() + " " + plugin.getCommandDesc());
- }
- return true;
- }if ((split[0].equals("/sethome")) && (player.canUseCommand("/sethome"))) {
- this.players = read("homes.txt");
- }
- return false;
- }
- public static HashMap<String, String> read(String file) {
- HashMap map = new HashMap();
- try {
- BufferedReader buff = new BufferedReader(new FileReader(file));
- try
- {
- String line;
- while ((line = buff.readLine()) != null)
- {
- String line;
- String[] split = line.split(":");
- float x = Float.parseFloat(split[1]); float y = Float.parseFloat(split[2]); float z = Float.parseFloat(split[3]);
- map.put(split[0], (int)x + ", " + (int)y + ", " + (int)z);
- }
- } finally {
- buff.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- return map;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement