Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Allow for the altering of the initial velocity of ender pearls

  • Loading branch information...
commit 5a95be02e45df8b3e5265b0f0070be567e507ca6 1 parent d347257
@shadowjay1 shadowjay1 authored committed
View
2  README.md
@@ -27,6 +27,7 @@ Minecraft server plug-in: Simply toggles various functionality
- Removes the Enchanted Golden Apple recipe.
- Converts Enchanted Golden Apples to normal Golden Apples if a Player attempts to eat them.
- Disables Ender Pearl Teleportation
+- Alters the initial velocity of Ender Pearls
- Alters the drop rate of wither skulls
- Removes specific items from dropping when a mob is killed
- Prevents records from playing in jukeboxes
@@ -63,6 +64,7 @@ Config file settings:
- fix_vehicle_logout_bug: Boolean, Fixes a teleport bug when players logout in vehicles
- player_max_health: Integer, sets all Player maximum health
- ender_pearl_teleportation: Boolean, Turns on Ender Pearl teleportation
+- ender_pearl_launch_velocity: Double, Alters initial velocity of Ender Pearls
- ench_gold_app_edible: Boolean, Allows players to eat Enchanted Golden Apples. If false, Enchanted Golden Apples are converted to normal Golden Apples
- ench_gold_app_craftable: Boolean, Allows the Enchanted Golden Apple recipe to be used
- wither_skull_drop_rate: Integer between -1 and 1000000, -1 is standard behavior. If a random number [0, 1000000) is less then this value, a wither skull drops. For example, 200000 is a 20% drop rate.
View
9 src/main/java/com/untamedears/humbug/Config.java
@@ -44,6 +44,7 @@
private static final int wither_skull_drop_rate_ = -1;
private static final int player_max_health_ = 20;
private static final boolean ender_pearl_teleportation_enabled_ = true;
+ private static final double ender_pearl_launch_velocity_ = 1.0F;
private static final boolean ench_gold_app_edible_ = false;
private static final boolean ench_gold_app_craftable_ = false;
// For fixing the teleport glitch
@@ -340,6 +341,14 @@ public boolean getEnderPearlTeleportationEnabled() {
public void setEnderPearlTeleportationEnabled(boolean value) {
config_.set("ender_pearl_teleportation", value);
}
+
+ public double getEnderPearlLaunchVelocity() {
+ return config_.getDouble("ender_pearl_launch_velocity", ender_pearl_launch_velocity_);
+ }
+
+ public void setEnderPearlLaunchVelocity(double value) {
+ config_.set("ender_pearl_launch_velocity", value);
+ }
public boolean getDisallowRecordPlaying() {
return config_.getBoolean("disallow_record_playing", disallow_record_playing_);
View
42 src/main/java/com/untamedears/humbug/Humbug.java
@@ -22,10 +22,12 @@
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.enchantments.Enchantment;
+import org.bukkit.entity.EnderPearl;
import org.bukkit.entity.Enderman;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
+import org.bukkit.entity.Projectile;
import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
import org.bukkit.event.EventHandler;
@@ -35,19 +37,20 @@
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockFromToEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
-import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.block.BlockPistonExtendEvent;
+import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.enchantment.EnchantItemEvent;
import org.bukkit.event.enchantment.PrepareItemEnchantEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import org.bukkit.event.entity.EntityCreatePortalEvent;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDeathEvent;
-import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
+import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent;
+import org.bukkit.event.entity.PlayerDeathEvent;
+import org.bukkit.event.entity.ProjectileLaunchEvent;
import org.bukkit.event.entity.SheepDyeWoolEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
@@ -66,8 +69,6 @@
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
-import com.untamedears.humbug.Config;
-
public class Humbug extends JavaPlugin implements Listener {
public static void severe(String message) {
log_.severe("[Humbug] " + message);
@@ -1021,6 +1022,24 @@ public void onEntityShootBow(EntityShootBowEvent event) {
((Player)event.getEntity()).getName(),
ench_level);
}
+
+ // ================================================
+ // Change ender pearl velocity!
+
+ @EventHandler
+ public void onEnderPearlThrow(ProjectileLaunchEvent event) {
+ double velocity = config_.getEnderPearlLaunchVelocity();
+
+ if(velocity == 1) {
+ return;
+ }
+
+ Projectile entity = event.getEntity();
+
+ if(entity instanceof EnderPearl) {
+ entity.setVelocity(entity.getVelocity().multiply(velocity));
+ }
+ }
// ================================================
// General
@@ -1052,6 +1071,14 @@ public int toInt(String value, int default_value) {
return default_value;
}
}
+
+ public double toDouble(String value, double default_value) {
+ try {
+ return Double.parseDouble(value);
+ } catch(Exception e) {
+ return default_value;
+ }
+ }
public int toMaterialId(String value, int default_value) {
try {
@@ -1244,6 +1271,11 @@ public boolean onCommand(
config_.setEnderPearlTeleportationEnabled(toBool(value));
}
msg = String.format("ender_pearl_teleportation = %s", config_.getEnderPearlTeleportationEnabled());
+ } else if (option.equals("ender_pearl_launch_velocity")) {
+ if (set) {
+ config_.setEnderPearlLaunchVelocity(toDouble(value, 1));
+ }
+ msg = String.format("ender_pearl_launch_velocity = %s", config_.getEnderPearlLaunchVelocity());
} else if (option.equals("disallow_record_playing")) {
if (set) {
config_.setDisallowRecordPlaying(toBool(value));
Please sign in to comment.
Something went wrong with that request. Please try again.