Skip to content

Commit

Permalink
Version 1.14.3-beta2
Browse files Browse the repository at this point in the history
- Add option to have a minimum number of passable blocks above player
  to allow other to ride him (default = 1)
- Prevent players to ride players who sleep, glide, swim or in vehicle
  (to prevent glitches like reported by Minestick)
- Remove Herobrine
  • Loading branch information
arboriginal committed Dec 7, 2019
1 parent e0d64ff commit 03a67a5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.github.arboriginal</groupId>
<artifactId>PlayerRider</artifactId>
<version>1.14.3-beta</version>
<version>1.14.3-beta2</version>

<developers>
<developer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ private void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
return;
}

if (!PRUtils.playerAllowed(player, "ride") || !PRUtils.rideIsActivated(duck) || player.isInsideVehicle())
if (player.isInsideVehicle() || !PRUtils.playerAllowed(player, "ride")
|| !PRUtils.isRidable(duck) || !PRUtils.rideIsActivated(duck))
return;

ItemStack item = player.getInventory().getItemInMainHand();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class PROptions {
eject_when_hurt, getoff_when_hurt, prevent_hit_rider, prevent_suffocation;
double boost_maxPitch, bossbar_pct, eject_maxPitch, hide_rider_maxPitch;
float boost_whip_pitch, boost_whip_volume;
int boost_amplifier, boost_duration;
int boost_amplifier, boost_duration, min_above_blocks;
Sound boost_whip_sound;
String bossbar_title, file_not_writable_err, potion_effect_err;

Expand Down Expand Up @@ -55,8 +55,9 @@ class PROptions {
boost_whip_pitch = (float) PR.config.getDouble("boost_whip_pitch");
boost_whip_volume = (float) PR.config.getDouble("boost_whip_volume");
// Integer values
boost_amplifier = PR.config.getInt("boost_amplifier");
boost_duration = PR.config.getInt("boost_duration");
boost_amplifier = PR.config.getInt("boost_amplifier");
boost_duration = PR.config.getInt("boost_duration");
min_above_blocks = PR.config.getInt("min_above_blocks") + 2;
// Sound values
boost_whip_sound = (boost_whip_volume > 0) ? (Sound) getEnumValue(Sound.class, "boost_whip_sound") : null;
// String values
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/github/arboriginal/PlayerRider/PRUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
Expand Down Expand Up @@ -98,6 +101,18 @@ static boolean isPlayer(Entity entity) {
return (entity instanceof Player) && !entity.hasMetadata("NPC");
}

static boolean isRidable(Player player) {
if (player.isGliding() || player.isSleeping() || player.isSwimming()
|| (player.isInsideVehicle() && player.getVehicle().getType() != EntityType.PLAYER))
return false;

Block b = player.getLocation().getBlock();
for (int i = 1; i < PR.options.min_above_blocks; i++)
if (!b.getRelative(BlockFace.UP, i).isPassable()) return false;

return true;
}

static boolean playerAllowed(Player player, String key) {
return player.hasPermission("playerrider." + key) || player.hasPermission("playerrider." + key + ".keepitem");
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,7 @@ affect_whipped_player:
inc: 1
max: 1
duration: 60

##### New in version 1.14.3 #####
min_above_blocks: 1 # (integer) Number of minimum "passable" blocks above a player to let other ride him
# (passable blocks are blocks the player can pass through, like AIR or grass for example).

0 comments on commit 03a67a5

Please sign in to comment.