Skip to content

Commit

Permalink
Updated: Extra death causes added
Browse files Browse the repository at this point in the history
Config has been adjusted, and the /kill command now support death cause
  • Loading branch information
BlaneyXYZ committed Jun 23, 2024
1 parent cf88767 commit c76b725
Show file tree
Hide file tree
Showing 5 changed files with 167 additions and 105 deletions.
2 changes: 1 addition & 1 deletion docs/commands/kill.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ command:
supports:
name-completion: false
time-format: false
usage: /kill [player]
usage: /kill [player] (cause)
layout: command
title: /kill
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,24 @@ private String getMessageType() {
case BLOCK_EXPLOSION:
pullFrom = "blo";
break;
case CAMPFIRE:
pullFrom = "cam";
break;
case CONTACT:
pullFrom = "con";
break;
case CUSTOM:
case DRAGON_BREATH:
pullFrom = "dra";
break;
case DROWNING:
pullFrom = "dro";
break;
case ENTITY_ATTACK:
case PROJECTILE:
pullFrom = (this.getDeathType() == DeathType.PLAYER) ? "pvp" : "mob";
pullFrom = "mob";
break;
case SUFFOCATION:
pullFrom = "suf";
case ENTITY_EXPLOSION:
pullFrom = "cre";
break;
case FALL:
pullFrom = "fal";
Expand All @@ -66,53 +75,58 @@ private String getMessageType() {
case FIRE_TICK:
pullFrom = "fir";
break;
case LAVA:
pullFrom = "lav";
case FLY_INTO_WALL:
pullFrom = "fiw";
break;
case DROWNING:
pullFrom = "dro";
case FREEZE:
pullFrom = "fro";
break;
case ENTITY_EXPLOSION:
pullFrom = "cre";
case HOT_FLOOR:
pullFrom = "hot";
break;
case VOID:
pullFrom = "voi";
case LAVA:
pullFrom = "lav";
break;
case LIGHTNING:
pullFrom = "lig";
break;
case SUICIDE:
pullFrom = "sui";
break;
case STARVATION:
pullFrom = "sta";
case MAGIC:
pullFrom = "mag";
break;
case MELTING:
case POISON:
pullFrom = "poi";
break;
case MAGIC:
pullFrom = "mag";
case PROJECTILE:
pullFrom = (this.getDeathType() == DeathType.PLAYER) ? "pvp" : "mob";
break;
case WITHER:
pullFrom = "wit";
case SONIC_BOOM:
pullFrom = "son";
break;
case STARVATION:
pullFrom = "sta";
break;
case SUFFOCATION:
pullFrom = "suf";
break;
case SUICIDE:
pullFrom = "sui";
break;
case THORNS:
pullFrom = "tho";
break;
case DRAGON_BREATH:
pullFrom = "dra";
case WITHER:
pullFrom = "wit";
break;
case FREEZE:
pullFrom = "fro";
case VOID:
pullFrom = "voi";
break;
case MELTING:
case CUSTOM:
default:
pullFrom = "oth";
break;
}
return pullFrom;
}
}//A B C D E F G H I J K L M N O P Q R S T U V W X y Z

