diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..a208105 --- /dev/null +++ b/pom.xml @@ -0,0 +1,47 @@ + + 4.0.0 + com.hyperling.minecraft + CoderDojoTest + 0.1.3-SNAPSHOT + Coder Dojo Test + Test project written to learn how to do Minecraft plug-in for Coder Dojo. + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.7 + 1.7 + + + + + + + + spigot-repo + https://hub.spigotmc.org/nexus/content/repositories/snapshots/ + + + + + + org.bukkit + bukkit + 1.12.2-R0.1-SNAPSHOT + jar + provided + + + + org.spigotmc + spigot-api + 1.12.2-R0.1-SNAPSHOT + jar + provided + + + + \ No newline at end of file diff --git a/src/main/java/com/hyperling/minecraft/coderdojotest/CoderDojoTest.java b/src/main/java/com/hyperling/minecraft/coderdojotest/CoderDojoTest.java new file mode 100644 index 0000000..fb8395a --- /dev/null +++ b/src/main/java/com/hyperling/minecraft/coderdojotest/CoderDojoTest.java @@ -0,0 +1,84 @@ +package com.hyperling.minecraft.coderdojotest; + +import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.Material; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; +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.PlayerInventory; +import org.bukkit.plugin.java.JavaPlugin; + +public final class CoderDojoTest extends JavaPlugin implements Listener { + public CoderDojoTest() { + + } + + @Override + public void onEnable() { + getLogger().info("onEnable has been accessed."); + getServer().getPluginManager().registerEvents(this, this); + } + + @Override + public void onDisable() { + getLogger().info("onDisable has been accessed."); + } + + @EventHandler + public void onJoin(PlayerJoinEvent event) { + getLogger().info("Running onJoin."); + Player player = event.getPlayer(); + + getServer().broadcastMessage("Welcome to the server, " + player.getDisplayName() + "!"); + + final PlayerInventory inv = player.getInventory(); + + // Give diamond tools and food if not in creative + if (getServer().getDefaultGameMode() != GameMode.CREATIVE) { + getServer().broadcastMessage("Enjoy your items!"); + ItemStack item; + item = new ItemStack(Material.DIAMOND_SWORD); + inv.remove(Material.DIAMOND_SWORD); + inv.addItem(item); + item = new ItemStack(Material.DIAMOND_AXE); + inv.remove(Material.DIAMOND_AXE); + inv.addItem(item); + item = new ItemStack(Material.DIAMOND_PICKAXE); + inv.remove(Material.DIAMOND_PICKAXE); + inv.addItem(item); + item = new ItemStack(Material.DIAMOND_SPADE); + inv.remove(Material.DIAMOND_SPADE); + inv.addItem(item); + item = new ItemStack(Material.DIAMOND_HOE); + inv.remove(Material.DIAMOND_HOE); + inv.addItem(item); + + // Give food + item = new ItemStack(Material.GOLDEN_APPLE); + inv.remove(Material.GOLDEN_APPLE); + item.setAmount(64); + inv.addItem(item); + + // These work + item = new ItemStack(Material.DIAMOND_BOOTS); + inv.setBoots(item); + item = new ItemStack(Material.DIAMOND_LEGGINGS); + inv.setLeggings(item); + item = new ItemStack(Material.DIAMOND_CHESTPLATE); + inv.setChestplate(item); + item = new ItemStack(Material.DIAMOND_HELMET); + inv.setHelmet(item); + } + else { + inv.clear(); + getServer().broadcastMessage("Inventory has been cleared for Creative mode."); + } + + getLogger().info("Refreshed diamond items."); + } +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml new file mode 100644 index 0000000..2257280 --- /dev/null +++ b/src/main/resources/plugin.yml @@ -0,0 +1,3 @@ +name: CoderDojoTest +main: com.hyperling.minecraft.coderdojotest.CoderDojoTest +version: 0.1.2 \ No newline at end of file diff --git a/target/CoderDojoTest-0.1.3-SNAPSHOT.jar b/target/CoderDojoTest-0.1.3-SNAPSHOT.jar new file mode 100644 index 0000000..d46a0b5 Binary files /dev/null and b/target/CoderDojoTest-0.1.3-SNAPSHOT.jar differ diff --git a/target/classes/com/hyperling/minecraft/coderdojotest/CoderDojoTest.class b/target/classes/com/hyperling/minecraft/coderdojotest/CoderDojoTest.class new file mode 100644 index 0000000..237b1c6 Binary files /dev/null and b/target/classes/com/hyperling/minecraft/coderdojotest/CoderDojoTest.class differ diff --git a/target/classes/plugin.yml b/target/classes/plugin.yml new file mode 100644 index 0000000..2257280 --- /dev/null +++ b/target/classes/plugin.yml @@ -0,0 +1,3 @@ +name: CoderDojoTest +main: com.hyperling.minecraft.coderdojotest.CoderDojoTest +version: 0.1.2 \ No newline at end of file diff --git a/target/maven-archiver/pom.properties b/target/maven-archiver/pom.properties new file mode 100644 index 0000000..debb43c --- /dev/null +++ b/target/maven-archiver/pom.properties @@ -0,0 +1,5 @@ +#Generated by Maven +#Thu Dec 27 10:04:47 CST 2018 +version=0.1.3-SNAPSHOT +groupId=com.hyperling.minecraft +artifactId=CoderDojoTest diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst new file mode 100644 index 0000000..e69de29 diff --git a/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst new file mode 100644 index 0000000..3ea79a7 --- /dev/null +++ b/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst @@ -0,0 +1 @@ +/home/ling/Programs/eclipse-workspace/CoderDojoTest/src/main/java/com/hyperling/minecraft/coderdojotest/CoderDojoTest.java diff --git a/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst new file mode 100644 index 0000000..e69de29