Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fr.SuperAntonio31.AntoinePlug;
- import java.io.File;
- import java.io.IOException;
- import java.util.ArrayList;
- import java.util.Map;
- import org.bukkit.Bukkit;
- import org.bukkit.command.Command;
- import org.bukkit.command.CommandExecutor;
- import org.bukkit.command.CommandSender;
- import org.bukkit.configuration.file.YamlConfiguration;
- import org.bukkit.entity.Player;
- import org.bukkit.scheduler.BukkitRunnable;
- public class commands implements CommandExecutor{
- public File fileCommands;
- public Main main;
- Map<String, String> sms;
- ArrayList<String> bW ;
- ArrayList<Character> forFinal ;
- public commands (Main main) {
- this.fileCommands = main.fileCommands;
- this.main = main;
- this.sms = main.sms;
- this.bW = main.bW;
- this.forFinal = main.forFinal;
- }
- @Override
- public boolean onCommand(CommandSender s, Command cmd, String label, String[] a) {
- if(s instanceof Player) {
- StringBuilder message = new StringBuilder();
- message.append(a[1]+" ");
- YamlConfiguration config = YamlConfiguration.loadConfiguration(fileCommands);
- if(!config.contains("messages")) {
- config.set("messages.help-msg", ""
- + "§cHey ! §6Syntaxe de la commande: §b/msg §e[Pseudo] [Votre Message]"
- + "§fCette commande vous permet d'envoyer un message privé à un joueur spécifique.");
- config.set("messages.help-tell", ""
- + "§cHey ! §6Syntaxe de la commande: §b/tell §e[Pseudo] [Votre Message]"
- + "§fCette commande vous permet d'envoyer un message privé à un joueur spécifique.");
- config.set("messages.help-m", ""
- + "§cHey ! §6Syntaxe de la commande: §b/m §e[Pseudo] [Votre Message]"
- + "§fCette commande vous permet d'envoyer un message privé à un joueur spécifique.");
- try {
- config.save(fileCommands);
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- String c = cmd.getName();
- Player p = (Player)s;
- if((c.equalsIgnoreCase("msg"))) {
- if(a.length < 2) {
- p.sendMessage(config.getString("messages.help-msg"));
- }
- if(a.length >= 2) {
- Player p2 = Bukkit.getPlayer(a[0]);
- if(p2 instanceof Player) {
- new BukkitRunnable() {
- StringBuilder motParMot = new StringBuilder();
- ArrayList<String> tableauDeMots = new ArrayList<String>();
- int i1 = -1;
- char lettreParLettre;
- @Override
- public void run() {
- if(i1 < message.length()-1) {
- i1++;
- lettreParLettre = message.charAt(i1);
- if(lettreParLettre != ' ') {
- motParMot.append(lettreParLettre); //ajout de la lettre au mot temporaire
- }else {
- if(motParMot != null) { //Si la phrase ne commence pas par un espace
- if(sms.containsKey(motParMot.toString().toLowerCase())) {
- ;
- tableauDeMots.add(sms.get(motParMot.toString()));
- }
- else if(bW.contains(motParMot.toString().toLowerCase())) { //Si c'est un gros mots
- tableauDeMots.add(motParMot.toString().toLowerCase().replaceAll("[a-zA-Z!]","*"));
- motParMot.setLength(0);
- }else {
- tableauDeMots.add("§f"+motParMot.toString());
- }
- motParMot.setLength(0);
- }
- }
- }else {
- StringBuilder phrase = new StringBuilder();
- for ( String mot : tableauDeMots) {
- phrase.append(mot);
- phrase.append(' ');
- }
- phrase.setCharAt(0,Character.toUpperCase(phrase.charAt(0)));
- phrase.deleteCharAt(phrase.length()-1);//j'enl_ve espace en trop
- if(forFinal.contains(phrase.charAt(phrase.length()-1))) {
- p.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- p2.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- }else {
- phrase.append('.');
- p.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- p2.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- }
- this.cancel();
- }
- }
- }.runTaskTimer(main, 0L, (long) 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001);
- }else {
- p.sendMessage("§6Le joueur §b"+p.getName()+"§6 n'est pas en ligne !");
- }
- }
- }
- if((c.equalsIgnoreCase("tell"))) {
- if(a.length < 2) {
- p.sendMessage(config.getString("messages.help-tell"));
- }
- if(a.length >= 2) {
- Player p2 = Bukkit.getPlayer(a[0]);
- if(p2 instanceof Player) {
- new BukkitRunnable() {
- StringBuilder motParMot = new StringBuilder();
- ArrayList<String> tableauDeMots = new ArrayList<String>();
- int i1 = -1;
- char lettreParLettre;
- @Override
- public void run() {
- if(i1 < message.length()-1) {
- i1++;
- lettreParLettre = message.charAt(i1);
- if(lettreParLettre != ' ') {
- motParMot.append(lettreParLettre); //ajout de la lettre au mot temporaire
- }else {
- if(motParMot != null) { //Si la phrase ne commence pas par un espace
- if(sms.containsKey(motParMot.toString().toLowerCase())) {
- ;
- tableauDeMots.add(sms.get(motParMot.toString()));
- }
- else if(bW.contains(motParMot.toString().toLowerCase())) { //Si c'est un gros mots
- tableauDeMots.add(motParMot.toString().toLowerCase().replaceAll("[a-zA-Z!]","*"));
- motParMot.setLength(0);
- }else {
- tableauDeMots.add("§f"+motParMot.toString());
- }
- motParMot.setLength(0);
- }
- }
- }else {
- StringBuilder phrase = new StringBuilder();
- for ( String mot : tableauDeMots) {
- phrase.append(mot);
- phrase.append(' ');
- }
- phrase.setCharAt(0,Character.toUpperCase(phrase.charAt(0)));
- phrase.deleteCharAt(phrase.length()-1);//j'enl_ve espace en trop
- if(forFinal.contains(phrase.charAt(phrase.length()-1))) {
- p.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- p2.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- }else {
- phrase.append('.');
- p.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- p2.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- }
- this.cancel();
- }
- }
- }.runTaskTimer(main, 0L, (long) 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001);
- }else {
- p.sendMessage("§6Le joueur §b"+p.getName()+"§6 n'est pas en ligne !");
- }
- }
- }
- if((c.equalsIgnoreCase("m"))) {
- if(a.length < 2) {
- p.sendMessage(config.getString("messages.help-m"));
- }
- if(a.length >= 2) {
- Player p2 = Bukkit.getPlayer(a[0]);
- if(p2 instanceof Player) {
- new BukkitRunnable() {
- StringBuilder motParMot = new StringBuilder();
- ArrayList<String> tableauDeMots = new ArrayList<String>();
- int i1 = -1;
- char lettreParLettre;
- @Override
- public void run() {
- if(i1 < message.length()-1) {
- i1++;
- lettreParLettre = message.charAt(i1);
- if(lettreParLettre != ' ') {
- motParMot.append(lettreParLettre); //ajout de la lettre au mot temporaire
- }else {
- if(motParMot != null) { //Si la phrase ne commence pas par un espace
- if(sms.containsKey(motParMot.toString().toLowerCase())) {
- tableauDeMots.add(sms.get(motParMot.toString()));
- }
- else if(bW.contains(motParMot.toString().toLowerCase())) { //Si c'est un gros mots
- tableauDeMots.add(motParMot.toString().toLowerCase().replaceAll("[a-zA-Z!]","*"));
- motParMot.setLength(0);
- }else {
- tableauDeMots.add("§f"+motParMot.toString());
- }
- motParMot.setLength(0);
- }
- }
- }else {
- StringBuilder phrase = new StringBuilder();
- for ( String mot : tableauDeMots) {
- phrase.append(mot);
- phrase.append(' ');
- }
- phrase.setCharAt(0,Character.toUpperCase(phrase.charAt(0)));
- phrase.deleteCharAt(phrase.length()-1);//j'enl_ve espace en trop
- if(forFinal.contains(phrase.charAt(phrase.length()-1))) {
- p.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- p2.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- }else {
- phrase.append('.');
- p.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- p2.sendMessage("§7["+p.getDisplayName()+"§7]"+"§6 --> "+"§7["+p2.getDisplayName()+"§7] "+"§f"+phrase);
- }
- this.cancel();
- }
- }
- }.runTaskTimer(main, 0L, (long) 0.00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001);
- }else {
- p.sendMessage("§6Le joueur §b"+p.getName()+"§6 n'est pas en ligne !");
- }
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement