human beings are pitiful clumps of matter
This commit is contained in:
parent
23bed03961
commit
1ec94c06e8
6 changed files with 126 additions and 0 deletions
0
config.yml
Normal file
0
config.yml
Normal file
6
plugin.yml
Normal file
6
plugin.yml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
main: iie.HelloWorldPlugin
|
||||||
|
version: 1.0.0
|
||||||
|
name: HelloWorldPlugin
|
||||||
|
commands:
|
||||||
|
HelloWorld:
|
||||||
|
description: Command that says Hello World!
|
37
src/iie/DeathListener.java
Normal file
37
src/iie/DeathListener.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package iie;
|
||||||
|
|
||||||
|
import java.time.Clock;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
|
||||||
|
public class DeathListener implements Listener {
|
||||||
|
|
||||||
|
HelloWorldPlugin plugin;
|
||||||
|
public DeathListener(HelloWorldPlugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onHardcoreDeath(PlayerDeathEvent deathEvent){
|
||||||
|
|
||||||
|
|
||||||
|
LocalDateTime currentTime = LocalDateTime.now(Clock.systemUTC());
|
||||||
|
String timeString = currentTime.toString();
|
||||||
|
Player player = deathEvent.getEntity();
|
||||||
|
String playerString = (String) player.getName();
|
||||||
|
Location location = player.getLocation();
|
||||||
|
String worldString = (String) location.getWorld().getName();
|
||||||
|
|
||||||
|
|
||||||
|
if (worldString == "hardcore"){
|
||||||
|
plugin.deathMap.put(playerString, timeString);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
46
src/iie/HelloWorld.java
Normal file
46
src/iie/HelloWorld.java
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
package iie;
|
||||||
|
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandExecutor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class HelloWorld implements CommandExecutor {
|
||||||
|
|
||||||
|
HelloWorldPlugin plugin;
|
||||||
|
public HelloWorld(HelloWorldPlugin plugin){
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command label, String command, String[] args) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
sender.sendMessage("WELL, AT LEAST THIS WORKS");
|
||||||
|
if (sender instanceof Player){
|
||||||
|
|
||||||
|
String playername = sender.getName();
|
||||||
|
int deathtime = Integer.parseInt(plugin.deathMap.get(playername));
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
int timeInt = (int) currentTime;
|
||||||
|
|
||||||
|
if (timeInt - deathtime >= 86400000){
|
||||||
|
Player player = (Player) sender;
|
||||||
|
World hardcoreWorld = player.getServer().getWorld("hardcore");
|
||||||
|
Location location = new Location(hardcoreWorld, 1280, 71, -179);
|
||||||
|
player.teleport(location);
|
||||||
|
}else{
|
||||||
|
sender.sendMessage("you are dead for the next" + ((86400000 - (timeInt - deathtime))/3600000) + "hours");
|
||||||
|
}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
|
||||||
|
sender.sendMessage("You must be a player to use this command!");
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/iie/HelloWorldPlugin.java
Normal file
18
src/iie/HelloWorldPlugin.java
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
package iie;
|
||||||
|
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
public class HelloWorldPlugin extends JavaPlugin {
|
||||||
|
public AbstractMap<String,String> deathMap = new HashMap<String,String>();
|
||||||
|
public void onEnable(){
|
||||||
|
registerCommands();
|
||||||
|
getServer().getPluginManager().registerEvents(new DeathListener(this), this);
|
||||||
|
}
|
||||||
|
public void registerCommands(){
|
||||||
|
getCommand("HelloWorld").setExecutor(new HelloWorld(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/iie/publicstaticvoidmain.java
Normal file
19
src/iie/publicstaticvoidmain.java
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
package iie;
|
||||||
|
|
||||||
|
public class publicstaticvoidmain {
|
||||||
|
public static void main(String[] args){
|
||||||
|
System.out.println("Hello World!");
|
||||||
|
|
||||||
|
int test = 1234;
|
||||||
|
String testString = Integer.toString(test);
|
||||||
|
int test2 = Integer.parseInt(testString);
|
||||||
|
System.out.println(test2);
|
||||||
|
|
||||||
|
|
||||||
|
long currentTime = System.currentTimeMillis();
|
||||||
|
System.out.println(currentTime);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue