death event works, working on commands
This commit is contained in:
parent
a6193c6618
commit
db5c24bc26
15 changed files with 114 additions and 32 deletions
4
TODO.md
4
TODO.md
|
@ -1,9 +1,11 @@
|
|||
# TODO List
|
||||
|
||||
### Done!
|
||||
* get the player death event working
|
||||
|
||||
### 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
|
||||
* 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`
|
||||
|
|
BIN
out/production/Resurrection/net/brysonsteck/CheckForUpdate.class
Normal file
BIN
out/production/Resurrection/net/brysonsteck/CheckForUpdate.class
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
out/production/Resurrection/net/brysonsteck/TImeCheck.class
Normal file
BIN
out/production/Resurrection/net/brysonsteck/TImeCheck.class
Normal file
Binary file not shown.
|
@ -1,3 +1,9 @@
|
|||
main: net.brysonsteck.Resurrection
|
||||
name: Resurrection
|
||||
version: alpha 0.0.1
|
||||
author: 'Bryson Steck'
|
||||
version: '0.0.1 alpha'
|
||||
commands:
|
||||
about:
|
||||
description: Displays information about Resurrection.
|
||||
permission: op
|
||||
usage: /about
|
|
@ -1,19 +0,0 @@
|
|||
package net.brysonsteck;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
System.out.println("Resurrection: A player has died!");
|
||||
Player p = e.getEntity();
|
||||
Long timeOfDeath = System.currentTimeMillis();
|
||||
Long resurrectionTime = timeOfDeath + 86400000;
|
||||
|
||||
p.sendMessage("You have died at " + timeOfDeath + ". You will respawn at " + resurrectionTime);
|
||||
}
|
||||
}
|
4
src/net/brysonsteck/Resurrection/CheckForUpdate.java
Normal file
4
src/net/brysonsteck/Resurrection/CheckForUpdate.java
Normal file
|
@ -0,0 +1,4 @@
|
|||
package net.brysonsteck.Resurrection;
|
||||
|
||||
public class CheckForUpdate {
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package net.brysonsteck;
|
||||
package net.brysonsteck.Resurrection;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
37
src/net/brysonsteck/Resurrection/PlayerListener.java
Normal file
37
src/net/brysonsteck/Resurrection/PlayerListener.java
Normal file
|
@ -0,0 +1,37 @@
|
|||
package net.brysonsteck.Resurrection;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin() {
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeath(PlayerDeathEvent e) {
|
||||
System.out.println("Resurrection: A player has died!");
|
||||
Player p = e.getEntity();
|
||||
p.setGameMode(GameMode.SPECTATOR);
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW,1000000000, 500));
|
||||
p.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 1000000000, 500));
|
||||
Long timeOfDeath = System.currentTimeMillis();
|
||||
Long resurrectionTime = timeOfDeath + 86400000;
|
||||
|
||||
TimeCheck death = new TimeCheck(timeOfDeath);
|
||||
TimeCheck resurrect = new TimeCheck(timeOfDeath + 86400000);
|
||||
|
||||
String deathFormatted = death.formatTime();
|
||||
String resurrectFormatted = resurrect.formatTime();
|
||||
|
||||
|
||||
p.sendMessage("You have died! You will be able to respawn in 24 hours.");
|
||||
}
|
||||
}
|
|
@ -1,14 +1,11 @@
|
|||
package net.brysonsteck;
|
||||
package net.brysonsteck.Resurrection;
|
||||
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import net.brysonsteck.Resurrection.commands.CommandAbout;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.Buffer;
|
||||
|
||||
public class Resurrection extends JavaPlugin {
|
||||
// public Plugin plugin = getPlugin(Resurrection.class);
|
||||
public Plugin plugin = getPlugin(Resurrection.class);
|
||||
|
||||
//spigot things
|
||||
@Override
|
||||
|
@ -19,9 +16,14 @@ public class Resurrection extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
|
||||
// register listener
|
||||
this.getServer().getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
|
||||
// register commands
|
||||
this.getCommand("about").setExecutor(new CommandAbout());
|
||||
|
||||
System.out.println("Resurrection: I'm alive!");
|
||||
PlayerListener playerListener = new PlayerListener();
|
||||
}
|
||||
|
||||
// end of spigot things
|
20
src/net/brysonsteck/Resurrection/TImeCheck.java
Normal file
20
src/net/brysonsteck/Resurrection/TImeCheck.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package net.brysonsteck.Resurrection;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
class TimeCheck {
|
||||
long millis;
|
||||
|
||||
public TimeCheck(long millis) {
|
||||
this.millis = millis;
|
||||
}
|
||||
|
||||
public String formatTime() {
|
||||
String formattedTime = String.format("%d hrs, %d min, %d sec",
|
||||
TimeUnit.MILLISECONDS.toHours(millis),
|
||||
TimeUnit.MILLISECONDS.toMinutes(millis),
|
||||
TimeUnit.MILLISECONDS.toSeconds(millis) -
|
||||
TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS.toMinutes(millis)));
|
||||
return formattedTime;
|
||||
}
|
||||
}
|
20
src/net/brysonsteck/Resurrection/commands/CommandAbout.java
Normal file
20
src/net/brysonsteck/Resurrection/commands/CommandAbout.java
Normal file
|
@ -0,0 +1,20 @@
|
|||
package net.brysonsteck.Resurrection.commands;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class CommandAbout implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
|
||||
String aboutMessage = "This is the about message for Resurrection.";
|
||||
if (commandSender instanceof Player) {
|
||||
Player p = (Player) commandSender;
|
||||
p.sendMessage(aboutMessage);
|
||||
} else {
|
||||
System.out.println(aboutMessage);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
13
src/net/brysonsteck/Resurrection/plugin.yml
Normal file
13
src/net/brysonsteck/Resurrection/plugin.yml
Normal file
|
@ -0,0 +1,13 @@
|
|||
main: net.brysonsteck.Resurrection.Resurrection
|
||||
name: Resurrection
|
||||
author: 'Bryson Steck'
|
||||
version: '0.0.1 alpha'
|
||||
commands:
|
||||
about:
|
||||
description: Displays information about Resurrection.
|
||||
permission: op
|
||||
usage: /about
|
||||
|
||||
timecheck:
|
||||
description: Displays the remaining time before the player (or specified player) is resurrected.
|
||||
usage: /timecheck [PLAYER NAME]
|
|
@ -1,3 +0,0 @@
|
|||
main: net.brysonsteck.Resurrection
|
||||
name: Resurrection
|
||||
version: alpha 0.0.1
|
Loading…
Add table
Reference in a new issue