Skip to content

Commit

Permalink
Add some new bits 'n' pieces
Browse files Browse the repository at this point in the history
  • Loading branch information
ElementalMP4 committed Mar 15, 2024
1 parent 5942720 commit 52d3d59
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/main/java/elementalmp4/SebUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ public void onEnable() {
getCommand("grantpermit").setExecutor(new GrantPermitCommand());
getCommand("revokepermit").setExecutor(new RevokePermitCommand());
getCommand("permits").setExecutor(new PermitsCommand());
getCommand("smite").setExecutor(new SmiteCommand());

logger.info(ConsoleColours.YELLOW + "Registering autofill");
getCommand("namecolour").setTabCompleter(new ColourTabCompleter());
Expand Down
12 changes: 2 additions & 10 deletions src/main/java/elementalmp4/command/admin/ListHomesCommand.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package main.java.elementalmp4.command.admin;

import main.java.elementalmp4.SebUtils;
import main.java.elementalmp4.service.HomeService;
import main.java.elementalmp4.utils.Home;
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 java.util.List;

Expand All @@ -19,15 +17,9 @@ public boolean onCommand(CommandSender commandSender, Command command, String al
return true;
}

Player player = SebUtils.getPlugin().getServer().getPlayer(args[0]);
if (player == null) {
commandSender.sendMessage(ChatColor.RED + "Player could not be found!");
return true;
}

List<Home> homes = HomeService.getHomes(player.getName());
List<Home> homes = HomeService.getHomes(args[0]);
if (homes.isEmpty()) {
commandSender.sendMessage(ChatColor.RED + "User hasn't set any homes");
commandSender.sendMessage(ChatColor.RED + "No homes found for player " + ChatColor.YELLOW + args[0]);
} else {
StringBuilder sb = new StringBuilder();
for (Home home : homes) {
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/elementalmp4/command/admin/SmiteCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main.java.elementalmp4.command.admin;

import main.java.elementalmp4.SebUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class SmiteCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String alias, String[] args) {
if (args.length == 0) {
commandSender.sendMessage(ChatColor.RED + "You must specify a player!");
return true;
}

Player player = SebUtils.getPlugin().getServer().getPlayer(args[0]);
if (player == null) {
commandSender.sendMessage(ChatColor.RED + "Player could not be found!");
return true;
}
player.getWorld().strikeLightning(player.getLocation());
player.setHealth(0);
commandSender.sendMessage(ChatColor.YELLOW + player.getName() + ChatColor.RED + " has been smited");
return true;
}
}
9 changes: 7 additions & 2 deletions src/main/java/elementalmp4/command/homes/HomeCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import main.java.elementalmp4.service.HomeService;
import org.bukkit.ChatColor;
import org.bukkit.Effect;
import org.bukkit.Sound;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
Expand All @@ -13,8 +15,11 @@ public class HomeCommand implements CommandExecutor {
public boolean onCommand(CommandSender commandSender, Command command, String label, String[] args) {
String homeName = args.length == 0 ? "default" : args[0];
if (HomeService.userHasHome(commandSender.getName(), homeName)) {
commandSender.sendMessage(ChatColor.GOLD + "Taking you home...");
HomeService.teleportUserHome(((Player) commandSender), homeName);
Player player = (Player) commandSender;
commandSender.sendMessage(ChatColor.GOLD + "Teleporting...");
HomeService.teleportUserHome(player, homeName);
player.playSound(player.getLocation(), Sound.ENTITY_ENDERMAN_TELEPORT, 10, 1);
player.playEffect(player.getLocation(), Effect.ENDER_SIGNAL, 5);
} else {
commandSender.sendMessage(ChatColor.RED + "You don't have a home with that name, or you haven't set a default home yet");
}
Expand Down
4 changes: 4 additions & 0 deletions src/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ commands:
description: "Toggle whether sheep are smited when shaved"
usage: "/sheepsmite [true/false]"
permission: "sebutils.admin"
smite:
description: "Smite a player"
usage: "/smite [player]"
permission: "sebutils.admin"
showconfig:
description: "Shows the plugin configuration"
usage: "/showconfig"
Expand Down

0 comments on commit 52d3d59

Please sign in to comment.