Browse Source

Open Sourced!

master
Florian Bouillon 8 months ago
commit
6a8764194c
Signed by: Avior <florian.bouillon@delta-wings.net> GPG Key ID: B143FF27EF555D16
29 changed files with 3345 additions and 0 deletions
  1. +8
    -0
      .gitignore
  2. +60
    -0
      .gitlab-ci.yml
  3. +37
    -0
      Chat-Manager.iml
  4. +1
    -0
      LICENSE
  5. +1
    -0
      README.md
  6. +86
    -0
      pom.xml
  7. +191
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Api/API.java
  8. +28
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Broadcast.java
  9. +483
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Channel.java
  10. +80
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Chat.java
  11. +31
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/ChatManager.java
  12. +18
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Clearchat.java
  13. +20
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/LockChat.java
  14. +41
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Mute.java
  15. +27
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Mutelist.java
  16. +48
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/StaffChat.java
  17. +50
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/StaffSwitch.java
  18. +32
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Unmute.java
  19. +118
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/Config.java
  20. +15
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/Custom.java
  21. +89
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/FileManager.java
  22. +42
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/Notifier.java
  23. +159
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Listeners/ChatListener.java
  24. +31
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Listeners/DeathListener.java
  25. +28
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Listeners/PlayerLoginLogoutListener.java
  26. +352
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Main.java
  27. +1021
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Metrics.java
  28. +44
    -0
      src/main/java/net/DeltaWings/Minecraft/ChatManager/Scheduler/Scheduler.java
  29. +204
    -0
      src/main/ressources/plugin.yml

+ 8
- 0
.gitignore View File

@@ -0,0 +1,8 @@
#VSCode
.vscode

#Java
target/
.classpath
.project
.settings/

+ 60
- 0
.gitlab-ci.yml View File

@@ -0,0 +1,60 @@
# This file is a template, and might need editing before it works on your project.
---

variables:
# This will supress any download for dependencies and plugins or upload messages which would clutter the console log.
# `showDateTime` will show the passed time in milliseconds. You need to specify `--batch-mode` to make this work.
MAVEN_OPTS: "-Dmaven.repo.local=.m2/repository -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=WARN -Dorg.slf4j.simpleLogger.showDateTime=true -Djava.awt.headless=true"
# As of Maven 3.3.0 instead of this you may define these options in `.mvn/maven.config` so the same config is used
# when running from the command line.
# `installAtEnd` and `deployAtEnd` are only effective with recent version of the corresponding plugins.
MAVEN_CLI_OPTS: "--batch-mode --errors --fail-at-end --show-version -DinstallAtEnd=true -DdeployAtEnd=true"

# Cache downloaded dependencies and plugins between builds.
# To keep cache across branches add 'key: "$CI_JOB_REF_NAME"'
cache:
paths:
- .m2/repository

# For `master` branch run `mvn deploy` automatically.
# Here you need to decide whether you want to use JDK7 or 8.
# To get this working you need to define a volume while configuring your gitlab-ci-multi-runner.
# Mount your `settings.xml` as `/root/.m2/settings.xml` which holds your secrets.
# See https://maven.apache.org/settings.html
Build:
# Use stage test here, so the pages job may later pickup the created site.
stage: build
script:
- mvn -B clean install
- mvn -B test
# Archive up the built documentation site.
artifacts:
paths:
- target/
image: maven
Test:
# Use stage test here, so the pages job may later pickup the created site.
stage: test
script:
- mvn -B test
# Archive up the built documentation site.
artifacts:
paths:
- target/
image: maven

Deploy:
# Use stage test here, so the pages job may later pickup the created site.
stage: deploy
script:
- cp ./settings-security.xml $HOME/.m2/settings-security.xml
- cp ./settings.xml $HOME/.m2/settings.xml
- mvn -B deploy
only:
- tags
# Archive up the built documentation site.
artifacts:
paths:
- target
image: maven

+ 37
- 0
Chat-Manager.iml View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="minecraft" name="Minecraft">
<configuration>
<autoDetectTypes>
<platformType>SPIGOT</platformType>
</autoDetectTypes>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/ressources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
<excludeFolder url="file://$MODULE_DIR$/src/main/excluded ressources" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.11.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12.2-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.19" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.12-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.12.2-R0.1-SNAPSHOT" level="project" />
</component>
</module>

+ 1
- 0
LICENSE View File

@@ -0,0 +1 @@
all rights reserved

+ 1
- 0
README.md View File

@@ -0,0 +1 @@
WIKI !!!

+ 86
- 0
pom.xml View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.DeltaWings</groupId>
<artifactId>ChatManager</artifactId>
<version>1.4.0</version>
<packaging>jar</packaging>

<name>Chat Manager</name>

<description>Have an Ultra customizable Chat Manager</description>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<url>http://delta-wings.net</url>

<build>
<defaultGoal>clean package</defaultGoal>
<finalName>Chat-Manager</finalName>
<extensions>
<!-- Enabling the use of FTP -->
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ftp</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>
<plugins>

<plugin>
<version>3.1</version>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<minimizeJar>true</minimizeJar>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/ressources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<repositories>
<repository>
<id>spigotmc-repo</id>
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>

+ 191
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Api/API.java View File

@@ -0,0 +1,191 @@
package net.DeltaWings.Minecraft.ChatManager.Api;

import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import net.DeltaWings.Minecraft.ChatManager.Custom.FileManager;
import net.DeltaWings.Minecraft.ChatManager.Main;

