Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.IDreamZ;
- import com.massivecraft.factions.FPlayer;
- import com.massivecraft.factions.FPlayers;
- import com.massivecraft.factions.Faction;
- import com.sk89q.worldguard.bukkit.WGBukkit;
- import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
- import com.sk89q.worldguard.protection.managers.RegionManager;
- import com.sk89q.worldguard.protection.regions.ProtectedRegion;
- import java.util.HashMap;
- import java.util.Map.Entry;
- import org.bukkit.Bukkit;
- import org.bukkit.Server;
- import org.bukkit.block.Block;
- import org.bukkit.block.BlockState;
- import org.bukkit.block.Sign;
- import org.bukkit.command.PluginCommand;
- import org.bukkit.configuration.file.FileConfiguration;
- import org.bukkit.configuration.file.FileConfigurationOptions;
- import org.bukkit.entity.Player;
- import org.bukkit.event.EventHandler;
- import org.bukkit.event.Listener;
- import org.bukkit.event.block.Action;
- import org.bukkit.event.player.PlayerInteractEvent;
- import org.bukkit.plugin.PluginManager;
- import org.bukkit.plugin.java.JavaPlugin;
- public class Main
- extends JavaPlugin
- implements Listener
- {
- public HashMap<String, String> youtuber = new HashMap();
- public static Main instance;
- WorldGuardPlugin worldGuard;
- public static Main getInstance()
- {
- return instance;
- }
- public void onEnable()
- {
- instance = this;
- try
- {
- this.worldGuard = ((WorldGuardPlugin)Bukkit.getServer().getPluginManager().getPlugin("WorldGuard"));
- }
- catch (Exception e)
- {
- e.printStackTrace();
- }
- getCommand("addYoutuber").setExecutor(new Commandes());
- getCommand("YoutuberList").setExecutor(new Commandes());
- getCommand("SaveYoutuber").setExecutor(new Commandes());
- getConfig().options().copyDefaults(true);
- saveConfig();
- Bukkit.getServer().getPluginManager().registerEvents(this, this);
- for (String str : getConfig().getKeys(true))
- {
- String chaine = getConfig().getString(str);
- this.youtuber.put(str, chaine);
- }
- }
- @EventHandler
- public void onInteract(PlayerInteractEvent e)
- {
- Player p = e.getPlayer();
- if (e.getAction() == Action.RIGHT_CLICK_BLOCK) {
- for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
- if (r.getId().equalsIgnoreCase("youtuber"))
- {
- BlockState block = e.getClickedBlock().getState();
- if ((block instanceof Sign))
- {
- Sign sign = (Sign)block;
- if (sign != null) {
- for (Map.Entry<String, String> entry : getInstance().youtuber.entrySet())
- {
- entry.getKey();
- entry.getValue();
- if ((sign.getLine(0).equalsIgnoreCase("&9[Youtubeur]".replace("&", "�"))) &&
- (sign.getLine(1).equalsIgnoreCase((String)entry.getKey())))
- {
- Player py = Bukkit.getServer().getPlayer((String)entry.getKey());
- FPlayer fp = (FPlayer)FPlayers.i.get(py);
- Faction faction = fp.getFaction();
- if (faction != null) {
- p.sendMessage("�fFaction de �9" + (String)entry.getKey() + ": �c" + faction.getTag());
- } else {
- p.sendMessage("�cLe joueur n'a pas de faction!");
- }
- }
- }
- }
- }
- }
- }
- } else if (e.getAction() == Action.LEFT_CLICK_BLOCK) {
- for (ProtectedRegion r : WGBukkit.getRegionManager(p.getWorld()).getApplicableRegions(p.getLocation())) {
- if (r.getId().equalsIgnoreCase("youtuber"))
- {
- BlockState block = e.getClickedBlock().getState();
- if ((block instanceof Sign))
- {
- Sign sign = (Sign)block;
- if (sign != null) {
- for (Map.Entry<String, String> entry : getInstance().youtuber.entrySet())
- {
- entry.getKey();
- entry.getValue();
- if ((sign.getLine(0).equalsIgnoreCase("&9[Youtubeur]".replace("&", "�"))) &&
- (sign.getLine(1).equalsIgnoreCase((String)entry.getKey()))) {
- p.sendMessage("�fChaine youtube de �9" + (String)entry.getKey() + ": �c" + (String)entry.getValue());
- }
- }
- }
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement