package main;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
public class WecosChatCommands extends JavaPlugin {
@Override
public void onEnable() {
initConfig();
}
private void initConfig() {
this.reloadConfig();
this.getConfig().options().header("WecosChatCommands Config");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.LoadedSuccesfull", "[WecosChatCommands] Loaded Succesfull.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.InstalledVersion", "[WecosChatCommands] The installed version is");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeLeave", " left the game.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeJoin", " joined the game.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp", "[Console: Opped ");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp2", "]");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasFeeded", " was Feeded.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereFeeded", "You were Feeded.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereHealed", "You were Healed.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasHealed", " was Healed.");
this.getConfig().options().copyDefaults(true);
this.saveConfig();
System.out.println("[WecosChatCommands] (Re)loaded Config succesfully.");
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
//Umwandlung Sender --> Player
Player p = null;
if(sender instanceof Player){
p = (Player)sender;
}
//test
if(cmd.getName().equalsIgnoreCase("wcctest")){
if (p != null) {
if(p.hasPermission("wecoschatcommands.wcctest"));
String version = this.getDescription().getVersion();
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.LoadedSuccesfull") + " ");
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.InstalledVersion") + " " + version);
for(int i = 0; i < this.getDescription().getAuthors().size(); i++){
}
return true;
} else {
String version = this.getDescription().getVersion();
sender.sendMessage(ChatColor.GREEN + "[FakeLeave] Loaded Succesfull.");
sender.sendMessage(ChatColor.GREEN + "[FakeLeave] The installed version is " + version);
return true;
}
}
//fakeleave
if(cmd.getName().equalsIgnoreCase("fakeleave")){
if(p != null){
if(p.hasPermission("wecoschatcommands.fakeleave"));
for (Player players : Bukkit.getOnlinePlayers()){
players.sendMessage(ChatColor.YELLOW + p.getDisplayName() + "" + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeLeave") + " ");
return true;
}
}
}
//End
//fakejoin
if(cmd.getName().equalsIgnoreCase("fakejoin")){
if(p != null){
if(p.hasPermission("wecoschatcommands.fakejoin"));
for (Player players : Bukkit.getOnlinePlayers()){
players.sendMessage(ChatColor.YELLOW + p.getDisplayName() + "" + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeJoin") + " ");
return true;
}
}
}
//End
//fakeop
if(cmd.getName().equalsIgnoreCase("fakeop")){
if(p != null){
if(p.hasPermission("wecoschatcommands.fakeop"));
if(args.length != 1){
return false;
}
Player targetPlayer = this.getServer().getPlayer(args[0]);
targetPlayer.sendMessage(ChatColor.GRAY + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp") + "" + targetPlayer.getDisplayName() + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp2") + "");
return true;
}
}
//End
//feed
if(cmd.getName().equalsIgnoreCase("wccfeed")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wccfeed"));
if(args.length != 1){
p.setFoodLevel(20);
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereFeeded"));
}
Player targetPlayer = this.getServer().getPlayer(args[0]);
targetPlayer.setFoodLevel(20);
p.sendMessage(ChatColor.GREEN + targetPlayer.getDisplayName() + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasFeeded") + "");
targetPlayer.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereFeeded"));
return true;
}
}
//End
//heal
if(cmd.getName().equalsIgnoreCase("wccheal")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wccheal"));
if(args.length != 1){
p.setHealth(20.0);
p.setFoodLevel(20);
for (PotionEffect effect : p.getActivePotionEffects())
p.removePotionEffect(effect.getType());
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereHealed"));
}
Player targetPlayer = this.getServer().getPlayer(args[0]);
targetPlayer.setFoodLevel(20);
targetPlayer.setHealth(20.0);
for (PotionEffect effect : targetPlayer.getActivePotionEffects())
targetPlayer.removePotionEffect(effect.getType());
p.sendMessage(ChatColor.GREEN + targetPlayer.getDisplayName() + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasHealed") + "");
targetPlayer.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereHealed"));
return true;
}
}
//wcckickall
if(cmd.getName().equalsIgnoreCase("wcckickall")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wcckickall"));
for (Player players : Bukkit.getOnlinePlayers()){
players.kickPlayer(ChatColor.GREEN + "[WecosChatCommands:] " + ChatColor.YELLOW + p.getDisplayName() + " kicked everyone.");
return true;
}
}
}
//End
//wcckillall
if(cmd.getName().equalsIgnoreCase("wcckillall")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wcckillall"));
for (Player players : Bukkit.getOnlinePlayers()){
players.sendMessage(ChatColor.GREEN + "[WecosChatCommands:] " + ChatColor.YELLOW + p.getDisplayName() + " killed everyone.");
players.setHealth(0.0);
return true;
}
}
}
//End
return false;
}
}
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.potion.PotionEffect;
public class WecosChatCommands extends JavaPlugin {
@Override
public void onEnable() {
initConfig();
}
private void initConfig() {
this.reloadConfig();
this.getConfig().options().header("WecosChatCommands Config");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.LoadedSuccesfull", "[WecosChatCommands] Loaded Succesfull.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.InstalledVersion", "[WecosChatCommands] The installed version is");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeLeave", " left the game.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeJoin", " joined the game.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp", "[Console: Opped ");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp2", "]");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasFeeded", " was Feeded.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereFeeded", "You were Feeded.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereHealed", "You were Healed.");
this.getConfig().addDefault("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasHealed", " was Healed.");
this.getConfig().options().copyDefaults(true);
this.saveConfig();
System.out.println("[WecosChatCommands] (Re)loaded Config succesfully.");
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
//Umwandlung Sender --> Player
Player p = null;
if(sender instanceof Player){
p = (Player)sender;
}
//test
if(cmd.getName().equalsIgnoreCase("wcctest")){
if (p != null) {
if(p.hasPermission("wecoschatcommands.wcctest"));
String version = this.getDescription().getVersion();
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.LoadedSuccesfull") + " ");
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.InstalledVersion") + " " + version);
for(int i = 0; i < this.getDescription().getAuthors().size(); i++){
}
return true;
} else {
String version = this.getDescription().getVersion();
sender.sendMessage(ChatColor.GREEN + "[FakeLeave] Loaded Succesfull.");
sender.sendMessage(ChatColor.GREEN + "[FakeLeave] The installed version is " + version);
return true;
}
}
//fakeleave
if(cmd.getName().equalsIgnoreCase("fakeleave")){
if(p != null){
if(p.hasPermission("wecoschatcommands.fakeleave"));
for (Player players : Bukkit.getOnlinePlayers()){
players.sendMessage(ChatColor.YELLOW + p.getDisplayName() + "" + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeLeave") + " ");
return true;
}
}
}
//End
//fakejoin
if(cmd.getName().equalsIgnoreCase("fakejoin")){
if(p != null){
if(p.hasPermission("wecoschatcommands.fakejoin"));
for (Player players : Bukkit.getOnlinePlayers()){
players.sendMessage(ChatColor.YELLOW + p.getDisplayName() + "" + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeJoin") + " ");
return true;
}
}
}
//End
//fakeop
if(cmd.getName().equalsIgnoreCase("fakeop")){
if(p != null){
if(p.hasPermission("wecoschatcommands.fakeop"));
if(args.length != 1){
return false;
}
Player targetPlayer = this.getServer().getPlayer(args[0]);
targetPlayer.sendMessage(ChatColor.GRAY + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp") + "" + targetPlayer.getDisplayName() + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.FakeOp2") + "");
return true;
}
}
//End
//feed
if(cmd.getName().equalsIgnoreCase("wccfeed")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wccfeed"));
if(args.length != 1){
p.setFoodLevel(20);
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereFeeded"));
}
Player targetPlayer = this.getServer().getPlayer(args[0]);
targetPlayer.setFoodLevel(20);
p.sendMessage(ChatColor.GREEN + targetPlayer.getDisplayName() + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasFeeded") + "");
targetPlayer.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereFeeded"));
return true;
}
}
//End
//heal
if(cmd.getName().equalsIgnoreCase("wccheal")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wccheal"));
if(args.length != 1){
p.setHealth(20.0);
p.setFoodLevel(20);
for (PotionEffect effect : p.getActivePotionEffects())
p.removePotionEffect(effect.getType());
p.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereHealed"));
}
Player targetPlayer = this.getServer().getPlayer(args[0]);
targetPlayer.setFoodLevel(20);
targetPlayer.setHealth(20.0);
for (PotionEffect effect : targetPlayer.getActivePotionEffects())
targetPlayer.removePotionEffect(effect.getType());
p.sendMessage(ChatColor.GREEN + targetPlayer.getDisplayName() + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.WasHealed") + "");
targetPlayer.sendMessage(ChatColor.GREEN + this.getConfig().getString("WecosChatCommands.commands.WECOSCHATCOMMANDS.messages.message.YouWereHealed"));
return true;
}
}
//wcckickall
if(cmd.getName().equalsIgnoreCase("wcckickall")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wcckickall"));
for (Player players : Bukkit.getOnlinePlayers()){
players.kickPlayer(ChatColor.GREEN + "[WecosChatCommands:] " + ChatColor.YELLOW + p.getDisplayName() + " kicked everyone.");
return true;
}
}
}
//End
//wcckillall
if(cmd.getName().equalsIgnoreCase("wcckillall")){
if(p != null){
if(p.hasPermission("wecoschatcommands.wcckillall"));
for (Player players : Bukkit.getOnlinePlayers()){
players.sendMessage(ChatColor.GREEN + "[WecosChatCommands:] " + ChatColor.YELLOW + p.getDisplayName() + " killed everyone.");
players.setHealth(0.0);
return true;
}
}
}
//End
return false;
}
}
No comments:
Post a Comment