v0.1.7
Added onRespawn event to DiamondItems.
This commit is contained in:
parent
220df1269b
commit
3282950e62
2
pom.xml
2
pom.xml
@ -2,7 +2,7 @@
|
|||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.hyperling.minecraft</groupId>
|
<groupId>com.hyperling.minecraft</groupId>
|
||||||
<artifactId>CoderDojoEVV</artifactId>
|
<artifactId>CoderDojoEVV</artifactId>
|
||||||
<version>0.1.6-SNAPSHOT</version>
|
<version>0.1.7-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>
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ 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.PlayerRespawnEvent;
|
||||||
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;
|
||||||
@ -17,7 +18,18 @@ public class DiamondItems implements Listener{
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onRespawn(PlayerRespawnEvent event) {
|
||||||
|
plugin.getLogger().info("Running onRespawn.");
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
final PlayerInventory inv = player.getInventory();
|
||||||
|
|
||||||
|
if (plugin.getServer().getDefaultGameMode() != GameMode.CREATIVE) {
|
||||||
|
giveDiamondItems(inv);
|
||||||
|
plugin.getServer().broadcastMessage(player.getDisplayName() + " was given back items.");
|
||||||
|
}
|
||||||
|
plugin.getLogger().info("Finished onRespawn().");
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onJoin(PlayerJoinEvent event) {
|
public void onJoin(PlayerJoinEvent event) {
|
||||||
@ -30,7 +42,18 @@ public class DiamondItems implements Listener{
|
|||||||
|
|
||||||
// Give diamond tools and food if not in creative
|
// Give diamond tools and food if not in creative
|
||||||
if (plugin.getServer().getDefaultGameMode() != GameMode.CREATIVE) {
|
if (plugin.getServer().getDefaultGameMode() != GameMode.CREATIVE) {
|
||||||
|
giveDiamondItems(inv);
|
||||||
plugin.getServer().broadcastMessage("Enjoy your items!");
|
plugin.getServer().broadcastMessage("Enjoy your items!");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
inv.clear();
|
||||||
|
plugin.getLogger().info("Inventory has been cleared for Creative mode.");
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.getLogger().info("Finished onJoin().");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void giveDiamondItems(PlayerInventory inv) {
|
||||||
ItemStack item;
|
ItemStack item;
|
||||||
item = new ItemStack(Material.DIAMOND_SWORD);
|
item = new ItemStack(Material.DIAMOND_SWORD);
|
||||||
inv.remove(Material.DIAMOND_SWORD);
|
inv.remove(Material.DIAMOND_SWORD);
|
||||||
@ -68,11 +91,5 @@ public class DiamondItems implements Listener{
|
|||||||
item = new ItemStack(Material.DIAMOND_HELMET);
|
item = new ItemStack(Material.DIAMOND_HELMET);
|
||||||
inv.setHelmet(item);
|
inv.setHelmet(item);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
inv.clear();
|
|
||||||
plugin.getServer().broadcastMessage("Inventory has been cleared for Creative mode.");
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.getLogger().info("Finished onJoin().");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: CoderDojoEVV
|
name: CoderDojoEVV
|
||||||
main: com.hyperling.minecraft.coderdojoevv.CoderDojoEVV
|
main: com.hyperling.minecraft.coderdojoevv.CoderDojoEVV
|
||||||
version: 0.1.6
|
version: 0.1.7
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
heal:
|
heal:
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: CoderDojoEVV
|
name: CoderDojoEVV
|
||||||
main: com.hyperling.minecraft.coderdojoevv.CoderDojoEVV
|
main: com.hyperling.minecraft.coderdojoevv.CoderDojoEVV
|
||||||
version: 0.1.6
|
version: 0.1.7
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
heal:
|
heal:
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#Generated by Maven
|
#Generated by Maven
|
||||||
#Fri Dec 28 11:40:41 CST 2018
|
#Fri Dec 28 12:13:17 CST 2018
|
||||||
version=0.1.6-SNAPSHOT
|
version=0.1.7-SNAPSHOT
|
||||||
groupId=com.hyperling.minecraft
|
groupId=com.hyperling.minecraft
|
||||||
artifactId=CoderDojoEVV
|
artifactId=CoderDojoEVV
|
||||||
|
Reference in New Issue
Block a user