-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 39c5deb
Showing
10 changed files
with
317 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="src" output="target/classes" path="src/main/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="src" output="target/test-classes" path="src/test/java"> | ||
<attributes> | ||
<attribute name="optional" value="true"/> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
<attribute name="test" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> | ||
<attributes> | ||
<attribute name="maven.pomderived" value="true"/> | ||
</attributes> | ||
</classpathentry> | ||
<classpathentry kind="output" path="target/classes"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
.metadata | ||
bin/ | ||
tmp/ | ||
*.tmp | ||
*.bak | ||
*.swp | ||
*~.nib | ||
local.properties | ||
.settings/ | ||
.loadpath | ||
.recommenders | ||
|
||
# External tool builders | ||
.externalToolBuilders/ | ||
|
||
# Locally stored "Eclipse launch configurations" | ||
*.launch | ||
|
||
# PyDev specific (Python IDE for Eclipse) | ||
*.pydevproject | ||
|
||
# CDT-specific (C/C++ Development Tooling) | ||
.cproject | ||
|
||
# CDT- autotools | ||
.autotools | ||
|
||
# Java annotation processor (APT) | ||
.factorypath | ||
|
||
# PDT-specific (PHP Development Tools) | ||
.buildpath | ||
|
||
# sbteclipse plugin | ||
.target | ||
|
||
# Tern plugin | ||
.tern-project | ||
|
||
# TeXlipse plugin | ||
.texlipse | ||
|
||
# STS (Spring Tool Suite) | ||
.springBeans | ||
|
||
# Code Recommenders | ||
.recommenders/ | ||
|
||
# Annotation Processing | ||
.apt_generated/ | ||
|
||
# Scala IDE specific (Scala & Java development for Eclipse) | ||
.cache-main | ||
.scala_dependencies | ||
.worksheet | ||
|
||
# Target | ||
target/ | ||
|
||
# Mac OSX | ||
.DS_Store |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>SilkableSpawners</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.m2e.core.maven2Builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.m2e.core.maven2Nature</nature> | ||
</natures> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# SilkableSpawners | ||
###### Mine mob spawners with a diamond silktouch pickaxe | ||
|
||
## Permissions | ||
| Permission | Description | | ||
|--------------------------|---------------------------------------------------------------| | ||
| `silkablespawners.*` | Gives access to all SilkableSpawners commands | | ||
| `silkablespawners.break` | Allows you to mine a spawner with a diamond silktouch pickaxe | | ||
| `silkablespawners.place` | Allows you to place a mined spawner | | ||
|
||
## Authors | ||
- [Tjeu Foolen]("https://www.github.com/tjeufoolen") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<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> | ||
<groupId>dev.foolen.silkablespawners</groupId> | ||
<artifactId>SilkableSpawners</artifactId> | ||
<version>1.0</version> | ||
|
||
<properties> | ||
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>1.8</maven.compiler.target> | ||
</properties> | ||
|
||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url> | ||
</repository> | ||
</repositories> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.14.2-R0.1-SNAPSHOT</version> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
17 changes: 17 additions & 0 deletions
17
src/main/java/dev/foolen/silkablespawners/SilkableSpawners.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.foolen.silkablespawners; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import dev.foolen.silkablespawners.events.EventHandler; | ||
|
||
public class SilkableSpawners extends JavaPlugin { | ||
|
||
public static final String PREFIX = ChatColor.BLUE + "[SilkableSpawners] " + ChatColor.GRAY; | ||
|
||
@Override | ||
public void onEnable() { | ||
// Events | ||
new EventHandler(this); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/dev/foolen/silkablespawners/events/EventHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package dev.foolen.silkablespawners.events; | ||
|
||
import org.bukkit.plugin.PluginManager; | ||
|
||
import dev.foolen.silkablespawners.SilkableSpawners; | ||
import dev.foolen.silkablespawners.events.listeners.OnBlockBreakEvent; | ||
import dev.foolen.silkablespawners.events.listeners.OnBlockPlaceEvent; | ||
|
||
public class EventHandler { | ||
|
||
public EventHandler(SilkableSpawners plugin) { | ||
PluginManager pm = plugin.getServer().getPluginManager(); | ||
|
||
pm.registerEvents(new OnBlockBreakEvent(), plugin); | ||
pm.registerEvents(new OnBlockPlaceEvent(), plugin); | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/java/dev/foolen/silkablespawners/events/listeners/OnBlockBreakEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package dev.foolen.silkablespawners.events.listeners; | ||
|
||
import java.util.Arrays; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.CreatureSpawner; | ||
import org.bukkit.enchantments.Enchantment; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockBreakEvent; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
import dev.foolen.silkablespawners.SilkableSpawners; | ||
|
||
public class OnBlockBreakEvent implements Listener { | ||
|
||
@EventHandler | ||
public void onBlockBreakEvent(BlockBreakEvent e) { | ||
Player player = e.getPlayer(); | ||
|
||
// Check if player has permission | ||
if (player.hasPermission("silkablespawners.break")) { | ||
// Check if broken block is a spawner | ||
if (e.getBlock().getType() == Material.SPAWNER) { | ||
// Check if block is broken by a diamond pickaxe with silktouch | ||
if (player.getInventory().getItemInMainHand().getType() == Material.DIAMOND_PICKAXE && player | ||
.getInventory().getItemInMainHand().getEnchantments().containsKey(Enchantment.SILK_TOUCH)) { | ||
|
||
// get spawner meta data | ||
CreatureSpawner creatureSpawner = (CreatureSpawner) e.getBlock().getState(); | ||
ItemStack spawnerItem = new ItemStack(e.getBlock().getType(), 1); | ||
ItemMeta spawnerMeta = spawnerItem.getItemMeta(); | ||
|
||
// Set item meta | ||
spawnerMeta.setDisplayName(ChatColor.BLUE + "" + ChatColor.BOLD + "" | ||
+ creatureSpawner.getSpawnedType().toString() + " Spawner"); | ||
spawnerMeta.setLore(Arrays.asList(ChatColor.GRAY + "Obtained by " + player.getName() + ".")); | ||
spawnerItem.setItemMeta(spawnerMeta); | ||
|
||
e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation(), spawnerItem); | ||
player.sendMessage(SilkableSpawners.PREFIX + "You've mined a spawner with silk touch."); | ||
} | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/dev/foolen/silkablespawners/events/listeners/OnBlockPlaceEvent.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package dev.foolen.silkablespawners.events.listeners; | ||
|
||
import org.bukkit.ChatColor; | ||
import org.bukkit.Material; | ||
import org.bukkit.block.CreatureSpawner; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.block.BlockPlaceEvent; | ||
|
||
import dev.foolen.silkablespawners.SilkableSpawners; | ||
|
||
public class OnBlockPlaceEvent implements Listener { | ||
|
||
@EventHandler | ||
public void onBlockPlaceEvent(BlockPlaceEvent e) { | ||
Player player = e.getPlayer(); | ||
|
||
// Check if player has permission | ||
if (player.hasPermission("silkablespawners.place")) { | ||
// Check if placed block is spawner | ||
if (e.getBlock().getType() == Material.SPAWNER) { | ||
// Check if spawner has custom name | ||
if (e.getItemInHand().getItemMeta().getLore() != null) { | ||
|
||
String entityName = ChatColor.stripColor(e.getItemInHand().getItemMeta().getDisplayName()) | ||
.split(" ")[0]; | ||
EntityType entity = EntityType.valueOf(entityName); | ||
|
||
CreatureSpawner spawner = (CreatureSpawner) e.getBlockPlaced().getState(); | ||
spawner.setSpawnedType(entity); | ||
spawner.update(); | ||
e.getPlayer().sendMessage( | ||
SilkableSpawners.PREFIX + "Your " + entityName.toLowerCase() + " spawner has been placed!"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: SilkableSpawners | ||
main: dev.foolen.silkablespawners.SilkableSpawners | ||
version: 1.0 | ||
author: Tjeu Foolen | ||
api-version: 1.13 | ||
|
||
permissions: | ||
silkablespawners.*: | ||
description: Gives access to all SilkableSpawners commands | ||
children: | ||
silkablespawners.break: true | ||
silkablespawners.place: true | ||
silkablespawners.break: | ||
description: Allows you to mine a spawner with a diamond silktouch pickaxe | ||
default: op | ||
silkablespawners.place: | ||
description: Allows you to place a mined spawner | ||
default: op |