Added /heal
This commit is contained in:
parent
b443697832
commit
c317338524
4
pom.xml
4
pom.xml
@ -1,8 +1,8 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.hyperling.minecraft</groupId>
|
<groupId>com.hyperling.minecraft</groupId>
|
||||||
<artifactId>CoderDojoTest</artifactId>
|
<artifactId>CoderDojoEVV</artifactId>
|
||||||
<version>0.1.3-SNAPSHOT</version>
|
<version>0.1.4-SNAPSHOT</version>
|
||||||
<name>Coder Dojo Test</name>
|
<name>Coder Dojo Test</name>
|
||||||
<description>Test project written to learn how to do Minecraft plug-in for Coder Dojo.</description>
|
<description>Test project written to learn how to do Minecraft plug-in for Coder Dojo.</description>
|
||||||
|
|
||||||
|
@ -1,22 +1,20 @@
|
|||||||
package com.hyperling.minecraft.coderdojotest;
|
package com.hyperling.minecraft.coderdojoevv;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.attribute.Attributable;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.PlayerInventory;
|
import org.bukkit.inventory.PlayerInventory;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
public final class CoderDojoTest extends JavaPlugin implements Listener {
|
public final class CoderDojoEVV extends JavaPlugin implements Listener {
|
||||||
public CoderDojoTest() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
@ -53,6 +51,10 @@ public final class CoderDojoTest extends JavaPlugin implements Listener {
|
|||||||
inv.addItem(item);
|
inv.addItem(item);
|
||||||
item = new ItemStack(Material.DIAMOND_SPADE);
|
item = new ItemStack(Material.DIAMOND_SPADE);
|
||||||
inv.remove(Material.DIAMOND_SPADE);
|
inv.remove(Material.DIAMOND_SPADE);
|
||||||
|
/* For 1.13 API
|
||||||
|
item = new ItemStack(Material.DIAMOND_SHOVEL);
|
||||||
|
inv.remove(Material.DIAMOND_SHOVEL);
|
||||||
|
*/
|
||||||
inv.addItem(item);
|
inv.addItem(item);
|
||||||
item = new ItemStack(Material.DIAMOND_HOE);
|
item = new ItemStack(Material.DIAMOND_HOE);
|
||||||
inv.remove(Material.DIAMOND_HOE);
|
inv.remove(Material.DIAMOND_HOE);
|
||||||
@ -79,6 +81,26 @@ public final class CoderDojoTest extends JavaPlugin implements Listener {
|
|||||||
getServer().broadcastMessage("Inventory has been cleared for Creative mode.");
|
getServer().broadcastMessage("Inventory has been cleared for Creative mode.");
|
||||||
}
|
}
|
||||||
|
|
||||||
getLogger().info("Refreshed diamond items.");
|
getLogger().info("Finished onJoin().");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
Player player = (Player) sender;
|
||||||
|
|
||||||
|
getLogger().info(player.getName() + " issued command with label " + label + ".");
|
||||||
|
|
||||||
|
if (label.equals("heal")) {
|
||||||
|
double health = player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getDefaultValue();
|
||||||
|
int food = (int) health;
|
||||||
|
|
||||||
|
player.setHealth(health);
|
||||||
|
player.setFireTicks(0);
|
||||||
|
player.setFoodLevel(food);
|
||||||
|
getLogger().info(player.getName() + " has healed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
getLogger().info("Finished onCommand().");
|
||||||
|
return super.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,3 +1,7 @@
|
|||||||
name: CoderDojoTest
|
name: CoderDojoEVV
|
||||||
main: com.hyperling.minecraft.coderdojotest.CoderDojoTest
|
main: com.hyperling.minecraft.coderdojoevv.CoderDojoEVV
|
||||||
version: 0.1.2
|
version: 0.1.4
|
||||||
|
|
||||||
|
commands:
|
||||||
|
heal:
|
||||||
|
description: Heal hearts, food, and ends fire.
|
@ -1,3 +1,7 @@
|
|||||||
name: CoderDojoTest
|
name: CoderDojoEVV
|
||||||
main: com.hyperling.minecraft.coderdojotest.CoderDojoTest
|
main: com.hyperling.minecraft.coderdojoevv.CoderDojoEVV
|
||||||
version: 0.1.2
|
version: 0.1.4
|
||||||
|
|
||||||
|
commands:
|
||||||
|
heal:
|
||||||
|
description: Heal hearts, food, and ends fire.
|
@ -1,5 +1,5 @@
|
|||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Thu Dec 27 10:04:47 CST 2018
|
#Fri Dec 28 10:02:46 CST 2018
|
||||||
version=0.1.3-SNAPSHOT
|
version=0.1.4-SNAPSHOT
|
||||||
groupId=com.hyperling.minecraft
|
groupId=com.hyperling.minecraft
|
||||||
artifactId=CoderDojoTest
|
artifactId=CoderDojoEVV
|
||||||
|
@ -1 +1 @@
|
|||||||
/home/ling/Programs/eclipse-workspace/CoderDojoTest/src/main/java/com/hyperling/minecraft/coderdojotest/CoderDojoTest.java
|
/home/ling/Programs/eclipse-workspace/CoderDojoEVV/src/main/java/com/hyperling/minecraft/coderdojoevv/CoderDojoEVV.java
|
||||||
|
Reference in New Issue
Block a user