private RoyalCommands getPlugin() {
return this.plugin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,30 @@
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent;
import org.royaldev.royalcommands.AuthorizationHandler.PermType;
import org.royaldev.royalcommands.MessageColor;
import org.royaldev.royalcommands.RoyalCommands;

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

@ReflectCommand
public class CmdKill extends TabCommand {

public CmdKill(final RoyalCommands instance, final String name) {
super(instance, name, true, new Short[]{CompletionType.ONLINE_PLAYER.getShort()});
super(instance, name, true, new Short[]{CompletionType.ONLINE_PLAYER.getShort(), CompletionType.CUSTOM.getShort()});
}

@Override
protected List<String> getCustomCompletions(final CommandSender cs, final Command cmd, final String label, final String[] args, final String arg) {
ArrayList<String> causes = new ArrayList<>();
for (EntityDamageEvent.DamageCause cause : EntityDamageEvent.DamageCause.values()) {
if (!cause.name().toLowerCase().startsWith(arg.toLowerCase())) continue;
causes.add(cause.name().toLowerCase());
}
return causes;
}

@Override
Expand All @@ -34,6 +49,17 @@ public boolean runCommand(final CommandSender cs, final Command cmd, final Strin
cs.sendMessage(MessageColor.NEGATIVE + "You cannot kill that player!");
return true;
}
if (args.length > 1){
Player p = (Player) cs;
try{
EntityDamageEvent.DamageCause cause = EntityDamageEvent.DamageCause.valueOf(args[1].toUpperCase());
t.setLastDamageCause(new EntityDamageByEntityEvent(p, t, cause, 0D));
} catch (IllegalArgumentException e) {
cs.sendMessage(MessageColor.NEGATIVE + "Please use a valid cause of death.");
return true;
}

}
t.setHealth(0);
cs.sendMessage(MessageColor.POSITIVE + "You have killed " + MessageColor.NEUTRAL + t.getDisplayName() + MessageColor.POSITIVE + ".");
return true;
Expand Down
170 changes: 96 additions & 74 deletions modules/RoyalCommands/src/main/resources/deathmessages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,118 +24,140 @@ var_color: DARK_AQUA
mes_color: RED

###################
# Sections!
# pvp <- For player vs player combat death messages
# lav <- Lava deaths
# fir <- Fire deaths
# dro <- Drowning deaths
# con <- Contact deaths (cacti)
# sta <- Starvation deaths
# sui <- Suicide deaths
# poi <- Poison deaths
# lig <- Lightning deaths
# fal <- Fall deaths
# fab <- Falling block deaths
# blo <- Block explosion deaths
# cre <- Creeper explosion deaths
# suf <- Suffocation deaths
# voi <- Void deaths
# mag <- Magic deaths (harming potions, etc)
# mob <- Monster death messages
# wit <- Wither death messages
# tho <- Thorns death messages
# oth <- Other death messages (unknown)
# Death Causes
###################

pvp:
- "{player} was killed by {killer} wielding {hand}."
- "{player} was struck down by {killer} with {hand}."
- "{killer} bashed {player} to a pulp with {hand}."

lav:
- "{player} tried to swim in lava."
- "{player} is now obsidian."
- "{player} mistook lava for water."

fir:
- "{player} was burnt to a crisp."
- "{player} caught on fire."
- "{player} was burned alive."
# blo <- Block explosion deaths
blo:
- "{player} exploded."
- "{player} has an explosive personality."
- "{player} is now scattered around the floor in chunks."

dro:
- "{player} is now one with the sea."
- "{player} is swimming with the fishies."
- "{player} tried to be a fish."
# cam <- Campfire deaths
cam:
- "{player} walked into the campfire."
- "{player} dropped a marshmallow into the campfire."

# con <- Contact deaths (cacti)
con:
- "{player} hugged a cactus."
- "{player} forgot that cacti are sharp."

sta:
- "{player} forgot to eat."
- "Starvation took {player} from us."

sui:
- "{player} committed suicide."
# cre <- Creeper explosion deaths
cre:
- "{player} hugged a creeper."
- "{player} got too close to a lil' creeper."

poi:
- "{player} has died from poison!"
- "{player} was poisoned!"
# dra <- Dragon Breath deaths
dra:
- "{player} took on the dragon and didn't survive to tell the story"

lig:
- "{player} was smitten by Zeus."
- "{player} was struck by lightning."
# dro <- Drowning deaths
dro:
- "{player} is now one with the sea."
- "{player} is swimming with the fishies."
- "{player} tried to be a fish."

# fal <- Fall deaths
fal:
- "{player} fell off a plateau."
- "{player} fell off a cliff."
- "{player} hit the ground too hard."
- "{player} tried to fly."

# fab <- Falling block deaths
fab:
- "A block fell on {player}."
- "A block fell on {player}, crushing his hopes and dreams."
- "{player} got squished."

blo:
- "{player} exploded."
- "{player} has an explosive personality."
- "{player} is now scattered around the floor in chunks."
# fir <- Fire deaths
fir:
- "{player} was burnt to a crisp."
- "{player} caught on fire."
- "{player} was burned alive."

cre:
- "{player} hugged a creeper."
- "{player} got too close to a lil' creeper."
# fiw <- Flying into wall deaths
fiw:
- "{player} flew into a wall."
- "{player} hit the wall at warp speed."

suf:
- "{player} got caught in a block."
- "{player} suffocated."
# fro <- Frozen deaths
fro:
- "{player} froze because they couldn't let it go"

voi:
- "{player} fell into the void."
- "{player} fell out of the world."
- "{player} went past the space-time continuum."
# hot <- Magma touch deaths
hot:
- "Someone didn't tell {player} that the floor is lava."

# lav <- Lava deaths
lav:
- "{player} tried to swim in lava."
- "{player} is now obsidian."
- "{player} mistook lava for water."

# lig <- Lightning deaths
lig:
- "{player} was smitten by Zeus."
- "{player} was struck by lightning."

# mag <- Magic deaths (harming potions, etc)
mag:
- "{player} got hit by a nasty potion."

# mob <- Monster death messages
mob:
- "{player} was killed by a {mob}."
- "{player} was attacked by {mob}."
- "An angry {mob} killed {player}."

wit:
- "{player} was killed by a wither!"
- "A wither annihilated {player}."
# oth <- Other death messages (unknown)
oth:
- "{player} died of unknown causes."

# poi <- Poison deaths
poi:
- "{player} has died from poison!"
- "{player} was poisoned!"

# pvp <- For player vs player combat death messages
pvp:
- "{player} was killed by {killer} wielding {hand}."
- "{player} was struck down by {killer} with {hand}."
- "{killer} bashed {player} to a pulp with {hand}."

# sta <- Starvation deaths
sta:
- "{player} forgot to eat."
- "Starvation took {player} from us."

# son <- Warden sonic boom deaths
son:
- "{player} couldn't handle the boom."
- "{player} ear drums popped."

# sui <- Suicide deaths
sui:
- "{player} committed suicide."

# suf <- Suffocation deaths
suf:
- "{player} got caught in a block."
- "{player} suffocated."

# tho <- Thorns death messages
tho:
- "{player} got a taste of his own medicine."
- "Reflected damage got the jump on {player}."

dra:
- "{player} took on the dragon and didn't survive to tell the story"
# voi <- Void deaths
voi:
- "{player} fell into the void."
- "{player} fell out of the world."
- "{player} went past the space-time continuum."

fro:
- "{player} froze because they couldn't let it go"
# wit <- Wither death messages
wit:
- "{player} was killed by a wither!"
- "A wither annihilated {player}."

oth:
- "{player} died of unknown causes."
2 changes: 1 addition & 1 deletion modules/RoyalCommands/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ reflectcommands:
- murder
class: CmdKill
description: Kills another player.
usage: '/<command> [player]'
usage: '/<command> [player] (cause)'
version_added: Pre-0.2.7
killall:
aliases:
Expand Down

0 comments on commit c76b725

Please sign in to comment.