Merge master

This commit is contained in:
Edith Boles 2021-10-01 16:11:52 -07:00
commit 9e684a260d
4 changed files with 56 additions and 18 deletions

View File

@ -14,6 +14,7 @@ import org.bukkit.ChatColor;
import org.bukkit.Effect; import org.bukkit.Effect;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
import org.bukkit.Sound; import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -58,15 +59,20 @@ public final class Events implements Listener {
} }
Collections.sort(uuids); Collections.sort(uuids);
// if the player already has a target, pick the next one, otherwise pick the first if (uuids.size() == 0) {
if (QuidProQuo.instance.targets.containsKey(playerUuid)) { player.sendMessage(ChatColor.YELLOW + "No targets online!");
UUID current_target = QuidProQuo.instance.targets.get(playerUuid); } else {
if (Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid)) == null) { // if the player already has a target, pick the next one, otherwise pick the first
if (QuidProQuo.instance.targets.containsKey(playerUuid)) {
UUID current_target = QuidProQuo.instance.targets.get(playerUuid);
if (Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid)) instanceof OfflinePlayer) {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0));
}
QuidProQuo.instance.targets.put(playerUuid, uuids.get((uuids.indexOf(current_target) + 1) % uuids.size()));
} else {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0)); QuidProQuo.instance.targets.put(playerUuid, uuids.get(0));
} }
QuidProQuo.instance.targets.put(playerUuid, uuids.get((uuids.indexOf(current_target) + 1) % uuids.size())); player.sendMessage(ChatColor.YELLOW + "Switched target to " + Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid)));
} else {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0));
} }
// friendly message // friendly message
@ -182,13 +188,17 @@ public final class Events implements Listener {
} }
Collections.sort(uuids); Collections.sort(uuids);
if (!QuidProQuo.instance.targets.containsKey(playerUuid)) { if (uuids.size() == 0) {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0)); otherPlayer = null;
} else {
if (!QuidProQuo.instance.targets.containsKey(playerUuid)) {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0));
}
if (Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid)) instanceof OfflinePlayer) {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0));
}
otherPlayer = Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid));
} }
if (Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid)) == null) {
QuidProQuo.instance.targets.put(playerUuid, uuids.get(0));
}
otherPlayer = Bukkit.getPlayer(QuidProQuo.instance.targets.get(playerUuid));
// backfire check, if succeeds then the ritual gets reversed // backfire check, if succeeds then the ritual gets reversed
if(new Random().nextDouble() >= ritual.backfire) { if(new Random().nextDouble() >= ritual.backfire) {

View File

@ -6,10 +6,7 @@ import java.util.UUID;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import top.penowl.quidproquo.rituals.FeedingRitual; import top.penowl.quidproquo.rituals.*;
import top.penowl.quidproquo.rituals.HealRitual;
import top.penowl.quidproquo.rituals.SnowmanRitual;
import top.penowl.quidproquo.rituals.WoolingRitual;
public class QuidProQuo extends JavaPlugin { public class QuidProQuo extends JavaPlugin {
@ -38,6 +35,7 @@ public class QuidProQuo extends JavaPlugin {
rituals.add(new WoolingRitual()); rituals.add(new WoolingRitual());
rituals.add(new FeedingRitual()); rituals.add(new FeedingRitual());
rituals.add(new SnowmanRitual()); rituals.add(new SnowmanRitual());
rituals.add(new GetLuckyRitual());
// run ritual setup scripts // run ritual setup scripts
for (Ritual ritual : rituals) { for (Ritual ritual : rituals) {

View File

@ -13,7 +13,7 @@ public class FeedingRitual extends Ritual {
public void setup() { public void setup() {
addSacrifice(EntityType.PIG, 1); addSacrifice(EntityType.PIG, 1);
addIngredient(Material.WOOD_SWORD, 1); addIngredient(Material.WOOD_SWORD, 1);
health = 4; health = 1;
name = "feeding"; name = "feeding";
} }

View File

@ -0,0 +1,30 @@
package top.penowl.quidproquo.rituals;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import top.penowl.quidproquo.Ritual;
public class GetLuckyRitual extends Ritual {
@Override
public void setup() {
addIngredient(Material.GOLD_BLOCK, 3);
addIngredient(Material.TNT, 1);
health = 3;
lightning = true;
name = "daring";
}
@Override
public void execute(Player caster, Player target, Location location) {
if (Math.random() < 0.5) {
location.getWorld().createExplosion(location, 100F);
} else {
byproducts.add(new ItemStack(Material.GOLD_BLOCK, 16));
}
}
}