import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class API {
/**
* Replace each
* @param text text to replace
* @param replacement map to replace the key by the value
* @return the replaced text
*/
public static String multiReplace(String text, HashMap<String, String> replacements) {
for(Map.Entry<String, String> entry : replacements.entrySet()) {
Main.log(entry.getKey());
Main.log(entry.getValue());
text = text.replace(entry.getKey(), entry.getValue());
}
return text.replace("&", "§");
}

/**
* Send a broadcast message
* @param Sender Command sender or desired sender
* @param Message message broadcasted
*/
public static void broadcast(String Sender, String Message) {
Config a = new Config("config", "broadcast");
HashMap<String, String> replacements = new HashMap<>();
replacements.put("[player]", Sender);
replacements.put("[message]", Message);
Bukkit.broadcastMessage(multiReplace(a.getString("format"), replacements));
}

/**
* Clearchat
* @param Sender the Sender is the name
* @param Receiver the receiver. if "null" will send to everyone
*/
public static void clearchat(String Sender, String Receiver) {
if(Receiver != null) {
for ( Player p : Bukkit.getServer().getOnlinePlayers() ) if ( p.getName().equalsIgnoreCase(Receiver) ) cca(p, Sender);
} else for ( Player p : Bukkit.getServer().getOnlinePlayers() ) cca(p, Sender);
}

private static void cca(Player p, String c) {
for ( int i = 0; i < new Config("config", "clearchat").getInt("lines-to-clear"); i++ ) p.sendMessage(" ");
p.sendMessage(new Config("messages", "clearchat").getString("clear").replace("[cleaner]", c).replace("&", "§"));
}

private static Boolean locked = false;

/**
* lock or unlock the chat
*/
public static void lockchat() {
Config config = new Config("config", "lockchat");
if ( locked ) {
locked = false;
Bukkit.broadcastMessage(config.getString("unlocked").replace("&", "§"));
} else {
locked = true;
Bukkit.broadcastMessage(config.getString("locked").replace("&", "§"));
}
}

/**
* Get if the chat is locked or not
* @return the state of the chat
*/
public static Boolean isChatLocked() {
return locked;
}

/**
*
* @param Sender Sender
* @param Player Player muted
* @param Time Time muted(-1 for perma)
* @param Type Type(all, chat, cmd)
* @param Reason reason
*/
public static void mute(CommandSender Sender, Player Player, Integer Time, String Type, String Reason) {
Config c = new Config("players", Player.getName());
Config m = new Config("messages", "mute");
if(Type.equalsIgnoreCase("all")) {
if ( c.getBoolean("mute.chat") && c.getBoolean("mute.cmd") ) Sender.sendMessage("");
if(!c.getBoolean("mute.chat")) mua(Player, Time, Reason, Type, Sender);
if(!c.getBoolean("mute.cmd")) mub(Player, Time, Reason, Type, Sender);
} else if(!c.getBoolean("mute." + Type)) {
if(Type.equalsIgnoreCase("chat")) mua(Player, Time, Reason, Type, Sender);
else mub(Player, Time, Reason, Type, Sender);
} else Sender.sendMessage(m.getString("already-muted").replace("[type]", Type).replace("&", "§"));
}

//mute from chat
private static void mua(Player p, Integer i, String r,String t, CommandSender s) {
Config c = new Config("players", p.getName());
Config m = new Config("messages", "mute");
c.set("mute.chat", true);
if(i == -1) c.set("mute.from", -1);
else c.set("mute.from", i * 60000 + System.currentTimeMillis());
c.set("mute.time", i);
c.set("mute.reason", r);
c.save();
p.sendMessage(m.getString("muted.self").replace("[from]", "chat").replace("[reason]", r).replace("&", "§"));
s.sendMessage(m.getString("muted.other").replace("[player]", p.getName()).replace("[type]", t).replace("[reason]", r).replace("&", "§"));
}

private static void mub(Player p, Integer i, String r,String t, CommandSender s) {
Config c = new Config("players", p.getName());
Config m = new Config("messages", "mute");
c.set("mute.cmd", true);
if(i == -1) c.set("mute.time", new Long(i));
else c.set("mute.time", System.currentTimeMillis() + (i * 60000));
c.set("mute.reason", r);
c.save();
p.sendMessage(m.getString("muted.self").replace("[from]", "commands").replace("[reason]", r).replace("&", "§"));
s.sendMessage(m.getString("muted.other").replace("[player]", p.getName()).replace("[type]", t).replace("[reason]", r).replace("&", "§"));
}

/**
*
* @param Sender Sender of the command
* @param Player Player unmutted
* @param Type Type unmutted(chat, cmd, all)
*/
public static void unmute(CommandSender Sender, Player Player, String Type) {
Config c = new Config("players", Player.getName());
if(Type.equalsIgnoreCase("all") || Type.equalsIgnoreCase("chat")) {
c.set("mute.chat", false);
}
if(Type.equalsIgnoreCase("all") || Type.equalsIgnoreCase("cmd")) {
c.set("mute.cmd", false);
}
c.save();
Config m = new Config("messages", "mute");
Sender.sendMessage(m.getString("unmutted.other").replace("[player]", Player.getName()).replace("[type]", Type).replace("&", "§"));
Player.sendMessage(m.getString("unmutted.self").replace("[type]", Type).replace("&", "§"));
}

/**
*
* @return String list of muted players ex : [Aviortheking,1489446063044,"banned"]
*/
public static List<String[]> mutedlist() {
List<String[]> r = new ArrayList<>();
for(String f : FileManager.listFiles(Main.getInstance().getDataFolder() + File.separator + "players")) {
f = f.replace(".yml", "");
Config c = new Config("players", f);
if(c.getBoolean("mute.chat")) {
String[] l = new String[3];
l[0] = f;
if(c.getLong("mute.from") == -1) l[1] = "permanent";
else l[1] = c.getInt("mute.time") + " Minutes";
l[2] = c.getString("mute.reason");
r.add(l);
}
}
return r;
}

static public void logMessage(String message) {
try {
File l = new File(Main.getInstance().getDataFolder(), "logs.txt");
FileManager.createFile(l);
PrintWriter p = new PrintWriter(new FileWriter(l, true));
p.println(message);
p.close();
} catch (IOException e) {
Main.error("Error !");
e.printStackTrace();
}

}
}

+ 28
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Broadcast.java View File

@@ -0,0 +1,28 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class Broadcast implements CommandExecutor {

@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
if((s instanceof Player && s.hasPermission("chat-manager.broadcast")) || s instanceof ConsoleCommandSender) {
if(a.length > 0) {
StringBuilder m = new StringBuilder();
for(String r : a) m.append(r).append(" ");
API.broadcast(s.getName(), m.toString());
return true;
} else {
return false;
}
} else s.sendMessage(new Config("messages", "global").getString("permission").replace("&", "§"));
return true;
}
}

+ 483
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Channel.java View File

@@ -0,0 +1,483 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import net.DeltaWings.Minecraft.ChatManager.Custom.FileManager;
import net.DeltaWings.Minecraft.ChatManager.Main;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class Channel implements CommandExecutor {

private Config a = new Config("messages", "channel");
private Config b = new Config("config", "channel");
private FileManager c = new FileManager();
private Main i = Main.getInstance();
private String j = File.separator;
private final File d = new File(i.getDataFolder() + j + "channels");
private Config h = new Config("messages", "global");

@Override
public boolean onCommand(CommandSender e, Command f, String label, String[] g) {
if ( f.getName().equalsIgnoreCase("channel") ) {
// /channels list
if ( g.length == 1 && g[0].equalsIgnoreCase("list") ) {
if ( e instanceof Player ) {
if ( e.hasPermission("chat-manager.channel.list") ) a(e);
else e(e);
} else a(e);
// /channel create <channel> WORK
} else if ( g.length == 2 && g[0].equalsIgnoreCase("create") ) {
if ( e instanceof Player ) {
if ( e.hasPermission("chat-manager.channel.create") ) b(g, e);
else e(e);
} else e.sendMessage(a.getString("console-cant"));
// /channel leave <channel> WORK
} else if ( g.length == 2 && g[0].equalsIgnoreCase("leave") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.leave")) c(g, e);
else e(e);
} else e.sendMessage(a.getString("console-cant"));
// /channel join <channel> WORK
} else if ( g.length == 2 && g[0].equalsIgnoreCase("join") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.join")) d(g, e);
else e(e);
} else e.sendMessage(a.getString("console-cant"));
// /channel invite <player> <channel> need multiplayers p isn't online et invited messages
} else if ( g.length == 3 && g[0].equalsIgnoreCase("invite") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.invite")) f(g, e);
else e(e);
} else e.sendMessage(a.getString("console-cant"));
// /channel disband <channel> WORK
} else if ( g.length == 2 && g[0].equalsIgnoreCase("disband") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.disband")) g(g, e);
else e(e);
} else g(g, e);
// /channel kick <player> <channel> WORK
} else if ( g.length == 3 && g[0].equalsIgnoreCase("kick") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.kick")) h(g, e);
else e(e);
} else h(g, e);
// /channel promote <player> <channel> WORK
} else if ( g.length == 3 && g[0].equalsIgnoreCase("promote") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.promote")) i(g, e);
else e(e);
} else e.sendMessage(a.getString("console-cant"));
// /channel demote <player> <channel> WORK
} else if ( g.length == 3 && g[0].equalsIgnoreCase("demote") ) {
if(e instanceof Player) {
if(e.hasPermission("chat-manager.channel.demote")) j(g, e);
else e(e);
} else e.sendMessage(a.getString("console-cant"));
// / channel infos <channel>
} else if ( g.length == 2 && g[0].equalsIgnoreCase("infos") ) {
if ( e.hasPermission("chat-manager.channel.info") ) {
e.sendMessage("Work In Progress");
/*if(config.getStringList("channels-list").contains(args[1])){
/*
List<String> avadmins = config.getStringList("channels."+args[1]+"admins");
String admins = "";
for (int i = 0; i < avadmins.size(); i++) {
String avadminst = avadmins.get(i);
admins = String.valueOf(admins) + avadminst + " ";
}
List<String> avusers = config.getStringList("channels."+args[1]+"users");
String users = "";
for (int i = 0; i < avusers.size(); i++) {
users = String.valueOf(users) + avusers.get(i)+ " ";
}

String admins = "";
String users = "";
String msg = "§fChannel Infos :\nName : "+args[1]+"\n§fprefix : "+config.getString("channels."+args[1]+".prefix")+"\n§fAdmins : "+admins+"\n§fUsers : "+users+"\n§fStatus : "+config.getString("channels."+args[1]+".status");
p.sendMessage(msg.replace("&", "§"));
}*/
} else e.sendMessage(new Config("messages", "global").getString("permission").replace("&", "§"));

// /channel help [<numero>]
} else if ( g.length == 2 && g[0].equalsIgnoreCase("help") ) {
//help
e.sendMessage("Work In Progress");
// /channel admin
} else if ( g.length == 1 && g[0].equalsIgnoreCase("admin") ) {
e.sendMessage("Work In Progress");
/*if(pl.getPermissionsForCmd(p, cmd, args)){
//join
if(args[1].equalsIgnoreCase("join")){
//check si le groupe existe
//check si il fait déjà parti du groupe
//check si c'est le même rang que le sien
//message tu es déjà dans ce channel et ce rang
//vire de son rang et on le fout dans l'autre
//rejoindre le groupe
if(config.getStringList("channels-list").contains(args[1])){
if(args[2].equalsIgnoreCase("admins")||args[2].equalsIgnoreCase("users")){
if(config.getStringList("channels."+args[1]+".admins").contains(p.getName()) || config.getStringList("channels."+args[2]+".users").contains(p.getName())){
if(config.getStringList("channels."+args[1]+"."+args[2]).contains(p.getName())){
//message tu es déjà dans ce channel
p.sendMessage(config.getString("messages.channel.already-in").replace("&", "§"));
}else{
List<String> list = config.getStringList("channels."+args[1]+"."+args[2]);
list.add(p.getName());
config.set("channels."+args[1]+"."+args[2], list);
//message tu as rejoins le channel en tant que args [2]
p.sendMessage(config.getString("messages.channel.channel-joined").replace("&", "§"));
if(args[2].equalsIgnoreCase("admins")){
List<String> remove = config.getStringList("channels."+args[1]+".users");
for ( int i = 0; i < remove.size(); i++){
String tempNamea = remove.get(i);
if(tempNamea.equals(p.getName())){
remove.remove(i);
}
}
}else{
List<String> removea = config.getStringList("channels."+args[1]+".admins");
for ( int ia = 0; ia < removea.size(); ia++){
String tempName = removea.get(ia);
if(tempName.equals(p.getName())){
removea.remove(ia);
}
}
}
}
}else{
List<String> list = config.getStringList("channels."+args[1]+"."+args[2]);
list.add(p.getName());
config.set("channels."+args[1]+"."+args[2], list);
//message tu as rejoins le channel
p.sendMessage(config.getString("messages.channel.channel-joined").replace("&", "§"));

}
}else{
//il y a uniquement deux rangs ! (admins, users)
p.sendMessage(config.getString("messages.badly-written").replace("&", "§"));

}
}else{
//message ce groupe n'existe pas
p.sendMessage(config.getString("messages.channel.dont-exist").replace("&", "§"));

}
}else if(args[1].equalsIgnoreCase("disband")){
//disband
config.set("channels."+args[1]+"status", null);
config.set("channels."+args[1]+".prefix", null);
config.set("channels."+args[1]+".users", null);
config.set("channels."+args[1]+".admins", null);
config.set("channels."+args[1], null);
//message channel disbanded
p.sendMessage(config.getString("messages.channel.channel-disbanded").replace("&", "§"));

}else{
//Message Badly Written
p.sendMessage(config.getString("messages.badly-written").replace("&", "§"));
}
}*/
} else {
e.sendMessage(new Config("messages", "global").getString("badly-written").replace("&", "§"));
}
}
return true;
}

/*
//local vars
k : channels list message
l : CommandSender
m : for loop channel String
n : for loop channel config
*/
private void a(CommandSender l) {
StringBuilder k = new StringBuilder();
if( FileManager.listFiles(d).size() != 0) {
for (String m : FileManager.listFiles(d)) {
Config n = new Config("channels", m.replace(".yml", ""));
if (n.getStringList("users").contains(l.getName())) {
k.append(b.getString("colors.user-name")).append(m.replace(".yml", "")).append(" ");
} else if (n.getStringList("admins").contains(l.getName())) {
k.append(b.getString("colors.admin-name")).append(m.replace(".yml", "")).append(" ");
} else {
k.append(b.getString("colors.default")).append(m.replace(".yml", "")).append(" ");
}
}
}
l.sendMessage(a.getString("list-start").replace("&", "§")+"\n"+ k.toString().replace("&", "§")+"\n"+a.getString("list-end").replace("&", "§"));
}

/*
k = args
l = CommandSender
m = Channel
*/
private void b(String[] k, CommandSender l) {
if(k.length != 2) l.sendMessage(a.getString("one-word-channel").replace("&", "§"));
else {
if(!d.exists()) FileManager.createFolder(d);
Config m = new Config("channels", k[1]);
if(m.exist()) l.sendMessage(a.getString("already-exist").replace("[channel]", k[1]).replace("&", "§"));
else {
m.create();
m.set("users");
List<String> n = new ArrayList<>();
n.add(l.getName());
m.set("admins", n);
m.set("prefix", "[&8"+k[1]+"&f]");
m.set("status", "open");
m.save();
l.sendMessage(a.getString("channel-created").replace("&", "§"));
}
}
}

/*
k = commandSender
*/
private void e(CommandSender k) {
k.sendMessage(h.getString("permission").replace("&", "§"));
}

/*
k = args
l = CommandSender
m = Channel
n = list
o = for loop
*/
private void c(String[] k, CommandSender l) {
if ( k.length != 2 ) l.sendMessage(a.getString("one-word-channel").replace("&", "§"));
else {
if ( FileManager.listFiles(d).contains(k[1] + ".yml") ) {
Config m = new Config("channels", k[1]);
if ( m.getStringList("admins").contains(l.getName()) ) {
List<String> n = m.getStringList("admins");
for ( int o = 0; o < n.size(); o++ ) {
if ( n.get(o).equals(l.getName()) ) {
n.remove(o);
l.sendMessage(a.getString("deleted-from-channel").replace("&", "§"));
if ( n.size() == 0 ) {
FileManager.delete(d + j + k[1] + ".yml");
l.sendMessage(a.getString("last-admin-delete").replace("&", "§"));
} else {
m.set("admins", n);
m.save();
}

}
}
} else if ( m.getStringList("channels." + k[1] + ".users").contains(l.getName()) ) {
List<String> n = m.getStringList("users");
for ( int o = 0; o < n.size(); o++ ) {
if ( n.get(o).equals(l.getName()) ) {
n.remove(o);
l.sendMessage(a.getString("deleted-from-channel").replace("&", "§"));
m.set("users", n);
m.save();
}
}
} else l.sendMessage(a.getString("not-a-user").replace("&", "§"));
} else l.sendMessage(a.getString("dont-exist").replace("&", "§"));
}
}

/*
k = args
l = CommandSender
m = Channel
n = list
o = for loop
p = pconfig
q = name list
*/
private void d(String[] k, CommandSender l) {
if ( FileManager.listFiles(d).contains(k[1] + ".yml") ) {
Config m = new Config("channels", k[1]);
if ( !m.getString("admins").contains(l.getName()) && !m.getString("users").contains(l.getName()) ) {
if ( m.getString("status").equalsIgnoreCase("public") ) {
List<String> n = m.getStringList("users");
n.add(l.getName());
m.set("users", n);
m.save();
l.sendMessage(a.getString("channel-joined").replace("&", "§"));
} else {
Config p = new Config("players", l.getName());
if ( p.getStringList("invite").contains(k[1]) ) {
List<String> q = p.getStringList("invite");
for ( int ic = 0; ic < q.size(); ic++ ) if ( q.get(ic).equals(k[1]) ) q.remove(ic);
p.set("invite", q);
p.save();
List<String> n = m.getStringList("users");
n.add(l.getName());
m.set("users", n);
m.save();
l.sendMessage(a.getString("channel-joined").replace("&", "§"));
} else l.sendMessage(a.getString("cant-join").replace("&", "§"));
}
} else l.sendMessage(a.getString("already-in").replace("&", "§"));
}
}

/*
k = args
l = CommandSender
m = players
n = player config
o = list
*/
private void f(String[] k, CommandSender l) {
if ( k.length != 3 ) l.sendMessage(h.getString("badly-written").replace("&", "§"));
else {
if ( new Config("channels", k[2]).getStringList("users").contains(l.getName()) || new Config("channels", k[2]).getStringList("admins").contains(l.getName()) ) {
for ( Player m : Bukkit.getServer().getOnlinePlayers() ) {
if ( m.getName().equalsIgnoreCase(k[1]) ) {
Config n = new Config("players", m.getName());
if ( !n.exist() ) n.create();
List<String> o = n.getStringList("invite");
o.add(k[2]);
n.set("invite", o);
n.save();
l.sendMessage(a.getString("you-invited").replace("[player]", k[1]).replace("&", "§"));
m.sendMessage(a.getString("invited").replace("[channel]", k[2]).replace("[player]", k[1]).replace("&", "§"));
}
}
} else l.sendMessage(a.getString("not-in-channel").replace("&", "§"));
}
}

/*
k = args
l = CommandSender
*/
private void g(String[] k, CommandSender l) {
if ( k.length == 2 ) {
if ( FileManager.listFiles(d).contains(k[1] + ".yml") ) {
if ( l instanceof ConsoleCommandSender ||new Config("channels", k[1]).getStringList("admins").contains(l.getName()) ) {
FileManager.delete(d + j + k[1] + ".yml");
l.sendMessage(a.getString("channel-disbanded").replace("&", "§"));
} else l.sendMessage(a.getString("cant-disband").replace("&", "§"));
} else l.sendMessage(a.getString("dont-exist").replace("&", "§"));
} else l.sendMessage(a.getString("one-word-channel").replace("&", "§"));
}

/*
k = args
l = CommandSender
m = channel config
n = users list
o = loop
*/
private void h(String[] k, CommandSender l) {
if ( k.length != 3 ) l.sendMessage(new Config("messages", "global").getString("badly-written").replace("&", "§"));
else if ( FileManager.listFiles(d).contains(k[2] + ".yml") ) {
Config m = new Config("channels", k[2]);
if (l instanceof ConsoleCommandSender || m.getStringList("admins").contains(l.getName()) ) {
if (!(l instanceof ConsoleCommandSender) && m.getStringList("admins").contains(k[1]) ) l.sendMessage(a.getString("cant-do-admin").replace("&", "§"));
else if ( m.getStringList("users").contains(k[1]) ) {
List<String> n = m.getStringList("users");
for ( int o = 0; o < n.size(); o++ ) if ( n.get(o).equals(k[1]) ) n.remove(o);
m.set("users", n);
m.save();
l.sendMessage(a.getString("kicked").replace("[player]", k[1]).replace("&", "§"));
} else l.sendMessage(a.getString("not-in-your-cannel").replace("[player]", k[1]).replace("&", "§"));
} else l.sendMessage(a.getString("cant-kick-if-not-admin").replace("&", "§"));
} else l.sendMessage(a.getString("dont-exist").replace("&", "§"));
}

/*
k = args
l = CommandSender
m = channel config
n = users list
o = loop
*/
private void i(String[] k, CommandSender l) {
if ( k.length != 3 ) l.sendMessage(new Config("messages", "global").getString("badly-written").replace("&", "§"));
else if ( FileManager.listFiles(d).contains(k[2] + ".yml") ) {
Config m = new Config("channels", k[2]);
if ( m.getStringList("admins").contains(l.getName()) ) {
if ( m.getStringList("users").contains(k[1]) ) {
List<String> n = m.getStringList("users");
for ( int o = 0; o < n.size(); o++ ) if ( n.get(o).equals(k[1]) ) n.remove(o);
m.set("users", n);
List<String> admins = m.getStringList("admins");
admins.add(k[1]);
m.set("admins", admins);
m.save();
l.sendMessage(a.getString("promoted").replace("[player]", k[1]).replace("&", "§"));
} else l.sendMessage(a.getString("player-is-not-channel").replace("[player]", k[1]).replace("&", "§"));
} else l.sendMessage(a.getString("cant-promote").replace("&", "§"));
} else l.sendMessage(a.getString("dont-exist").replace("&", "§"));
}

/*
k = args
l = CommandSender
m = channel config
n = users list
o = loop
*/
private void j(String[] k, CommandSender l) {
if ( k.length != 3 ) l.sendMessage(new Config("messages", "global").getString("badly-written").replace("&", "§"));
else if ( FileManager.listFiles(d).contains(k[2] + ".yml") ) {
Config m = new Config("channels", k[2]);
if ( m.getStringList("admins").contains(l.getName()) ) {
if ( m.getStringList("admins").contains(k[1]) ) {
List<String> n = m.getStringList("admins");
for ( int o = 0; o < n.size(); o++ ) {
if ( n.get(o).equals(k[1]) ) {
n.remove(o);
}
}
if ( n.size() == 0 ) {
FileManager.delete(d + j + k[2] + ".yml");
l.sendMessage(a.getString("last-admin-delete").replace("&", "§"));
} else {
m.set("admins", n);
List<String> admins = m.getStringList("users");
admins.add(k[1]);
m.set("users", admins);
m.save();
l.sendMessage(a.getString("demoted").replace("[player]", k[1]).replace("&", "§"));
}
} else l.sendMessage(a.getString("is-not-user").replace("&", "§"));
} else l.sendMessage(a.getString("cant-do-admin").replace("&", "§"));
} else l.sendMessage(a.getString("dont-exist").replace("&", "§"));
}
/*
gen var
a : new Config("messages", "channel"); // ou en général
b : new Config("config", "channel");
c : new FileManager();
d : channels folder
e : CommandSender
f : Command
g : args
h : new Config("messages", "global");
i : Main
j : File Separator

methods :
a : list
b : create
c : leave
d : join
e : permission message
f : invite
g : disband
h : kick
i : promote
j : demote
*/
}

+ 80
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Chat.java View File

@@ -0,0 +1,80 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import net.DeltaWings.Minecraft.ChatManager.Custom.FileManager;
import net.DeltaWings.Minecraft.ChatManager.Main;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.io.File;


public class Chat implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player){
Player p = (Player)sender;
if(cmd.getName().equalsIgnoreCase("chat")){
Config messages = new Config("messages", "channel");
Config gmsg = new Config("messages", "global");
Config gconfig = new Config("config", "channel");
if(p.hasPermission("chat-manager.channel.chat")){
if(args.length >= 2){
Config config = new Config("channels", args[0]);
if( FileManager.listFiles(Main.getInstance().getDataFolder() + File.separator + "channels").contains(args[0]+".yml")){
StringBuilder message = new StringBuilder();
for (int i = 1; i < args.length; i++) {
message.append(args[i]).append(" ");
}
if(config.getStringList("admins").contains(p.getName())){
String msg = gconfig.getString("chat.format").replace("[channel]", args[0]).replace("[player]", gconfig.getString("colors.admin-name")+p.getName()).replace("[message]", gconfig.getString("colors.default")+message);
//loop players qui font parti du channel
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(config.getStringList("admins").contains(p.getName()) || config.getStringList("users").contains(p.getName())){
player.sendMessage(msg.replace("&", "§"));
}
}
}else if(config.getStringList("users").contains(p.getName())){
String msg = gconfig.getString("chat.format").replace("[channel]", args[0]).replace("[player]", gconfig.getString("colors.user-name")+p.getName()).replace("[message]", gconfig.getString("colors.default")+message);
//loop players qui font parti du channel
for(Player player : Bukkit.getServer().getOnlinePlayers()) {
if(config.getStringList("admins").contains(p.getName()) || config.getStringList("users").contains(p.getName())){
player.sendMessage(msg.replace("&", "§"));
}
}
}else{
//message tu ne peux pas envoyer de message dans un groupe dont tu ne fais pas parti
p.sendMessage(messages.getString("cant-message").replace("&", "§"));
}
}else{
//message le channel que tu cherche n'existe pas
p.sendMessage(messages.getString("dont-exist").replace("&","§"));
}
}else{
p.sendMessage(gmsg.getString("badly-written").replace("&","§"));
}
}else{
//message permission
p.sendMessage(gmsg.getString("permission").replace("&", "§"));
}
}
}
return true;
}
}
// /c <channel> <message>
/*message :
*[channel] [player] [message]
*[message] contain base color set by config file with different by player eg :
* admin = &c
* user = &b
*[channel] is set by each channel
*[player] is the player's name with a color like
*"&f[&cadmin&f]"
*"&f[&buser&f]"
*/

