Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 4.40 KB | None | 0 0
  1. package fr.IDreamZ;
  2.  
  3. import com.massivecraft.factions.FPlayer;
  4. import com.massivecraft.factions.FPlayers;
  5. import com.massivecraft.factions.Faction;
  6. import com.sk89q.worldguard.bukkit.WGBukkit;
  7. import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
  8. import com.sk89q.worldguard.protection.managers.RegionManager;
  9. import com.sk89q.worldguard.protection.regions.ProtectedRegion;
  10. import java.util.HashMap;
  11. import java.util.Map.Entry;
  12. import org.bukkit.Bukkit;
  13. import org.bukkit.Server;
  14. import org.bukkit.block.Block;
  15. import org.bukkit.block.BlockState;
  16. import org.bukkit.block.Sign;
  17. import org.bukkit.command.PluginCommand;
  18. import org.bukkit.configuration.file.FileConfiguration;
  19. import org.bukkit.configuration.file.FileConfigurationOptions;
  20. import org.bukkit.entity.Player;
  21. import org.bukkit.event.EventHandler;
  22. import org.bukkit.event.Listener;
  23. import org.bukkit.event.block.Action;
  24. import org.bukkit.event.player.PlayerInteractEvent;
  25. import org.bukkit.plugin.PluginManager;
  26. import org.bukkit.plugin.java.JavaPlugin;
  27.  
  28. public class Main
  29.   extends JavaPlugin
  30.   implements Listener
  31. {
  32.   public HashMap<String, String> youtuber = new HashMap();
  33.   public static Main instance;
  34.   WorldGuardPlugin worldGuard;
  35.  
  36.   public static Main getInstance()
  37.   {
  38.     return instance;
  39.   }
  40.  
  41.   public void onEnable()
  42.   {
  43.     instance = this;
  44.     try
  45.     {
  46.       this.worldGuard = ((WorldGuardPlugin)Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"));
  47.     }
  48.     catch (Exception e)
  49.     {
  50.       e.printStackTrace();
  51.     }
  52.     getCommand("addYoutuber").setExecutor(new Commandes());
  53.     getCommand("YoutuberList").setExecutor(new Commandes());
  54.     getCommand("SaveYoutuber").setExecutor(new Commandes());
  55.     getConfig().options().copyDefaults(true);
  56.     saveConfig();
  57.     Bukkit.getServer().getPluginManager().registerEvents(this, this);
  58.     for (String str : getConfig().getKeys(true))
  59.     {
  60.       String chaine = getConfig().getString(str);
  61.      
  62.       this.youtuber.put(str, chaine);
  63.     }
  64.   }
  65.  
  66.   @EventHandler
  67.   public void onInteract(PlayerInteractEvent e)
  68.   {
  69.     Player p = e.getPlayer();
  70.     if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
  71.       for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
  72.         if (r.getId().equalsIgnoreCase("youtuber"))
  73.         {
  74.           BlockState block = e.getClickedBlock().getState();
  75.           if ((block instanceof Sign))
  76.           {
  77.             Sign sign = (Sign)block;
  78.             if (sign != null) {
  79.               for (Map.Entry<String, String> entry : getInstance().youtuber.entrySet())
  80.               {
  81.                 entry.getKey();
  82.                 entry.getValue();
  83.                 if ((sign.getLine(0).equalsIgnoreCase("&9[Youtubeur]".replace("&", "�"))) &&
  84.                   (sign.getLine(1).equalsIgnoreCase((String)entry.getKey())))
  85.                 {
  86.                   Player py = Bukkit.getServer().getPlayer((String)entry.getKey());
  87.                   FPlayer fp = (FPlayer)FPlayers.i.get(py);
  88.                   Faction faction = fp.getFaction();
  89.                   if (faction != null) {
  90.                     p.sendMessage("�fFaction de �9" + (String)entry.getKey() + ": �c" + faction.getTag());
  91.                   } else {
  92.                     p.sendMessage("�cLe joueur n'a pas de faction!");
  93.                   }
  94.                 }
  95.               }
  96.             }
  97.           }
  98.         }
  99.       }
  100.     } else if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
  101.       for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
  102.         if (r.getId().equalsIgnoreCase("youtuber"))
  103.         {
  104.           BlockState block = e.getClickedBlock().getState();
  105.           if ((block instanceof Sign))
  106.           {
  107.             Sign sign = (Sign)block;
  108.             if (sign != null) {
  109.               for (Map.Entry<String, String> entry : getInstance().youtuber.entrySet())
  110.               {
  111.                 entry.getKey();
  112.                 entry.getValue();
  113.                 if ((sign.getLine(0).equalsIgnoreCase("&9[Youtubeur]".replace("&", "�"))) &&
  114.                   (sign.getLine(1).equalsIgnoreCase((String)entry.getKey()))) {
  115.                   p.sendMessage("�fChaine youtube de �9" + (String)entry.getKey() + ": �c" + (String)entry.getValue());
  116.                 }
  117.               }
  118.             }
  119.           }
  120.         }
  121.       }
  122.     }
  123.   }
  124. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement