-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
8 changed files
with
309 additions
and
2 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
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
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,55 @@ | ||
NerdAnim | ||
======== | ||
A Bukkit plugin that handles custom mob spawning. | ||
|
||
|
||
Features | ||
-------- | ||
Currently this is just a small plugin that restores Minecraft 1.10 wither | ||
skeleton spawning behaviour to 1.11 survival mode servers. In specific terms, it | ||
replaces a configurable percentage of skeletons spawned in the PLAINS biome in | ||
the NETHER environement with wither skeletons. | ||
|
||
Time permitting, this plugin may be expanded to be a more general custom-mob | ||
spawning system with facilities like OtherDrops (currently defunct) or | ||
MythicMobs. | ||
|
||
The design principles for expanding the capabilities of the plugin would be: | ||
|
||
* No reliance on NMS classes, since that presents a maintenance obstacle. | ||
* Loose coupling to other plugins (soft dependencies only). | ||
* As much as possible, in-game configuration only: mob types, including their | ||
equipment should be designable in-game with minimal commands and no | ||
configuration editing. Their spawnable areas should be defined in-game as | ||
spheres or rectangular prisms from a specified location. | ||
* Complex configuration languages should be avoided; YAML should not be abused | ||
for this purpose: most Bukkit plugin configuration languages based on YAML | ||
have horrible, quirky, poorly documented syntax. OtherDrops and MythicMobs | ||
are prime examples of this. The YAML parser in Bukkit is extremely | ||
unforgiving of minor syntax errors. Instead of YAML, the configuration | ||
language, which would be used mostly for configurating mob *behaviours*, | ||
should use a pre-existing Java implementation of an established scripting | ||
language like Lua, Python (Jython) or Groovy to set properties of a | ||
well-documented object model. | ||
|
||
|
||
Commands | ||
-------- | ||
|
||
* `/beastmaster reload` - Reload the plugin configuration. | ||
|
||
|
||
Configuration | ||
------------- | ||
|
||
| Setting | Description | | ||
| :--- | :--- | | ||
| `debug.config` | If true, log the configuration on reload. | | ||
| `debug.replace` | If true, log replacement of skeletons by wither skeletons. | | ||
| `chance.wither-skeleton` | Probability, in the range [0.0,1.0] that a plains biome skeleton spawn in the nether environment will be replaced by a wither skeleton. | | ||
|
||
|
||
Permissions | ||
----------- | ||
|
||
* `beastmaster.admin` - Permission to administer the plugin (run `/beastmaster reload`). |
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,6 @@ | ||
debug: | ||
config: false | ||
replace: false | ||
|
||
chance: | ||
wither-skeleton: 0.8 |
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,22 @@ | ||
name: ${project.name} | ||
version: ${project.version} | ||
author: totemo | ||
authors: [] | ||
description: ${project.description} | ||
website: ${project.url} | ||
database: true | ||
main: nu.nerd.beastmaster.BeastMaster | ||
|
||
permissions: | ||
beastmaster.admin: | ||
description: Permission to administer the plugin. | ||
default: op | ||
|
||
commands: | ||
beastmaster: | ||
description: ${project.name} administrative command. | ||
permission: beastmaster.admin | ||
usage: | | ||
§e/<command> help§f - Show usage help. | ||
§e/<command> reload§f - Reload the configuration. |
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,71 @@ | ||
<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>nu.nerd</groupId> | ||
<name>BeastMaster</name> | ||
<artifactId>${project.name}</artifactId> | ||
<version>1.0.0</version> | ||
<packaging>jar</packaging> | ||
<description>Handles custom mob spawning.</description> | ||
<url>https://github.com/NerdNu/${project.name}</url> | ||
<scm> | ||
<connection>scm:git:git://github.com/NerdNu/${project.name}.git</connection> | ||
<url>https://github.com/NerdNu/${project.name}</url> | ||
<developerConnection>scm:git:git://github.com/NerdNu/${project.name}.git</developerConnection> | ||
</scm> | ||
<properties> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
<repositories> | ||
<repository> | ||
<id>spigot-repo</id> | ||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url> | ||
</repository> | ||
</repositories> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.spigotmc</groupId> | ||
<artifactId>spigot-api</artifactId> | ||
<version>1.11.2-R0.1-SNAPSHOT</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<defaultGoal>clean package</defaultGoal> | ||
<sourceDirectory>${basedir}/src</sourceDirectory> | ||
<resources> | ||
<resource> | ||
<targetPath>.</targetPath> | ||
<filtering>true</filtering> | ||
<directory>${basedir}</directory> | ||
<includes> | ||
<include>plugin.yml</include> | ||
<include>config.yml</include> | ||
</includes> | ||
</resource> | ||
</resources> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>2.1</version> | ||
<configuration> | ||
<archive> | ||
<addMavenDescriptor>false</addMavenDescriptor> | ||
</archive> | ||
<finalName>${project.artifactId}-${project.version}</finalName> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>2.0.2</version> | ||
<configuration> | ||
<source>1.8</source> | ||
<target>1.8</target> | ||
</configuration> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |
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,95 @@ | ||
package nu.nerd.beastmaster; | ||
|
||
import org.bukkit.Bukkit; | ||
import org.bukkit.Location; | ||
import org.bukkit.World; | ||
import org.bukkit.World.Environment; | ||
import org.bukkit.block.Biome; | ||
import org.bukkit.command.Command; | ||
import org.bukkit.command.CommandSender; | ||
import org.bukkit.entity.EntityType; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.entity.CreatureSpawnEvent; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import net.md_5.bungee.api.ChatColor; | ||
|
||
// ---------------------------------------------------------------------------- | ||
/** | ||
* Plugin, command handling and event handler class. | ||
*/ | ||
public class BeastMaster extends JavaPlugin implements Listener { | ||
// ------------------------------------------------------------------------ | ||
/** | ||
* Configuration wrapper instance. | ||
*/ | ||
public static Configuration CONFIG = new Configuration(); | ||
|
||
/** | ||
* This plugin, accessible as, effectively, a singleton. | ||
*/ | ||
public static BeastMaster PLUGIN; | ||
|
||
// ------------------------------------------------------------------------ | ||
/** | ||
* @see org.bukkit.plugin.java.JavaPlugin#onEnable() | ||
*/ | ||
@Override | ||
public void onEnable() { | ||
PLUGIN = this; | ||
saveDefaultConfig(); | ||
CONFIG.reload(); | ||
|
||
getServer().getPluginManager().registerEvents(this, this); | ||
} | ||
|
||
// ------------------------------------------------------------------------ | ||
/** | ||
* @see org.bukkit.plugin.java.JavaPlugin#onDisable() | ||
*/ | ||
@Override | ||
public void onDisable() { | ||
Bukkit.getScheduler().cancelTasks(this); | ||
} | ||
|
||
// ------------------------------------------------------------------------ | ||
/** | ||
* @see org.bukkit.plugin.java.JavaPlugin#onCommand(org.bukkit.command.CommandSender, | ||
* org.bukkit.command.Command, java.lang.String, java.lang.String[]) | ||
*/ | ||
@Override | ||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { | ||
if (args.length != 1 || args[0].equalsIgnoreCase("help")) { | ||
return false; | ||
} | ||
|
||
if (args.length == 1 && args[0].equalsIgnoreCase("reload")) { | ||
CONFIG.reload(); | ||
sender.sendMessage(ChatColor.GOLD + getName() + " configuration reloaded."); | ||
} | ||
return true; | ||
} | ||
|
||
// ------------------------------------------------------------------------ | ||
/** | ||
* In the plains biome in the nether environment, replace the configured | ||
* percentage of Skeletons with WitherSkeletons. | ||
*/ | ||
@EventHandler(ignoreCancelled = true) | ||
public void onCreatureSpawn(CreatureSpawnEvent event) { | ||
Location loc = event.getLocation(); | ||
World world = loc.getWorld(); | ||
if (world.getEnvironment() == Environment.NETHER && | ||
loc.getBlock().getBiome() == Biome.PLAINS && | ||
event.getEntityType() == EntityType.SKELETON && | ||
Math.random() < CONFIG.CHANCE_WITHER_SKELETON) { | ||
if (CONFIG.DEBUG_REPLACE) { | ||
getLogger().info(String.format("Replacing skeleton at (%d, %d, %d, %s) with wither skeleton.", | ||
loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), loc.getWorld().getName())); | ||
} | ||
event.getEntity().remove(); | ||
world.spawnEntity(loc, EntityType.WITHER_SKELETON); | ||
} | ||
} | ||
} // class BeastMaster |
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 nu.nerd.beastmaster; | ||
|
||
import java.util.logging.Logger; | ||
|
||
import org.bukkit.configuration.file.FileConfiguration; | ||
|
||
// ---------------------------------------------------------------------------- | ||
/** | ||
* Reads and exposes the plugin configuration. | ||
*/ | ||
public class Configuration { | ||
// ------------------------------------------------------------------------ | ||
/** | ||
* If true, log the configuration on reload. | ||
*/ | ||
public boolean DEBUG_CONFIG; | ||
|
||
/** | ||
* If true, log replacement of skeletons by wither skeletons. | ||
*/ | ||
public boolean DEBUG_REPLACE; | ||
|
||
/** | ||
* Probability, in the range [0.0,1.0] that a plains biome skeleton spawn in | ||
* the nether environment will be replaced by a wither skeleton. | ||
*/ | ||
public double CHANCE_WITHER_SKELETON; | ||
|
||
// ------------------------------------------------------------------------ | ||
/** | ||
* Load the plugin configuration. | ||
*/ | ||
public void reload() { | ||
BeastMaster.PLUGIN.reloadConfig(); | ||
FileConfiguration config = BeastMaster.PLUGIN.getConfig(); | ||
DEBUG_CONFIG = config.getBoolean("debug.config"); | ||
DEBUG_REPLACE = config.getBoolean("debug.replace"); | ||
CHANCE_WITHER_SKELETON = config.getDouble("chance.wither-skeleton"); | ||
|
||
Logger logger = BeastMaster.PLUGIN.getLogger(); | ||
if (DEBUG_CONFIG) { | ||
logger.info("Configuration:"); | ||
logger.info("DEBUG_REPLACE: " + DEBUG_REPLACE); | ||
logger.info("CHANCE_WITHER_SKELETON: " + CHANCE_WITHER_SKELETON); | ||
} | ||
} // reload | ||
|
||
// ------------------------------------------------------------------------ | ||
} // class Configuration |