i think the death thing works now
This commit is contained in:
parent
8449343bdf
commit
c18c642b97
6 changed files with 71 additions and 2 deletions
4
TODO.md
4
TODO.md
|
@ -2,11 +2,13 @@
|
||||||
|
|
||||||
### Done!
|
### Done!
|
||||||
* get the player death event working
|
* get the player death event working
|
||||||
|
* figure out how to convert milliseconds to an actual date and time for the end user
|
||||||
|
* figure out commands and how to use them
|
||||||
|
* `about`
|
||||||
|
|
||||||
### For first release
|
### For first release
|
||||||
|
|
||||||
* figure out how to get the player.data file to add a user when one joins the server for the first time
|
* figure out how to get the player.data file to add a user when one joins the server for the first time
|
||||||
* figure out how to convert milliseconds to an actual date and time for the end user
|
|
||||||
* figure out commands and how to use them
|
* figure out commands and how to use them
|
||||||
* `about`
|
* `about`
|
||||||
* `resurrect PLAYER` (resurrects a player now if needed)
|
* `resurrect PLAYER` (resurrects a player now if needed)
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,6 +1,8 @@
|
||||||
package net.brysonsteck.Resurrection;
|
package net.brysonsteck.Resurrection;
|
||||||
|
|
||||||
import net.brysonsteck.Resurrection.commands.CommandAbout;
|
import net.brysonsteck.Resurrection.commands.CommandAbout;
|
||||||
|
import net.brysonsteck.Resurrection.commands.CommandResurrect;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
@ -22,8 +24,9 @@ public class Resurrection extends JavaPlugin {
|
||||||
|
|
||||||
// register commands
|
// register commands
|
||||||
this.getCommand("about").setExecutor(new CommandAbout());
|
this.getCommand("about").setExecutor(new CommandAbout());
|
||||||
|
this.getCommand("resurrect").setExecutor(new CommandResurrect());
|
||||||
|
|
||||||
System.out.println("Resurrection: I'm alive!");
|
System.out.println("[Resurrection] I'm alive!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of spigot things
|
// end of spigot things
|
||||||
|
|
|
@ -0,0 +1,64 @@
|
||||||
|
package net.brysonsteck.Resurrection.commands;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
|
||||||
|
public class CommandResurrect implements CommandExecutor {
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||||
|
boolean valid = (strings.length != 1);
|
||||||
|
|
||||||
|
if (commandSender instanceof Player) {
|
||||||
|
Player p = (Player) commandSender;
|
||||||
|
if (valid) {
|
||||||
|
Player resurrectPlayer = Bukkit.getPlayer(strings[0]);
|
||||||
|
if (resurrectPlayer == null) {
|
||||||
|
p.sendMessage("That player does not exist! Failed to resurrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (resurrectPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||||
|
for (PotionEffect effect : resurrectPlayer.getActivePotionEffects())
|
||||||
|
resurrectPlayer.removePotionEffect(effect.getType());
|
||||||
|
resurrectPlayer.setGameMode(GameMode.SURVIVAL);
|
||||||
|
Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
p.sendMessage(strings[0] + " is not dead! Failed to resurrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Too few arguments!");
|
||||||
|
System.out.println("Usage: /resurrect PLAYER");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (valid) {
|
||||||
|
Player resurrectPlayer = Bukkit.getPlayer(strings[0]);
|
||||||
|
if (resurrectPlayer == null) {
|
||||||
|
System.out.println("That player does not exist! Failed to resurrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (resurrectPlayer.getGameMode() == GameMode.SPECTATOR) {
|
||||||
|
for (PotionEffect effect : resurrectPlayer.getActivePotionEffects())
|
||||||
|
resurrectPlayer.removePotionEffect(effect.getType());
|
||||||
|
resurrectPlayer.setGameMode(GameMode.SURVIVAL);
|
||||||
|
Bukkit.broadcastMessage(strings[0] + " has been resurrected manually by an admin!");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
System.out.println(strings[0] + " is not dead! Failed to resurrect.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
System.out.println("Too few arguments!");
|
||||||
|
System.out.println("Usage: /resurrect PLAYER");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue