Skip to content

Commit

Permalink
Apply formatting changes
Browse files Browse the repository at this point in the history
Changed files:
build.gradle
README.md
Command.java
SpawnPets.java
  • Loading branch information
Magnum97 committed May 19, 2020
1 parent f99aa5a commit 3fc41ca
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 37 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
# BreedablePetsMC
Breed parrots and polar bears. Customize the food/item you use to tame each mob.
Breed animals that are not normally breed-able in Minecraft.

**Breedable Pets** is a [Minecraft](http://minecraft.net) server plugin for [Bukkit](http://http://bukkit.org) / [Spigot](http://spigotmc.org) / [Paper](http://papermc.io) that allows you to breed animals that are not usually breedable.


**Breedable Pets** is a [Minecraft](http://minecraft.net) server plugin for [Bukkit](http://http://bukkit.org) / [Spigot](http://spigotmc.org) / [Paper](http://papermc.io) that allows you to breed animals that are not usually breed-able.

### Installation

Drop the jar in your plugins folder and start the server.
Download jar from the [releases](https://github.com/Magnum97/BreedablePetsMC/releases) page and put it in your server's `plugins/` folder, then start the server.
Optionally you can compile it yourself.

## Usage
There is only one command, `/breedablepets` alias `/bp`. Sub commands are:
Expand All @@ -15,7 +18,7 @@ There is only one command, `/breedablepets` alias `/bp`. Sub commands are:

For settings see [config.yml](https://github.com/Magnum97/BreedablePetsMC/blob/master/src/main/resources/config.yml)\
I tried to put all options in there. Some are not implemented yet. \
Currently only parrots are breedable. You must feed them seeds *other* than wheat. Wheat seeds are still used for taming wild parrots. Foods are hard coded but plan to move to config in a future version.
Currently only parrots are breed-able. You must feed them seeds *other* than wheat. Wheat seeds are still used for taming wild parrots. Foods are hard coded but plan to move to config in a future version.

### Contributing
This is a pretty basic plugin. If you have any thoughts, good or bad, I would like them or any suggestions for features or improvements.\
Expand Down
37 changes: 19 additions & 18 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ plugins {
id 'com.github.johnrengelman.shadow' version '5.1.0'
}

group= 'me.magnum' // Put your groupId here
version= '1.3.1a' // Put your version here
group = 'me.magnum' // Put your groupId here
version = '1.3.1a' // Put your version here
archivesBaseName = 'BreedablePets' // Put your artifactId here
mainClassName = 'me.magnum.breedablepets.Main'
mainClassName = 'me.magnum.Breedable'
targetCompatibility = 1.8
sourceCompatibility = 1.8

// See https://github.com/EntryPointKR/Spigradle#repositories for repository shortcodes
repositories {
mavenLocal()
// mavenLocal()
mavenCentral()
paper()
enderZone()
Expand All @@ -32,9 +32,10 @@ repositories {
dependencies {
compileOnly spigot('1.15.2')
implementation 'fr.mrmicky:FastParticles:1.2.0'
implementation 'com.github.JavaFactoryDev:LightningStorage:3.0.3'
implementation files ('/home/rich/.m2/repository/com/github/javafactorydev/lightningstorage/3.1.1-SNAPSHOT/lightningstorage-3.1.1-SNAPSHOT.jar')
// implementation 'com.github.JavaFactoryDev:LightningStorage:3.1.1-SNAPSHOT'
implementation "co.aikar:acf-bukkit:0.5.0-SNAPSHOT"
implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library
// implementation 'com.github.kangarko:Foundation:5.3.8@jar' // Kangerko's Foundation library

}
compileJava {
Expand All @@ -47,33 +48,33 @@ task relocateShadowJar(type: ConfigureShadowRelocation) {
prefix = "shadow" // Default value is "shadow"

}
tasks.shadowJar.dependsOn tasks.relocateShadowJar
shadowJar {
classifier = null // remove -all from end of jar
}
// TODO Create plugin.yml with correct info
spigot {
authors = ['Magnum1997']
// depends = ['ProtocolLib']
apiVersion = '1.15'
load = STARTUP
commands {
give {
aliases = ['i']
description = 'Give command.'
permission = 'test.foo'
permissionMessage = 'You do not have permission!'
usage = '/<command> [test|stop]'
breedablepets {
aliases = ['bp']
description = 'Main command for BreedablePets'
permission = 'breedablepets.command'
permissionMessage = 'You do not have permission: breedablepets.command'
usage = '/<command> [ help | parrotegg [fertile]]'
}
}
permissions {
'test.foo' {
description = 'Allows foo command'
defaults = 'true'
'breedablepets.command' {
description = 'Allows main command'
defaults = 'op'
}
'test.*' {
'breedablepets.*' {
description = 'Wildcard permission'
defaults = 'op'
children = ['test.foo': true]
children = ['breedablepets.command': true, 'breedablepets.command.parrot': true, 'breedabpepets.reload': true]
}
}
}
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/me/magnum/breedablepets/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

@CommandAlias("breedablepet|bp")
// TODO refine permissions
// ie. breedable.command breedable.command.parrot breedable.command.reload
@CommandAlias("breedablepets|bp")
public class Command extends BaseCommand {

@HelpCommand
Expand All @@ -45,7 +47,7 @@ public void onHelp (CommandSender sender, CommandHelp help) {

@Subcommand("parrotegg")
@Description("Get a parrot egg")
@CommandPermission("breedable.parrot.egg")
@CommandPermission("breedablepets.command.parrotegg")
public void onCommand (CommandSender sender, @Default("false") String fertile) {
ItemUtil util = new ItemUtil();
Player p = (Player) sender;
Expand All @@ -63,7 +65,7 @@ public void onCommand (CommandSender sender, @Default("false") String fertile) {
@Subcommand("reload")
@CommandPermission("breedable.reload")
public void onReload (CommandSender sender) {
Breedable.getCfg().reloadConfig();
Breedable.getPlugin().getCfg().forceReload();
}

@CommandAlias("sp")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public void onFeed (PlayerInteractEntityEvent pie) {
double y = target.getLocation().getY() + 1;
double z = target.getLocation().getZ();
if (hasMate) {
if (ThreadLocalRandom.current().nextInt(100) < (Breedable.getCfg().getInt("fertile-egg-chance"))) {
if (ThreadLocalRandom.current().nextInt(100) < (Breedable.getPlugin().getCfg().getInt("fertile-egg-chance"))) {
w.dropItemNaturally(loc, items.regEgg.clone());
// w.dropItemNaturally(loc, items.fertileEgg.clone()); // TODO To be fertile egg - disabled until single throw bug fixed
FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3);
Expand All @@ -122,7 +122,7 @@ public void onFeed (PlayerInteractEntityEvent pie) {
FastParticle.spawnParticle(w, ParticleType.HEART, x, y, z, 3);
}
else {
if (ThreadLocalRandom.current().nextInt(1, 101) < Breedable.getCfg().getInt("egg-chance")) {
if (ThreadLocalRandom.current().nextInt(1, 101) < Breedable.getPlugin().getCfg().getInt("egg-chance")) {
w.dropItemNaturally(loc, items.regEgg.clone());
FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, target.getLocation(), 3);
FastParticle.spawnParticle(target.getWorld(), ParticleType.HEART, x, y, z, 3);
Expand All @@ -133,7 +133,7 @@ public void onFeed (PlayerInteractEntityEvent pie) {

}
else {
if (ThreadLocalRandom.current().nextInt(100) < Breedable.getCfg().getInt("egg-change")) {
if (ThreadLocalRandom.current().nextInt(100) < Breedable.getPlugin().getCfg().getInt("egg-change")) {
FastParticle.spawnParticle(w, ParticleType.NOTE, target.getLocation(), 3, x, y, z);
// FastParticle.spawnParticle(w, ParticleType.NOTE, x, y, z, 1);
w.dropItemNaturally(loc, items.regEgg.clone());
Expand All @@ -147,20 +147,20 @@ private Integer foodCalc (Entity target, Material type) {
int chance = 0;
switch (type) {
case WHEAT_SEEDS:
chance = Breedable.getCfg().getInt("modifier.wheat");
chance = Breedable.getPlugin().getCfg().getInt("modifier.wheat");
break;
case BEETROOT_SEEDS:
chance = Breedable.getCfg().getInt("modifier.beetroot");
chance = Breedable.getPlugin().getCfg().getInt("modifier.beetroot");
break;
case PUMPKIN_SEEDS:
chance = Breedable.getCfg().getInt("modifier.pumpkin");
chance = Breedable.getPlugin().getCfg().getInt("modifier.pumpkin");
break;
case MELON_SEEDS:
chance = Breedable.getCfg().getInt("modifier.melon");
chance = Breedable.getPlugin().getCfg().getInt("modifier.melon");
break;
case GLISTERING_MELON_SLICE:
_MELON:
chance = Breedable.getCfg().getInt("modifier.glistering");
chance = Breedable.getPlugin().getCfg().getInt("modifier.glistering");
break;
}
return chance;
Expand Down
7 changes: 3 additions & 4 deletions src/main/java/me/magnum/breedablepets/util/SpawnPets.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
package me.magnum.breedablepets.util;

import me.magnum.Breedable;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
Expand All @@ -48,16 +47,16 @@ public static void newParrot (Player player, Location location) {
World world = player.getWorld();
location = world.getHighestBlockAt(location).getLocation().add(0,1,0);
Parrot parrot = (Parrot) world.spawnEntity(location, EntityType.PARROT);
parrot.setTamed(Breedable.getCfg().getBoolean("hatches.tamed"));
parrot.setTamed(Breedable.getPlugin().getCfg().getBoolean("hatches.tamed"));
parrot.setHealth(1); // TODO add to config
parrot.setVariant(Parrot.Variant.RED);
if (parrot.isTamed()) {
parrot.setOwner(player);
parrot.setSitting(true);
}
if (Breedable.getCfg().getBoolean("hatches.named")) {
if (Breedable.getPlugin().getCfg().getBoolean("hatches.named")) {
parrot.setCustomNameVisible(true);
parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Breedable.getCfg().getString("hatches.name"))));
parrot.setCustomName(ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(Breedable.getPlugin().getCfg().getString("hatches.name"))));
}
}
}

0 comments on commit 3fc41ca

Please sign in to comment.