ClocxHD

ChatFilter

Jan 10th, 2015
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.58 KB | None | 0 0
  1. package main;
  2.  
  3. import java.io.File;
  4. import java.io.FileNotFoundException;
  5. import java.util.ArrayList;
  6. import java.util.Scanner;
  7. import org.bukkit.ChatColor;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.player.PlayerCommandPreprocessEvent;
  11. import org.bukkit.plugin.java.JavaPlugin;
  12.  
  13. public class ChatFilter extends JavaPlugin {
  14.    
  15.     ArrayList<String> blacklist = new ArrayList<String>();
  16.    
  17.     @Override
  18.     public void onEnable() {
  19.         System.out.println(ChatColor.GREEN + "ChatFilter erfolgreich gestartet!");
  20.         System.out.println("");
  21.         System.out.println("");
  22.         System.out.println(ChatColor.RED + "Hinweis: Hier kΓΆnnte Ihre Werbung stehen!");
  23.         new ChatEventListener(this);
  24.        
  25.         //Blacklist laden
  26.         //File file = new File(this.getDataFolder() + "\\blacklist.txt");
  27.         File file = new File("/var/server/lobby/plugins/blacklist.txt");
  28.        
  29.         try {
  30.             Scanner s = new Scanner(file);
  31.            
  32.             while(s.hasNextLine()) {
  33.                 blacklist.add(s.nextLine());
  34.             }
  35.            
  36.             s.close();
  37.            
  38.     } catch (FileNotFoundException e) {
  39.         System.err.println("Blacklist nicht gefunden. Bitte die Datei blacklist.txt im Plugin-Ordner anlegen.");
  40.     }
  41.     //-- Blacklist laden
  42.     }
  43.    
  44.     @EventHandler
  45.     public void NoPl(PlayerCommandPreprocessEvent event) {
  46.         Player p = event.getPlayer();
  47.         String command = event.getMessage();
  48.         if ((command.equalsIgnoreCase("/pl")) || (command.equalsIgnoreCase("/plugins"))) {
  49.             event.setCancelled(true);
  50.             p.sendMessage(ChatColor.GOLD + "[NoPl]" + ChatColor.GREEN + " Du darfst die Plugins nicht sehen!");
  51.             }
  52.         }
  53.     }
  54.  
  55. //}
Advertisement
Add Comment
Please, Sign In to add comment