Initial commit
This commit is contained in:
commit
bd2c7bc4c3
8 changed files with 165 additions and 0 deletions
1
src/config.yml
Normal file
1
src/config.yml
Normal file
|
@ -0,0 +1 @@
|
|||
language: en
|
22
src/fr/flifloo/StaffToggle/Commands/Help.java
Normal file
22
src/fr/flifloo/StaffToggle/Commands/Help.java
Normal file
|
@ -0,0 +1,22 @@
|
|||
package fr.flifloo.StaffToggle.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.flifloo.StaffToggle.Main;
|
||||
|
||||
public class Help implements CommandExecutor {
|
||||
Main plugin;
|
||||
|
||||
public Help(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender player, Command cmd, String label, String[] args) {
|
||||
player.sendMessage(ChatColor.AQUA + "StaffToogle help !");
|
||||
return true;
|
||||
}
|
||||
}
|
37
src/fr/flifloo/StaffToggle/Commands/Staff.java
Normal file
37
src/fr/flifloo/StaffToggle/Commands/Staff.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package fr.flifloo.StaffToggle.Commands;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import fr.flifloo.StaffToggle.Main;
|
||||
|
||||
public class Staff implements CommandExecutor {
|
||||
Main plugin;
|
||||
|
||||
public Staff(Main plugin) {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender player, Command cmd, String label, String[] args) {
|
||||
if (!(player instanceof Player)) {
|
||||
player.sendMessage(ChatColor.RED + "Command only for players !");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {
|
||||
String message = plugin.language.config.getString("staff.help");
|
||||
player.sendMessage(ChatColor.translateAlternateColorCodes('&', message));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("modo")) {
|
||||
player.sendMessage(ChatColor.GOLD + "Switch modo !");
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("admin")) {
|
||||
player.sendMessage(ChatColor.GOLD + "Switch admin !");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
42
src/fr/flifloo/StaffToggle/Configuration/Language.java
Normal file
42
src/fr/flifloo/StaffToggle/Configuration/Language.java
Normal file
|
@ -0,0 +1,42 @@
|
|||
package fr.flifloo.StaffToggle.Configuration;
|
||||
|
||||
import fr.flifloo.StaffToggle.Main;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
|
||||
public class Language{
|
||||
public FileConfiguration config;
|
||||
|
||||
public Language (Main main) {
|
||||
String configLanguage = main.getConfig().getString("language");
|
||||
InputStream resourceLanguage = main.getResource("languages/" + configLanguage + ".yml");
|
||||
File configFile = new File(main.getDataFolder(), "language.yml");
|
||||
|
||||
if (!configFile.exists()) {
|
||||
configFile.getParentFile().mkdirs();
|
||||
try {
|
||||
Files.copy(resourceLanguage, configFile.toPath());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
config = new YamlConfiguration();
|
||||
try {
|
||||
config.load(configFile);
|
||||
if (!configLanguage.equalsIgnoreCase(config.getString("language"))) {
|
||||
Files.copy(resourceLanguage, configFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
||||
config.load(configFile);
|
||||
}
|
||||
} catch (IOException | InvalidConfigurationException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
29
src/fr/flifloo/StaffToggle/Main.java
Normal file
29
src/fr/flifloo/StaffToggle/Main.java
Normal file
|
@ -0,0 +1,29 @@
|
|||
package fr.flifloo.StaffToggle;
|
||||
|
||||
import fr.flifloo.StaffToggle.Commands.*;
|
||||
import fr.flifloo.StaffToggle.Configuration.*;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class Main extends JavaPlugin {
|
||||
public Language language;
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
saveDefaultConfig();
|
||||
getConfig().getString("language");
|
||||
language = new Language(this);
|
||||
registerCommands();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
|
||||
}
|
||||
|
||||
public void registerCommands() {
|
||||
getCommand("staff").setExecutor(new Staff(this));
|
||||
}
|
||||
}
|
6
src/languages/en.yml
Normal file
6
src/languages/en.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
language: en
|
||||
staff:
|
||||
help: "&3=========={Staff help}==========\n
|
||||
&e/staff modo&9: Toggle moderation\n
|
||||
&e/staff admin&9: Toggle administration\n
|
||||
&3=============================="
|
6
src/languages/fr.yml
Normal file
6
src/languages/fr.yml
Normal file
|
@ -0,0 +1,6 @@
|
|||
language: fr
|
||||
staff:
|
||||
help: "&3=========={Staff help}==========\n
|
||||
&e/staff modo&9: Active la moderation\n
|
||||
&e/staff admin&9: Active l'administration\n
|
||||
&3=============================="
|
22
src/plugin.yml
Normal file
22
src/plugin.yml
Normal file
|
@ -0,0 +1,22 @@
|
|||
main: fr.flifloo.StaffToggle.Main
|
||||
name: StaffToggle
|
||||
version: 1.0.0
|
||||
description: Toggle staff mod
|
||||
api-version: "1.14"
|
||||
author: flifloo
|
||||
depend:
|
||||
- LuckPerms
|
||||
|
||||
commands:
|
||||
staff:
|
||||
permission: staff.help
|
||||
permission-message: You don't have the permission to use this command !
|
||||
aliases: staff help
|
||||
|
||||
permissions:
|
||||
staff.help:
|
||||
description: Show help
|
||||
staff.modo:
|
||||
description: Toogle modo
|
||||
staff.admin:
|
||||
description: Toogle admin
|
Loading…
Reference in a new issue