-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for & color code syntax (#5)
* Add support for & color code syntax * Add suicide command
- Loading branch information
Robin Füllgraf
authored
Apr 6, 2022
1 parent
16d3c98
commit 3cb1006
Showing
5 changed files
with
54 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
src/main/java/net/simplyvanilla/nopluginscommand/command/SuicideCommandExecutor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package net.simplyvanilla.nopluginscommand.command; | ||
|
||
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.jetbrains.annotations.NotNull; | ||
|
||
public class SuicideCommandExecutor implements CommandExecutor { | ||
|
||
private final String messageToBroadcast; | ||
|
||
public SuicideCommandExecutor(String messageToBroadcast) { | ||
this.messageToBroadcast = messageToBroadcast; | ||
} | ||
|
||
@Override | ||
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) { | ||
if (!(sender instanceof Player player)) { | ||
sender.sendMessage("This command is only for players!"); | ||
return true; | ||
} | ||
|
||
player.setHealth(0); | ||
if (messageToBroadcast != null && !messageToBroadcast.isEmpty()) { | ||
Bukkit.broadcastMessage(messageToBroadcast.replaceAll("%name%", player.getName())); | ||
} | ||
return true; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
whitelist: | ||
- info | ||
- shop | ||
# %name% is the name of the player who committed suicide | ||
suicide-broadcst: "&7The player &e%name% &4commited suicide" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters