Multiple potion effects

This commit is contained in:
Jakub Kolář 2017-08-03 10:24:59 +02:00
parent c6edc3639f
commit ffac637904
6 changed files with 43 additions and 49 deletions

View File

@ -20,11 +20,16 @@
<version>${minecraft.version}-${bukkit.version}-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--Bukkit API-->
<dependency> <!-- Spigot (this includes Spigot API, Bukkit API, Craftbukkit and NMS) -->
<groupId>org.spigotmc</groupId>
<artifactId>spigot</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>${minecraft.version}-${bukkit.version}-SNAPSHOT</version>
<artifactId>craftbukkit</artifactId>
<version>1.12-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
@ -55,11 +60,11 @@
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>

View File

@ -3,7 +3,9 @@ package cz.boosik.boosCooldown.Managers;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
@ -313,30 +315,19 @@ public class BoosConfigManager {
return conf.getString("options.messages.paid_for_command", "Price of &command& was %s and you now have %s");
}
static String getPotionEffect(String regexCommand, Player player) {
String effect = "";
String temp;
String[] command;
static Map<String, Integer> getPotionEffects(String regexCommand, Player player) {
String group = getCommandGroup(player);
temp = conf.getString("commands.groups." + group + "." + regexCommand + ".potion", "");
command = temp.split(",");
if (command.length == 2) {
effect = command[0];
}
return effect;
}
Map<String, Integer> result = new HashMap<>();
List<String> temp = conf.getStringList("commands.groups." + group + "." + regexCommand + ".potion");
temp.forEach(entry -> {
String[] item;
item = entry.split(",");
if (item.length == 2) {
result.put(item[0], Integer.valueOf(item[1]));
}
});
static int getPotionEffectStrength(String regexCommand, Player player) {
int effect = 0;
String temp;
String[] command;
String group = getCommandGroup(player);
temp = conf.getString("commands.groups." + group + "." + regexCommand + ".potion", "");
command = temp.split(",");
if (command.length == 2) {
effect = Integer.valueOf(command[1]);
}
return effect;
return result;
}
public static double getPrice(String regexCommand, Player player) {

View File

@ -16,21 +16,13 @@ public class BoosWarmUpManager {
private static final ConcurrentHashMap<String, BoosWarmUpTimer> playercommands = new ConcurrentHashMap<>();
private static void applyPotionEffect(Player player, String regexCommand,
int warmUpSeconds) {
String potion = BoosConfigManager.getPotionEffect(regexCommand, player);
if (potion.equals("")) {
return;
}
int potionStrength = BoosConfigManager.getPotionEffectStrength(
regexCommand, player);
if (potionStrength == 0) {
return;
}
PotionEffectType effect = PotionEffectType.getByName(potion);
player.addPotionEffect(
effect.createEffect(warmUpSeconds * 40, potionStrength - 1),
true);
private static void applyPotionEffect(Player player, String regexCommand, int warmUpSeconds) {
BoosConfigManager.getPotionEffects(regexCommand, player).forEach((potion, potionStrength) -> {
PotionEffectType effect = PotionEffectType.getByName(potion);
player.addPotionEffect(
effect.createEffect(warmUpSeconds * 20, potionStrength - 1),
true);
});
}
public static void cancelWarmUps(Player player) {

View File

@ -147,7 +147,9 @@ commands:
price: 10.0
limit: 5
#potion effect and its strength that will affect player for the warmup time (5 seconds here) has to be one from this list: https://hub.spigotmc.org/javadocs/spigot/org/bukkit/potion/PotionEffectType.html
potion: WEAKNESS,3
potion:
- WEAKNESS,3
- SLOW,5
/test:
#message that is sent to player when he uses this command
message: You just used /test!

View File

@ -1,6 +1,6 @@
name: boosCooldowns
main: cz.boosik.boosCooldown.BoosCoolDown
version: 3.13.4
version: 3.14.0
authors: [LordBoos (boosik)]
softdepend: [Vault, PlayerPoints]
description: >

12
pom.xml
View File

@ -11,12 +11,12 @@
<packaging>pom</packaging>
<url>http://maven.apache.org</url>
<properties>
<boosCooldowns.version>3.13.4</boosCooldowns.version>
<boosCooldowns.version>3.14.0</boosCooldowns.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<minecraft.version>1.11</minecraft.version>
<minecraft.version>1.12</minecraft.version>
<bukkit.version>R0.1</bukkit.version>
<bukkit.packet>v1_11_R1</bukkit.packet>
<bukkit.packet>v1_12_R1</bukkit.packet>
</properties>
<pluginRepositories>
<pluginRepository>
@ -45,9 +45,13 @@
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
<repository>
<id>spigot-repo</id>
<id>spigot-repo-old</id>
<url>http://repo.md-5.net/content/repositories/snapshots/</url>
</repository>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>elmakers-spigot-repo</id>
<url>http://maven.elmakers.com/repository/</url>