mirror of
https://github.com/taoneill/war.git
synced 2024-12-02 15:13:39 +01:00
Config to apply potions on spawn.
Closes #615. The new APPLYPOTION configuration option allows warzone makers to give potion effects ot players every time they spawn. Use case: Resistance 5 for a few seconds on player spawn to prevent them from being "spawn camped" - killed when they step out by other players waiting nearby. Format of APPLYPOTION: effect_type:duration:amplification effect_type: For a valid list of values that can be used for this type param, please see http://jd.bukkit.org/rb/apidocs/org/bukkit/potion/PotionEffectType.html duration: Time in ticks (1/20 sec) that the potion will apply for. amplification: Amplifier to the potion's power. @taoneill @cmastudios documentate how to tune this option before 1.9 release on the wiki. Also please test use of this option in game (pulling a @grinning here).
This commit is contained in:
parent
4106dd887f
commit
72a2f08d70
@ -57,6 +57,8 @@ import com.tommytony.war.utility.PlayerState;
|
||||
import com.tommytony.war.utility.SizeCounter;
|
||||
import com.tommytony.war.utility.WarLogFormatter;
|
||||
import com.tommytony.war.volume.Volume;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
/**
|
||||
* Main class of War
|
||||
@ -225,6 +227,7 @@ public class War extends JavaPlugin {
|
||||
teamDefaultConfig.put(TeamConfig.KILLSTREAK, false);
|
||||
teamDefaultConfig.put(TeamConfig.BLOCKWHITELIST, "all");
|
||||
teamDefaultConfig.put(TeamConfig.PLACEBLOCK, true);
|
||||
teamDefaultConfig.put(TeamConfig.APPLYPOTION, "");
|
||||
|
||||
this.getDefaultInventories().clearLoadouts();
|
||||
HashMap<Integer, ItemStack> defaultLoadout = new HashMap<Integer, ItemStack>();
|
||||
@ -1318,4 +1321,23 @@ public class War extends JavaPlugin {
|
||||
public Locale getLoadedLocale() {
|
||||
return messages.getLocale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert serialized effect to actual effect.
|
||||
* @param serializedEffect String stored in configuration.
|
||||
* Format: TYPE:DURATION:AMPLIFY
|
||||
* @return Potion effect or null otherwise
|
||||
*/
|
||||
public PotionEffect getPotionEffect(String serializedEffect) {
|
||||
String[] arr = serializedEffect.split(":");
|
||||
if (arr.length != 3) return null;
|
||||
try {
|
||||
PotionEffectType type = PotionEffectType.getByName(arr[0]);
|
||||
int duration = Integer.parseInt(arr[1]);
|
||||
int amplification = Integer.parseInt(arr[2]);
|
||||
return new PotionEffect(type, duration, amplification);
|
||||
} catch (RuntimeException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.scoreboard.DisplaySlot;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
@ -452,6 +453,13 @@ public class Warzone {
|
||||
// clear potion effects
|
||||
PotionEffectHelper.clearPotionEffects(player);
|
||||
|
||||
if (!team.getTeamConfig().getString(TeamConfig.APPLYPOTION).isEmpty()) {
|
||||
PotionEffect effect = War.war.getPotionEffect(team.getTeamConfig().getString(TeamConfig.APPLYPOTION));
|
||||
if (effect != null) {
|
||||
player.addPotionEffect(effect);
|
||||
}
|
||||
}
|
||||
|
||||
boolean isFirstRespawn = false;
|
||||
if (!this.getLoadoutSelections().keySet().contains(player.getName())) {
|
||||
isFirstRespawn = true;
|
||||
|
@ -17,7 +17,8 @@ public enum TeamConfig {
|
||||
XPKILLMETER (Boolean.class),
|
||||
KILLSTREAK (Boolean.class),
|
||||
BLOCKWHITELIST (String.class),
|
||||
PLACEBLOCK (Boolean.class);
|
||||
PLACEBLOCK (Boolean.class),
|
||||
APPLYPOTION(String.class);
|
||||
|
||||
private final Class<?> configType;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user