+ 31
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/ChatManager.java View File

@@ -0,0 +1,31 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import net.DeltaWings.Minecraft.ChatManager.Main;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class ChatManager implements CommandExecutor {

@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
Main p = Main.getInstance();
if (s instanceof Player) {
if (s.hasPermission("chat-manager.admin.reload")) {
p.getServer().getPluginManager().disablePlugin(p);
p.getServer().getPluginManager().enablePlugin(p);
s.sendMessage("§8[§cChat§8-§cManager§8] §fPlugin reloaded !");
Main.log("Plugin reloaded !");
} else {
s.sendMessage(new Config("messages", "global").getString("permission").replace("&", "§"));
}
} else {
p.getServer().getPluginManager().disablePlugin(p);
p.getServer().getPluginManager().enablePlugin(p);
Main.log("Plugin reloaded !");
}
return true;
}
}

+ 18
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Clearchat.java View File

@@ -0,0 +1,18 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class Clearchat implements CommandExecutor {

@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] a) {
if(a.length == 0) if ( s instanceof Player && s.hasPermission("chat-manager.clear-chat.global") || s instanceof ConsoleCommandSender) API.clearchat(s.getName(), null);
else if(a.length == 1) if( s instanceof Player && s.hasPermission("chat-manager.clear-chat.player") || s instanceof ConsoleCommandSender) API.clearchat(s.getName(), a[0]);
return true;
}
}

+ 20
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/LockChat.java View File

@@ -0,0 +1,20 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Api.API;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class LockChat implements CommandExecutor {

public boolean onCommand(CommandSender s, Command c, String t, String[] a) {
if (s instanceof Player && s.hasPermission("chat-manager.lockchat.lock") || s instanceof ConsoleCommandSender) API.lockchat();
else s.sendMessage("perms usage"); //permission message
return true;
}


}

+ 41
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Mute.java View File

@@ -0,0 +1,41 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;

import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class Mute implements CommandExecutor {
@Override
public boolean onCommand(CommandSender s, Command c, String jk, String[] a) {
if(s instanceof Player && s.hasPermission("chat-manager.mute.chat") || s instanceof ConsoleCommandSender) {
Player l = null;
Boolean f = false;
for(Player p : Bukkit.getServer().getOnlinePlayers()) {
if(a.length > 0)if(p.getName().equalsIgnoreCase(a[0])) {
l = p;
f = true;
}
}
if(!f) s.sendMessage(new Config("messages", "mute").getString("player.not-found").replace("&", "§"));
else if(a.length >= 3) {
StringBuilder m = new StringBuilder();
for ( Integer y = 2; a.length > y; y++ ) m.append(a[y]).append(" ");
API.mute(s, l, Integer.parseInt(a[1]), "chat", m.toString());
}
else if(a.length == 2) API.mute(s, l, Integer.parseInt(a[1]), "chat", new Config("config", "mute").getString("default-reason"));
else if(a.length == 1) API.mute(s, l, -1, "chat", new Config("config", "mute").getString("default-reason"));
else s.sendMessage(new Config("messages", "global").getString("badly-written").replace("&", "§"));

} else {
s.sendMessage("perm usage");
}
return false;
}
}
// /mute Aviortheking [time] [reason]

+ 27
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Mutelist.java View File

@@ -0,0 +1,27 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

import java.util.List;

public class Mutelist implements CommandExecutor {
@Override
public boolean onCommand(CommandSender s, Command command, String label, String[] args) {
if(s instanceof Player && s.hasPermission("chat-manager.mute.list") || s instanceof ConsoleCommandSender) {
List<String[]> l = API.mutedlist();
Config m = new Config("messages", "mute");
s.sendMessage(m.getString("mutelist.top").replace("&", "§"));
for(String[] a : l) {
s.sendMessage(m.getString("mutelist.object").replace("[player]", a[0]).replace("[time]", a[1]).replace("[reason]", a[2]).replace("&", "§"));
}
s.sendMessage(m.getString("mutelist.bottom").replace("&", "§"));
}
return false;
}
}

+ 48
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/StaffChat.java View File

@@ -0,0 +1,48 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import net.DeltaWings.Minecraft.ChatManager.Main;

public class StaffChat implements CommandExecutor {

private final Main m = Main.getInstance();

@Override
public boolean onCommand(CommandSender s, Command c, String l, String[] a) {
if(c.getName().equalsIgnoreCase("staffchat")) {
if(s instanceof Player) {
if(s.hasPermission("chat-manager.staff-chat.send")) sendMessage(a, s.getName());
else s.sendMessage(new Config("messages", "global").getString("permission").replace("&", "§"));
} else sendMessage(a, "Console");
}
return true;
}

private void sendMessage(String[] a, String s) {
StringBuilder z = new StringBuilder();
for (String r : a) {
z.append(r).append(" ");
}
for(Player p : Bukkit.getServer().getOnlinePlayers()) {
if(p.hasPermission("chat-manager.staff-chat.read")){
m.makeDefaultPlayerFile(p);
if(new Config("players", p.getName()).getBoolean("switch")){
Config g = new Config("config", "staffchat");
p.sendMessage(g.getString("chat.format").replace("[player]", g.getString("colors.player")+s).replace("[message]", g.getString("colors.default")+z).replace("&", "§"));
}
}
}
}
}

/*
* Permissions :
* Staff chat read : chat-manager.staff-chat.read
* Staff chat send : chat-manager.staff-chat.send
*/

+ 50
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/StaffSwitch.java View File

@@ -0,0 +1,50 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Custom.Config;

import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class StaffSwitch implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
if(sender instanceof Player){
Player p = (Player)sender;
if(cmd.getName().equalsIgnoreCase("staffswitch")){
Config gmessage = new Config("messages", "global");
Config smessage = new Config("messages", "switch");
if(p.hasPermission("chat-manager.staff-chat.switch")){
Config player = new Config("players", p.getName());
if(player.exist()){
if(player.getBoolean("switch")){
player.set("switch", false);
player.save();
p.sendMessage(smessage.getString("switch").replace("[state]", "False").replace("&", "§"));
}else{
player.set("switch", true);
player.save();
p.sendMessage(smessage.getString("switch").replace("[state]", "True").replace("&", "§"));
}
}else{
//basic
player.create();
player.set("invite");
//end basic
player.set("switch", false);
player.save();
p.sendMessage(smessage.getString("switch").replace("[state]", "False").replace("&", "§"));
}
}else{
p.sendMessage(gmessage.getString("permission").replace("&", "§"));
}
}
}
return true;
}

}

// /staffswitch

+ 32
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Commands/Unmute.java View File

@@ -0,0 +1,32 @@
package net.DeltaWings.Minecraft.ChatManager.Commands;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;

import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;

public class Unmute implements CommandExecutor {
@Override
public boolean onCommand(CommandSender s, Command command, String label, String[] a) {
if(s instanceof Player && s.hasPermission("chat-manager.unmute.chat") || s instanceof ConsoleCommandSender) {
Player l = null;
Boolean f = false;
for(Player p : Bukkit.getServer().getOnlinePlayers()) {
if(a.length > 0)if(p.getName().equalsIgnoreCase(a[0])) {
l = p;
f = true;
}
}
if(!f) s.sendMessage(new Config("messages", "mute").getString("player.not-found").replace("&", "§"));
else API.unmute(s, l, "chat");
}
return false;
}
}

//unmute <player>

+ 118
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/Config.java View File

@@ -0,0 +1,118 @@
package net.DeltaWings.Minecraft.ChatManager.Custom;

import net.DeltaWings.Minecraft.ChatManager.Main;

