Files
Builders-Utilities/src/main/java/net/arcaniax/buildersutilities/commands/NightVisionCommand.java
T
2021-01-07 20:04:42 +01:00

54 lines
2.5 KiB
Java

/*
* ____ _ _ _ _ _ _ _ _ _ _ _
* | _ \ (_) | | | | | | | | (_) (_) | (_)
* | |_) |_ _ _| | __| | ___ _ __ ___ ______| | | | |_ _| |_| |_ _ ___ ___
* | _ <| | | | | |/ _` |/ _ \ '__/ __|______| | | | __| | | | __| |/ _ \/ __|
* | |_) | |_| | | | (_| | __/ | \__ \ | |__| | |_| | | | |_| | __/\__ \
* |____/ \__,_|_|_|\__,_|\___|_| |___/ \____/ \__|_|_|_|\__|_|\___||___/
*
* Builder's Utilities is a collection of a lot of tiny features that help with building.
* Copyright (C) 2021 Arcaniax
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package net.arcaniax.buildersutilities.commands;
import net.arcaniax.buildersutilities.BuildersUtilities;
import net.arcaniax.buildersutilities.Settings;
import net.arcaniax.buildersutilities.commands.system.ICommand;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class NightVisionCommand implements ICommand {
@Override
public void execute(Player player, String[] args) {
if (!player.hasPermission("builders.util.nightvision")) {
if (Settings.sendErrorMessages) {
player.sendMessage(BuildersUtilities.MSG_NO_PERMISSION + "builders.util.nightvision");
}
return;
}
if (player.hasPotionEffect(PotionEffectType.NIGHT_VISION)) {
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
player.sendMessage(BuildersUtilities.MSG_PREFIX + "Night Vision " + ChatColor.RED + "disabled");
} else {
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, Integer.MAX_VALUE, 0, true, false));
player.sendMessage(BuildersUtilities.MSG_PREFIX + "Night Vision " + ChatColor.GREEN + "enabled");
}
}
}