Skip to content

Commit

Permalink
Added NightVision Command.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomster09090 committed Dec 4, 2022
1 parent 1dce53e commit f8b349f
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/java/me/tomster09090/staffutil/StaffUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.tomster09090.staffutil.commands.chatfunctions.clearChat;
import me.tomster09090.staffutil.commands.chatfunctions.managementChatCommand;
import me.tomster09090.staffutil.commands.chatfunctions.reportPlayer;
import me.tomster09090.staffutil.commands.nvCommand;
import me.tomster09090.staffutil.commands.reloadCommand;
import me.tomster09090.staffutil.commands.rsp.onPackLoad;
import me.tomster09090.staffutil.commands.rsp.resourcePackCommand;
Expand Down Expand Up @@ -52,6 +53,7 @@ public void onEnable() {
logger();
getCommand("clearchat").setExecutor(new clearChat(this));
getCommand("rsp").setExecutor(new resourcePackCommand(this));
getCommand("nightvision").setExecutor(new nvCommand());
Bukkit.getPluginManager().registerEvents(new onPackLoad(this), this);
Bukkit.getPluginManager().registerEvents(new DiscordListener(this), this);
Bukkit.getPluginManager().registerEvents(new asyncChatCooldownListener(this), this);
Expand Down
57 changes: 57 additions & 0 deletions src/main/java/me/tomster09090/staffutil/commands/nvCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package me.tomster09090.staffutil.commands;

import me.tomster09090.staffutil.util.CC;
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 org.bukkit.potion.Potion;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import org.bukkit.potion.PotionType;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class nvCommand implements CommandExecutor {
List<Player> playersWithNV = new ArrayList<>();

@Override
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
if (commandSender.hasPermission("staff.nv")) {
Player player = (Player) commandSender;
if (args.length == 0) {
if (!playersWithNV.contains(player)) {
playersWithNV.add(player);
player.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 999999, 255, false, false));
player.sendMessage(CC.GREEN + "You now have night vision!");
} else {
playersWithNV.remove(player);
player.removePotionEffect(PotionEffectType.NIGHT_VISION);
player.sendMessage(CC.RED + "You no longer have night vision!");
}
}else{
String targetName = args[0];
Player target = Bukkit.getServer().getPlayerExact(targetName);
if (target == null){
player.sendMessage(CC.RED + "Player " + targetName + " isn't online.");
}else if (!playersWithNV.contains(target)){
playersWithNV.add(target);
player.sendMessage(CC.GREEN + "Forcefully given nightvision to " + targetName + "!");

target.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 999999, 255, false, false));
target.sendMessage(CC.GREEN + "You have forcefully been given night vision!");
}else{
playersWithNV.remove(target);
player.sendMessage(CC.RED + "Forcefully removed nightvision from " + targetName + "!");

target.removePotionEffect(PotionEffectType.NIGHT_VISION);
target.sendMessage(CC.RED + "Your nightvision has been forcefully taken away!");
}
}
}
return false;
}
}
6 changes: 6 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ commands:
report:
description: Gives you the ability to report another player.
permission: staff.report
nightvision:
aliases:
- nv
description: Gives the user night vision.
permission: staff.nv
permissions:
staff.*:
children:
Expand All @@ -48,6 +53,7 @@ permissions:
staff.report.read: true
staff.reload: true
staff.cooldown.bypass: true
staff.nv: true
description: Permission node for all array of commands within the plugin.
default: op

Expand Down
1 change: 1 addition & 0 deletions target/classes/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ cooldown-message: "&cHey %player%! You're talking too fast! Please wait %seconds
#----- RESOURCE PACK -----#
#Set this option to false if you would like to allow your players to join your server without a resource pack.
force-resource-pack: true
console-notify-on-fail: false
#If set to true, this is where you should put your server resource pack for the plugin to attempt to download client-side.
resource-pack-link: "RESOURCE-PACK"

Expand Down
Binary file modified target/classes/me/tomster09090/staffutil/StaffUtil.class
Binary file not shown.
Binary file not shown.
6 changes: 6 additions & 0 deletions target/classes/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ commands:
report:
description: Gives you the ability to report another player.
permission: staff.report
nightvision:
aliases:
- nv
description: Gives the user night vision.
permission: staff.nv
permissions:
staff.*:
children:
Expand All @@ -48,6 +53,7 @@ permissions:
staff.report.read: true
staff.reload: true
staff.cooldown.bypass: true
staff.nv: true
description: Permission node for all array of commands within the plugin.
default: op

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
me\tomster09090\staffutil\StaffUtil.class
me\tomster09090\staffutil\commands\nvCommand.class
me\tomster09090\staffutil\commands\chatfunctions\managementChatCommand.class
me\tomster09090\staffutil\util\CC.class
me\tomster09090\staffutil\commands\chatfunctions\reportPlayer.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ C:\Users\tomka\Documents\GitHub\StaffUtil\src\main\java\me\tomster09090\staffuti
C:\Users\tomka\Documents\GitHub\StaffUtil\src\main\java\me\tomster09090\staffutil\commands\chatfunctions\clearChat.java
C:\Users\tomka\Documents\GitHub\StaffUtil\src\main\java\me\tomster09090\staffutil\StaffUtil.java
C:\Users\tomka\Documents\GitHub\StaffUtil\src\main\java\me\tomster09090\staffutil\commands\rsp\resourcePackCommand.java
C:\Users\tomka\Documents\GitHub\StaffUtil\src\main\java\me\tomster09090\staffutil\commands\nvCommand.java

0 comments on commit f8b349f

Please sign in to comment.