import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Config {
private final FileConfiguration config;
private final File root = Main.getInstance().getDataFolder();
private final File folder;
private final File file;
private final FileManager fm = new FileManager();

public Config(String folder, String file) {
this.folder = new File(folder);
this.file = new File(root.toString() + File.separator + this.folder.toString() + File.separator + file + ".yml");
config = YamlConfiguration.loadConfiguration(this.file);
}

public Boolean exist() {
return file.exists();
}

public void set(String path, Object value) {
config.set(path, value);
}

public void set(String path) {
config.createSection(path);
}

public void header(String header) {
config.options().header(header);
}

public int getInt(String path, Integer def) {
return config.getInt(path, def);
}

public int getInt(String path) {
return config.getInt(path);
}

public Double getDouble(String path, Double def) {
return config.getDouble(path, def);
}

public Double getDouble(String path) {
return config.getDouble(path);
}

public String getString(String path, String def) {
return config.getString(path, def);
}

public String getString(String path) {
return config.getString(path);
}

public Long getLong(String path) {
return config.getLong(path);
}

public Long getLong(String path, Long def) {
return config.getLong(path, def);
}

public void save() {
try {
config.save(file);
} catch ( IOException e ) {
e.printStackTrace();
}
}

public ArrayList<String> getSection(String path) {
return new ArrayList<>(config.getConfigurationSection(path).getKeys(false));
}

public List<String> getStringList(String path) {
return config.getStringList(path);
}

public void create() {
if(!exist()) {
if(!root.exists()) root.mkdirs();
File rfolder = new File(root.toString() + File.separator + folder.toString());
if(!rfolder.exists()) rfolder.mkdirs();
try {
file.createNewFile();
} catch ( IOException e ) {
e.printStackTrace();
}
}
}

public boolean isSet(String path) {
return config.isSet(path);
}

public boolean getBoolean(String path, Boolean def) {
return config.getBoolean(path, def);
}

public boolean getBoolean(String path) {
return config.getBoolean(path);
}

public void delete() {
FileManager.delete(file);
}
}

+ 15
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/Custom.java View File

@@ -0,0 +1,15 @@
package net.DeltaWings.Minecraft.ChatManager.Custom;

public class Custom {
public static boolean isInteger(String s) {
if (s.isEmpty()) return false;
for (int i = 0; i < s.length(); i++) {
if (i == 0 && s.charAt(i) == '-') {
if (s.length() == 1) return false;
else continue;
}
if (Character.digit(s.charAt(i), 10) < 0) return false;
}
return true;
}
}

+ 89
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/FileManager.java View File

@@ -0,0 +1,89 @@
package net.DeltaWings.Minecraft.ChatManager.Custom;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;

public class FileManager {


public static List<String> listFiles(String path) {
String[] t = new File(path).list();
if(t == null) return new ArrayList<>();
else return Arrays.asList(t);
}

public static List<String> listFiles(File path) {
String[] t = path.list();
if(t == null) return new ArrayList<>();
else return Arrays.asList(t);
}

public static void delete(File path) {
path.delete();
}

public static void delete(String path) {
File f = new File(path);
f.delete();
}

public static void createFile(String path) {
try {
new File(path).createNewFile();
} catch ( IOException e ) {
e.printStackTrace();
}
}

public static void createFile(File path) {
try {
path.createNewFile();
} catch ( IOException e ) {
e.printStackTrace();
}
}

public static void createFolder(File path) {
path.mkdirs();
}

public static void createFolder(String path) {
new File(path).mkdirs();
}

public static void archive(String srcFolder, String destZipFile) {
try {
FileOutputStream f = new FileOutputStream(destZipFile);
ZipOutputStream z = new ZipOutputStream(f);
b(srcFolder, z);
z.close();
} catch ( Exception e ) {
e.printStackTrace();
}
}

private static void a(String p, String s, ZipOutputStream z) throws Exception {
File f = new File(s);
if (f.isDirectory()) b(s, z);
else {
byte[] b = new byte[1024];
int l;
FileInputStream i = new FileInputStream(s);
z.putNextEntry(new ZipEntry(p + "/" + f.getName()));
while ((l = i.read(b)) > 0) z.write(b, 0, l);
}
}

private static void b(String s, ZipOutputStream z) throws Exception {
File f = new File(s);
String[] l = f.list();
if(l != null) for (String n : l) a(f.getName(), s + File.separator + n, z);
}
}

+ 42
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Custom/Notifier.java View File

@@ -0,0 +1,42 @@
package net.DeltaWings.Minecraft.ChatManager.Custom;

import net.DeltaWings.Minecraft.ChatManager.Main;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class Notifier {

public Notifier(Integer r, String b) {
Bukkit.getScheduler().scheduleSyncDelayedTask( Main.getInstance(), () -> {
try {
HttpURLConnection c = (HttpURLConnection) new URL("http://www.spigotmc.org/api/general.php").openConnection();
c.setDoOutput(true);
c.setRequestMethod("POST");
try (OutputStream o = c.getOutputStream()) {
o.write(("key=98BE0FE67F88AB82B4C197FAF1DC3B69206EFDCC4D3B80FC83A00037510B99B4&resource=" + r).getBytes("UTF-8"));
}
String v;
try (BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(c.getInputStream()))) {
v = bufferedReader.readLine();
}
if (v.equalsIgnoreCase(b)) Main.log("No new Version version available ! Thanks for using our plugin.");
else {
Main.log("New version available ! Version : " + v);
for (Player p : Bukkit.getServer().getOnlinePlayers()) if (p.hasPermission("chat-manager.admin.notification")) p.sendMessage("§8[§cChat§8-§cManager§8]§f New version available ! Version : " + v);
}
} catch (Exception e) {
Main.log(e.getMessage());
Main.log("");
Main.log("Please contact the developper and give him the code before.");
for(Player p : Bukkit.getServer().getOnlinePlayers()) if(p.hasPermission("chat-manager.admin.notification")) p.sendMessage("§8[§cChat§8-§cManager§8]§f Error while trying to check for updates ! Please look at the console for more informations.");
}
}, 0L);
}
}

+ 159
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Listeners/ChatListener.java View File

@@ -0,0 +1,159 @@
package net.DeltaWings.Minecraft.ChatManager.Listeners;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;
import net.DeltaWings.Minecraft.ChatManager.Custom.Custom;
import net.DeltaWings.Minecraft.ChatManager.Main;

import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.AsyncPlayerChatEvent;

import java.util.ArrayList;

