Skip to content

Commit

Permalink
Version 1.14.2: New options + optimisations
Browse files Browse the repository at this point in the history
Changelog:
* You can now add potion effects on ridden player when mounted
* You can now add potion effects on ridden player when whipped
* Code refactoring to improve performances
  • Loading branch information
arboriginal committed Sep 29, 2019
1 parent 2cfb6af commit af9a4d1
Show file tree
Hide file tree
Showing 8 changed files with 703 additions and 498 deletions.
82 changes: 69 additions & 13 deletions src/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ toggleErr: "{prefix}&cUnable to toggle your ridability, contact an admin..."
# Messages sent to the player when using command /prider-toggle
statusOn: "{prefix}&aOther players can now ride you"
statusOff: "{prefix}&aOther players cannot ride you anymore"
# Error message when you use a potion effect with wrong parameters
effectErr: "{prefix}&cError with potion effect {type}"

# In the both 3 sections: (broadcast, player and duck)
# - sub-section "ride" is used when a player riders another
Expand All @@ -65,14 +67,6 @@ duck:
whip: "{prefix}&e&l{player}&b whipped you, do you like that?"
eject: "{prefix}&bYou've just ejected &e&l{player}&b, beware... I'm sure he will try again!"

# Bossbar displayed to ridden player
bossbar_on_ridden_player:
enabled: true
title: "{player} is ridding you!" # {player} will be replaced by the rider's name
color: YELLOW # Available values: BLUE, GREEN, PINK, PURPLE, RED, WHITE, YELLOW
style: SOLID # Available values: SOLID, SEGMENTED_6, SEGMENTED_10, SEGMENTED_12, SEGMENTED_20
progress: 1.0 # Between 0 and 1

# Cooldowns (in seconds)
cooldowns:
ride:
Expand Down Expand Up @@ -125,11 +119,6 @@ consume_items:
ride: false
whip: true

# Disabled worlds (you can use « [] > to represents an empty list)
disabled_worlds:
- world1_to_disable
- World2_to_disable

# Define how many riders can sit on the same player's shoulders
# You can set groups you need, and give the appropriate permission to your users.
# Each groups you define will be checked with the permission "playerrider.duck.<group>"
Expand Down Expand Up @@ -180,3 +169,70 @@ boost_whip_pitch: 1.3
hide_rider_maxPitch: 25 # 0 to disable this feature
# Please note: This is not perfect, because if the player use third person view, it has no sense...
# and unfortunately, this cannot be detected in a Spigot plugin (this is client side)

##### New in version 1.14.1 #####

# Bossbar displayed to ridden player
bossbar_on_ridden_player:
enabled: true
title: "{player} is ridding you!" # {player} will be replaced by the rider's name
color: YELLOW # Available values: BLUE, GREEN, PINK, PURPLE, RED, WHITE, YELLOW
style: SOLID # Available values: SOLID, SEGMENTED_6, SEGMENTED_10, SEGMENTED_12, SEGMENTED_20
progress: 1.0 # Between 0 and 1

# Disabled worlds (you can use « [] > to represents an empty list)
disabled_worlds:
- world1_to_disable
- World2_to_disable

##### New in version 1.14.2 #####

# Disclaimer for those potion effects:
# It can be used by players to cure a higher effect, and I will not make a complex mechanic to prevent it.
# BUT, if a player has other types of effects before being mounted, those ones will not be affected by PlayerRider.
# It will only clear types of effect it had when the action begin when it stops.
#
# For example: (considering the default value of this config file with enabled = true)
# If a player is affected by a HUNGER effect for 2 minutes and is quickly mounted by another player,
# even if it's only for 1 second, he will be cured from HUNGER when this other player leaves his shoulder.
#
# So now you are warned about that, choose the effect you want to give with this in mind.

# Suggested by Elguerrero: If enabled when a player has someone on his shoulder, he will be slow down
affect_ridden_player:
enabled: false
# Available types here: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
# BEWARE: You have to verify for each effect you set if it can support the "max" multiplier value.
# I cannot garantee all effect will works with all values, so make your tests before.
# The effect showed here are arbitrary examples (I've tested those values but not using them on my server)
effects:
- type: SLOW # Potion effect type, see the link given above
init: 1 # (integer) Potion effect multiplier when the player has only one player on his shoulder
inc: 1 # (integer) Value to add for each additional player on his shoulder
max: 2 # (integer) Max value for the multiplier
duration: 1200 # (integer, ticks : 1 sec = 20 ticks) /!\ Refreshed when the ridden player moves
# You can add several effects, each defined like the previous one. Example:
- type: HUNGER
init: 1
inc: 2
max: 10
duration: 1200

# Works like affect_ridden_player but affect the ridden player when he's being whipped
affect_whipped_player:
enabled: false
# Note: As it is the primary function of this whip feature, the speed boost applied is not modifiable here
# You can change its settings wieht the parameters "boost_amplifier" and associated.
# They are after the line « ##### [ the next parameters are ignored if boost_allowed: false ] ##### »
effects:
- type: JUMP
init: 1
inc: -1
max: 0 # When you set a negative "inc" value, max value is used as a minimum value
duration: 60

- type: CONFUSION
init: 0
inc: 1
max: 1
duration: 60
75 changes: 75 additions & 0 deletions src/me/arboriginal/PlayerRider/PR.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package me.arboriginal.PlayerRider;

import java.io.File;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;

public class PR extends JavaPlugin {
static File file;
static FileConfiguration config;
static PROptions options;
static PRcooldown cooldown;
static YamlConfiguration users;

// JavaPlugin methods -----------------------------------------------------------------------------------------------

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (command.getName().equalsIgnoreCase("prider-reload")) {
reloadConfig();
PRUtils.userMessage(sender, "reload");

return true;
}

if (command.getName().equalsIgnoreCase("prider-toggle")) {
if (sender instanceof Player)
PRUtils.userMessage(sender, PRUtils.rideToggle((Player) sender));
else
PRUtils.userMessage(sender, "toggleWarn");
return true;
}

return super.onCommand(sender, command, label, args);
}

@Override
public void onDisable() {
super.onDisable();

HandlerList.unregisterAll((JavaPlugin) this);
}

@Override
public void onEnable() {
reloadConfig();

cooldown = new PRcooldown();
users = new YamlConfiguration();
file = new File(getDataFolder(), "usersPreferences.yml");

if (file.exists())
users = YamlConfiguration.loadConfiguration(file);
else
PRUtils.dataSave();

getServer().getPluginManager().registerEvents(new PRListener(this), this);
}

@Override
public void reloadConfig() {
super.reloadConfig();

saveDefaultConfig();
config = getConfig();
config.options().copyDefaults(true);
saveConfig();

options = new PROptions();
}
}
Loading

0 comments on commit af9a4d1

Please sign in to comment.