public class ChatListener implements Listener {

private Integer d = 0, e = 0, r = 0, g = -1;
private Config gconfig = new Config("config", "global");


@EventHandler(priority = EventPriority.HIGH)
public void AsyncPlayerChat(AsyncPlayerChatEvent e){
e.setCancelled(true);
Config p = new Config("players", e.getPlayer().getName());
//Calculator
if(e.getMessage().split("")[0].equalsIgnoreCase("=")) calculator(e);
//Muted Player
else if(p.getBoolean("mute.chat", false)) {
if(p.getInt("mute.from") == -1 || p.getLong("mute.time") > System.currentTimeMillis()) {
e.getPlayer().sendMessage(new Config("messages", "mute").getString("muted.self").replace("[reason]", p.getString("mute.reason")).replace("&", "§"));
}
else {
p.set("mute.chat", false);
p.save();
}
}
//Locked chat
if(API.isChatLocked() && !p.getBoolean("mute.chat", false) && !(e.getMessage().split("")[0].equalsIgnoreCase("="))) {
Config lockchat = new Config("messages", "lockchat");
if(e.getPlayer().hasPermission("chat-manager.lockchat.ignore")) {
e.getPlayer().sendMessage(lockchat.getString("ignored").replace("&", "§"));
sendMessage(e.getPlayer(), e.getMessage());
} else e.getPlayer().sendMessage(lockchat.getString("locked").replace("&", "§"));
//Send Message
} else if(!p.getBoolean("mute.chat", false) && !(e.getMessage().split("")[0].equalsIgnoreCase("="))) sendMessage(e.getPlayer(), e.getMessage());
}
/*
Calculator
*/
private void calculator(AsyncPlayerChatEvent g) {
String a = g.getMessage();
StringBuilder f = new StringBuilder();
for ( String b : a.split(" ") ) {
Integer l = -1;
for ( String q : b.split("") ) {
if ( Custom.isInteger(q) ) {
if ( l == -1 || l == 1 ) l = 1;
else {
l = 1;
f.append(" ");
}
} else {
if ( l == -1 || l == 0 ) l = 0;
else {
l = 0;
f.append(" ");
}
}
f.append(q);
}
f.append(" ");
}
String[] c = f.toString().split(" ");
if ( c[0].equalsIgnoreCase("=") ) start(c, g.getPlayer());
}

private void start(String[] b, Player p) {
r = 0;
if (b[0].equalsIgnoreCase("=")) {
for (String c : b) {
if (c.equalsIgnoreCase("+")) g = 0;
else if (c.equalsIgnoreCase("-")) g = 1;
else if (c.equalsIgnoreCase("*") || c.equalsIgnoreCase("x")) g = 2;
else if (c.equalsIgnoreCase("/")) g = 3;
if (Custom.isInteger(c)) {
if (g != -1) {
e = Integer.parseInt(c);
calc(g);
g = -1;
} else d = Integer.parseInt(c);
}
}
p.sendMessage("[Result] "+ r);
}
}

private void calc(Integer g) {
if (g == 0) r += d + e;
else if (g == 1) r += d - e;
else if (g == 2) {
if(d != 0) r += d * e;
else r*= e;
}
else if (g == 3) {
if(d != 0) r += d / e;
else r /= e;
}
d = 0;
e = 0;
}
/*
End Calculator
*/

private void sendMessage(Player p, String msg) {
Config config = new Config("config", "prefix");
ArrayList<String> plist = config.getSection("prefix");
String prefix = "";

if(!plist.isEmpty()) for ( String a : plist ) if ( p.hasPermission("chat-manager.chat.prefix." + a) ) prefix = config.getString("prefix." + a);

ArrayList<String> slist = config.getSection("suffix");
String suffix = "";

if(!slist.isEmpty()) for ( String a : slist ) if ( p.hasPermission("chat-manager.chat.suffix." + a) ) suffix = config.getString("suffix." + a);

ArrayList<String> nlist = config.getSection("name-color");
String namecolor = "&f";
if(!nlist.isEmpty()) for ( String a : nlist ) if ( p.hasPermission("chat-manager.chat.color." + a) ) namecolor = config.getString("name-color." + a);

if(!nlist.isEmpty()) for ( String a : nlist ) if ( p.hasPermission("chat-manager.chat.name-color." + a) ) namecolor = config.getString("name-color." + a);

if(!p.hasPermission("chat-manager.chat.colors")) msg = msg.replaceAll("&([0-9a-f])", "");

msg = "&f" + msg + "&f";
String res = gconfig.getString("format.chat");
res = res.replace("[prefix]", prefix).replace("[player]", namecolor+p.getName()).replace("[suffix]", suffix);
Main.log(res.replace("[message]", msg));
API.logMessage(res.replace("[message]", msg));
for(Player pl : Bukkit.getServer().getOnlinePlayers()) {
String temp;
if(gconfig.getBoolean("name.enabled") && msg.contains(pl.getName())) temp = res.replace("[message]", msg.replace(pl.getName(), (gconfig.getString("name.color") + pl.getName() + "&f")));
else temp = res.replace("[message]", msg);
pl.sendMessage(temp.replace("&", "§"));
}
}
}

/*
permissions :
colors in chat : chat-manager.chat.colors
name in certain color : chat-manager.chat.name-color.NAME
prefix : chat-manager.chat.prefix.NAME
suffix : chat-manager.chat.suffix.NAME
lockchat ignore : chat-manager.lock-chat.ignore
*/

+ 31
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Listeners/DeathListener.java View File

@@ -0,0 +1,31 @@
package net.DeltaWings.Minecraft.ChatManager.Listeners;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;

import java.util.HashMap;

import org.bukkit.entity.Entity;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;

public class DeathListener implements Listener {

@EventHandler
public void onPlayerDeath(PlayerDeathEvent e) {
if(new Config("config", "events").getBoolean("enabled.death", true)) {
Config msg = new Config("messages", "events");

e.getEntity().getLastDamageCause();
DamageCause cause = e.getEntity().getLastDamageCause().getCause();
Entity killer = e.getEntity().getKiller();
HashMap<String, String> replacements = new HashMap<>();
replacements.put("[player]", e.getEntity().getName());
if(killer != null) replacements.put("[killer]", killer.getName());
replacements.put("[item]", e.getEntity().getDisplayName().replace("&", "§"));
e.setDeathMessage(API.multiReplace(msg.getString("death.causes."+cause.toString().toLowerCase()), replacements));
}
}
}

+ 28
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Listeners/PlayerLoginLogoutListener.java View File

@@ -0,0 +1,28 @@
package net.DeltaWings.Minecraft.ChatManager.Listeners;

import net.DeltaWings.Minecraft.ChatManager.Api.API;
import net.DeltaWings.Minecraft.ChatManager.Custom.Config;

import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;

public class PlayerLoginLogoutListener implements Listener {

@EventHandler
public void onPlayerJoin(PlayerJoinEvent e) {
Config joinleave = new Config("config", "events");
if(joinleave.getBoolean("enabled.join", true)) e.setJoinMessage(new Config("messages", "events").getString("join").replace("[player]", e.getPlayer().getName()).replace("&", "§"));
else e.setJoinMessage(null);
if(joinleave.getBoolean("enabled.motd", false)) for(String line : new Config("messages", "joinleave").getStringList("motd")) e.getPlayer().sendMessage(line.replace("&", "§"));
if (API.isChatLocked()) e.getPlayer().sendMessage(new Config("messages", "lockchat").getString("locked").replace("&", "§"));
}

@EventHandler
public void onPlayerLeave(PlayerQuitEvent e) {
if(new Config("config", "events").getBoolean("enabled.leave", true)) e.setQuitMessage(new Config("messages", "events").getString("leave").replace("[player]", e.getPlayer().getName()).replace("&", "§"));
else e.setQuitMessage(null);
}

}

+ 352
- 0
src/main/java/net/DeltaWings/Minecraft/ChatManager/Main.java View File

@@ -0,0 +1,352 @@
package net.DeltaWings.Minecraft.ChatManager;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import net.DeltaWings.Minecraft.ChatManager.Commands.*;
import net.DeltaWings.Minecraft.ChatManager.Custom.*;
import net.DeltaWings.Minecraft.ChatManager.Listeners.*;
import net.DeltaWings.Minecraft.ChatManager.Scheduler.Scheduler;

import org.bukkit.entity.Player;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;


public class Main extends JavaPlugin {

private static Main instance;
private PluginDescriptionFile desc;

public static void log(String message) {
Main.getInstance().getLogger().info(message);
}

public static void debug(String message) {
if(new Config("config", "global").getBoolean("debug", false))Main.getInstance().getLogger().info("[Debug] " + message);
}

public static void error(String message) {
Main.getInstance().getLogger().severe(message);
}


public static Main getInstance() {
return instance;
}

@Override
public void onEnable() {
desc = getDescription();
instance = this;
PluginManager pm = getServer().getPluginManager();
//Commands
getCommand("StaffChat").setExecutor(new StaffChat());
getCommand("StaffSwitch").setExecutor(new StaffSwitch());
getCommand("Channel").setExecutor(new Channel());
getCommand("Chat").setExecutor(new Chat());
getCommand("Broadcast").setExecutor(new Broadcast());
getCommand("Clearchat").setExecutor(new Clearchat());
getCommand("Chat-Manager").setExecutor(new ChatManager());
getCommand("LockChat").setExecutor(new LockChat());
getCommand("Mute").setExecutor(new Mute());
getCommand("Unmute").setExecutor(new Unmute());
getCommand("Mutelist").setExecutor(new Mutelist());

//Listeners
pm.registerEvents(new PlayerLoginLogoutListener(), this);
pm.registerEvents(new ChatListener(), this);
pm.registerEvents(new DeathListener(), this);

//make config files
genconfig();

//Start Schedulers
new Scheduler();

//new Notifier(25929, desc.getVersion());
//Metrics
Metrics metrics = new Metrics(this);
metrics.addCustomChart(new Metrics.SimplePie("auto_broadcast") {
@Override
public String getValue() {
return ""+new Config("config", "broadcast").getBoolean("auto-broadcast.enabled", false);
}
});

metrics.addCustomChart(new Metrics.SimplePie("auto_clearchat") {
@Override
public String getValue() {
return ""+new Config("config", "clearchat").getBoolean("auto-clear-chat.enabled", false);
}
});

metrics.addCustomChart(new Metrics.SingleLineChart("muted_players") {
@Override
public int getValue() {
Integer r = 0;
try {
List<String> files = FileManager.listFiles(new File(getDataFolder() + File.separator + "players"));
for(String file : files) {
if(new Config("players", file.replace(".yml", "")).getBoolean("mute.chat")) r++;
}
} catch ( Exception e ) {
e.printStackTrace();
}

return r;
}
});
metrics.addCustomChart(new Metrics.SimplePie("name_customization") {
@Override
public String getValue() {
return new Config("config", "global").getBoolean("name.enabled", false) + "";
}
});

log("Successfully enabled");
}

private void genconfig() {
Config c;
c = new Config("config", "global");
Boolean ver = !c.getString("version", "0.0.0").equalsIgnoreCase(desc.getVersion());
if(ver) {
log("Because it's a new update we will now archive all your configuration and generate a new one.");
log("Before repasting into the new files check the changelogs to see what files have changed !");
FileManager.archive(Main.getInstance().getDataFolder().toString(), Main.getInstance().getDataFolder().toString() + File.separator + "Backup-" + c.getString("version", "unknown") + ".zip");
}

if(!c.exist() || ver) {
c.delete();
c.create();
c.header("Please don't touch the version or you will break some functions");
c.set("debug", false);
c.set("format.chat", "[prefix] [player] [suffix] > [message]");
c.set("name.enabled", true);
c.set("name.color", "&9&o");
c.set("version", desc.getVersion());
c.save();
}
c = new Config("config", "prefix");
if(!c.exist() || ver) {
c.delete();
c.create();
c.header("More infos on https://gitlab.com/Delta-Wings/Chat-Manager/snippets/1574373");
c.set("prefix");
c.set("suffix");
c.set("name-color");
c.save();
}

c = new Config("messages", "lockchat");
if(!c.exist() || ver) {
c.delete();
c.create();
c.header("[state] stand for chat state (locked for locked chat, unlocked for unlocked chat)");
c.set("locked", "&8 >&c The chat is locked !");
c.set("unlocked", "&8 >&c The chat has been unlocked !");
c.set("ignored", "&8 >&c The chat is locked but you can speak !");
c.set("already", "&8 >&c Chat is already [state] !");
c.save();
}

c = new Config("messages", "channel");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("dont-exist", "&8 >&c The channel don't exist");
c.set("list-start", "&8 >&f Channels list(&bBlue&f = user &cRed&f = Admin");
c.set("list-end", "&8 >&c End");
c.set("already-exist", "&8 >&c There is already a channel named \"[channel]\"");
c.set("channel-created", "&8 >&c The channel has been created !");
c.set("one-word-channel", "&8 >&c Your channel name must be one word");
c.set("no-chanel-name", "&8 >&c You need to tell the channel name !");
c.set("deleted-from-channel", "&8 >&c You have been deleted from the channel");
c.set("last-admin-delete", "&8 >&c Because you were the last admin. The channel has been deleted too");
c.set("channel-joined", "&8 >&c You have successfully joined the channel !");
c.set("cant-join", "&8 >&c You can't join this channel");
c.set("already-in", "&8 >&c You are already in this channel");
c.set("no-channel-name", "&8 >&c There is no channels with this name");
c.set("you-invited", "&8 >&c You have successfully invited [player]");
c.set("channel-disbanded", "&8 >&c You have successfully disbanded the channel");
c.set("cant-disband", "&8 >&c You can't disband this channel because you are not an admin of this channel");
c.set("cant-kick-admin", "&8 >&c You can't kick an other admin");
c.set("kicked", "&8 >&c [player] has been kicked from the channel");
c.set("not-in-your-channel", "&8 >&c [player] is not on your channel");
c.set("cant-do-if-not-admin", "&8 >&c You can't do that's if you aren't a channel admin");
c.set("promoted", "&8 >&c [player] have been promoted");
c.set("player-is-not-channel", "&8 >&c [player] is not in the channel");
c.set("cant-promoted", "&8 >&c You can only promote if you are an admin of a channel");
c.set("demoted", "&8 >&c [player] have been demoted");
c.set("is-not-user", "&8 >&c the player is not an admin of this channel");
c.set("cant-message", "&8 >&c You can't send messages in this channel");
c.set("not-in-channel", "&8 > &c You aren't in this channel");
c.set("invited", "&8 >&c You have been invited in the channel : [channel]");
c.set("one-word-channel", "&8 >&c You have misspelled the channel name !");
c.set("console-cant", "The Console can't do this command !");
c.set("not-a-user", "&8 >&c You aren't a user of this channel");
c.save();
}

c = new Config("config", "channel");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("colors.admin-name", "&c");
c.set("colors.user-name", "&b");
c.set("colors.default", "&f");
c.set("chat.format", "[channel] [player] [message]");
c.save();
}

c = new Config("messages", "global");
if(!c.exist()) {
c.create();
c.set("permission", "&8 >&c You don't have the permission to do that !");
c.set("badly-written", "&8 >&c You have badly written somethings");
c.set("not-online", "&8 > &c The player isn't online");
c.save();
}

c = new Config("messages", "switch");
if(!c.exist() || ver) {
c.create();
c.set("switch", "&8 >&c You have changed your receive setting to \"[state]\"");
c.save();
}

Config sconf = new Config("messages", "staffchat");
if(!sconf.exist() || ver) {
sconf.create();
sconf.set("no-message", "&8 >&c You have to put a message after the command");
sconf.save();
}

c = new Config("config", "staffchat");
if(!c.exist() || ver) {
c.create();
c.set("colors.player", "&c");
c.set("colors.default", "&f");
c.set("chat.format", "&8[&cStaffchat&8] [player] [message]");
c.save();
}

c = new Config("config", "lockchat");
if(!c.exist() || ver) {
c.create();
c.set("locked", "The chat is now locked");
c.set("unlocked", "The chat is now unlocked");
c.save();
}

c = new Config("config", "clearchat");
if(!c.exist() || ver) {
c.delete();
c.create();
c.header("Time in minutes");
c.set("lines-to-clear", 200);
c.set("auto-clear-chat.enabled", true);
c.set("auto-clear-chat.time", 30);
c.save();
}

c = new Config("messages", "clearchat");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("clear", "&8 >&c Your chat has been cleared by [cleaner]");
c.save();
}

c = new Config("config", "broadcast");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("format", "<Broadcast> [player]&8 > &c[message]");
c.set("auto-broadcast.enabled", true);
List<String> t = new ArrayList<>();
t.add("&cWelcome new players !");
c.set("auto-broadcast.messages", t);
c.set("auto-broadcast.time", 10);
c.save();
}

c = new Config("config", "mute");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("enabled", true);
c.set("default-reason", "You did something bad !");
c.save();
}

c = new Config("messages", "mute");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("muted.self", "You are muted ! Reason : [reason]");
c.set("muted.other", "&8 >&c You have muted [player] with the reason [reason]");
c.set("unmutted.self", "&8 >&c You have been unmutted");
c.set("unmutted.other", "&8 >&c You have unmutted [player]");
c.set("already-muted", "&8 >&c The player is already muted");
c.set("player.not-found", "&8 >&c The player has not been found !");
c.set("mutelist.top", "&8 >&c Mutelist&8 <");
c.set("mutelist.object", "&c[player] &b[time] &areason : [reason]");
c.set("mutelist.bottom", "&8 >&c Mutelist&8 <");
c.save();
}

c = new Config("config", "events");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("enabled.join", true);
c.set("enabled.death", true);
c.set("enabled.motd", true);
c.set("enabled.leave", true);
c.save();
}
c = new Config("messages", "events");
if(!c.exist() || ver) {
c.delete();
c.create();
c.set("join", "&bWelcome [player] !");
c.set("leave", "&cGoodbye [player] ! I'll miss you !");
c.set("death.player", "&9[player] was killed from [killer] using [item]");
c.set("death.mob", "&9