This commit is contained in:
YuTian 2024-08-11 13:30:47 +08:00
parent 5c88e81278
commit 64efbb5a59
9 changed files with 42 additions and 21 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/.idea/ /.idea/
/out/ /out/
/EnderDragonWars.iml /EnderDragonWars.iml
/lib/

View File

@ -25,7 +25,7 @@ public class AddMaxHealthEffect extends GiftEffect {
private int count = 0; private int count = 0;
@Override @Override
public void run() { public void run() {
if (count >= 10) { if (count >= 50) {
cancel(); cancel();
return; return;
} }

View File

@ -19,6 +19,8 @@ public class PlayerBigEffect extends GiftEffect {
} }
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() + 0.5); player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() + 0.5);
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue() + 1); player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue() + 1);
player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).setBaseValue(player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).getBaseValue() + 1);
player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() + 0.2);
} }
} }

View File

@ -16,6 +16,7 @@ public class PlayerResetEffect extends GiftEffect {
Player player = game.getPlayer(); Player player = game.getPlayer();
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(1); player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(1);
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(4.5); player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(4.5);
player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).setBaseValue(0.6);
} }
} }

View File

@ -19,6 +19,8 @@ public class PlayerSmallEffect extends GiftEffect {
} }
player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() - 0.5); player.getAttribute(Attribute.GENERIC_SCALE).setBaseValue(player.getAttribute(Attribute.GENERIC_SCALE).getBaseValue() - 0.5);
player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue() - 0.5); player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).setBaseValue(player.getAttribute(Attribute.PLAYER_BLOCK_INTERACTION_RANGE).getBaseValue() - 0.5);
player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).setBaseValue(player.getAttribute(Attribute.GENERIC_STEP_HEIGHT).getBaseValue() - 1);
player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(player.getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() - 0.2);
} }
} }

View File

@ -19,7 +19,7 @@ public class TakeMaxHealthEffect extends GiftEffect {
if (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= 20) { if (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() <= 20) {
return; return;
} }
player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() - 20); player.getAttribute(Attribute.GENERIC_MAX_HEALTH).setBaseValue(20);
} }

View File

@ -10,11 +10,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
public class LikeListener implements Listener { public class LikeListener implements Listener {
@EventHandler//点赞
@EventHandler
public void onDianZan(LiveLikeEvents e) { public void onDianZan(LiveLikeEvents e) {
Player zhubo = e.getPlayer(); Player zhubo = e.getPlayer();
String userName = ""+ RandomUtil.getRandomInt(999,10000); String userName = "" + RandomUtil.getRandomInt(999, 10000);
if(e.getUser().nickName() != null) { if (e.getUser().nickName() != null) {
userName = e.getUser().nickName(); userName = e.getUser().nickName();
} }
long add_amount = e.getCount(); long add_amount = e.getCount();
@ -22,11 +23,12 @@ public class LikeListener implements Listener {
gameManager.addDianzan_amount((int) add_amount); gameManager.addDianzan_amount((int) add_amount);
if (gameManager.getDianzan_amount() >= gameManager.getDianzan_need()) { if (gameManager.getDianzan_amount() >= gameManager.getDianzan_need()) {
String eventName_Show = gameManager.getDianzan_event(); String eventName_Show = gameManager.getDianzan_event();
String title = "§c"+eventName_Show; String title = "§c" + eventName_Show;
String subtitle = "§9双击屏幕x"+gameManager.getDianzan_need(); String subtitle = "§9双击屏幕x" + gameManager.getDianzan_need();
zhubo.sendTitle(title, subtitle,10, 30, 10); zhubo.sendTitle(title, subtitle, 10, 30, 10);
GiftEffectManager.addGiftEffect(userName,eventName_Show); GiftEffectManager.addGiftEffect(userName, eventName_Show);
gameManager.setDianzan_amount(0); gameManager.setDianzan_amount(0);
} }
} }
} }

View File

@ -14,38 +14,38 @@ import org.bukkit.event.Listener;
public class LiveEvent implements Listener { public class LiveEvent implements Listener {
@EventHandler @EventHandler
public void onLive(LiveGiftEvents e){ public void onLive(LiveGiftEvents e) {
Player zhubo = e.getPlayer(); Player zhubo = e.getPlayer();
String userName = e.getUser().nickName(); String userName = e.getUser().nickName();
boolean butt = false; boolean butt = false;
if(userName != null){ if (userName != null) {
userName = e.getUser().nickName(); userName = e.getUser().nickName();
butt = true; butt = true;
} }
String giftName = e.getName(); String giftName = e.getName();
int giftAmount = (int) e.getAmount(); int giftAmount = (int) e.getAmount();
if(giftAmount < 0){ if (giftAmount < 0) {
giftAmount = 1; giftAmount = 1;
} }
GameManager gameManager = Main.gameManager; GameManager gameManager = Main.gameManager;
if(gameManager.getGiftData(giftName) == null){ if (gameManager.getGiftData(giftName) == null) {
return; return;
} }
GiftData giftData = gameManager.getGiftData(giftName); GiftData giftData = gameManager.getGiftData(giftName);
String hideUserName = GameUtil.hideName(userName); String hideUserName = GameUtil.hideName(userName);
String eventName = giftData.getEvent(); String eventName = giftData.getEvent();
if(GameUtil.specialGiftEffectTriggers(zhubo,eventName,hideUserName,giftAmount)){ if (GameUtil.specialGiftEffectTriggers(zhubo, eventName, hideUserName, giftAmount)) {
return; return;
} }
String title = "§c" + eventName; String title = "§c" + eventName;
if(giftAmount >= 2) { if (giftAmount >= 2) {
title = "§c" + eventName + " x" + giftAmount; title = "§c" + eventName + " x" + giftAmount;
} }
String subtitle = "§9" + giftName; String subtitle = "§9" + giftName;
if(butt) { if (butt) {
subtitle = "§9" + hideUserName; subtitle = "§9" + hideUserName;
} }
zhubo.sendTitle(title, subtitle,0, 30, 10); zhubo.sendTitle(title, subtitle, 0, 30, 10);
if (giftAmount <= 1) { if (giftAmount <= 1) {
giftData.playSoundEvent(); giftData.playSoundEvent();
GiftEffectManager.addGiftEffect(hideUserName, eventName); GiftEffectManager.addGiftEffect(hideUserName, eventName);
@ -58,8 +58,8 @@ public class LiveEvent implements Listener {
}, (long) i * dadey); }, (long) i * dadey);
} }
} }
for (Player player : Bukkit.getOnlinePlayers()){ for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage("§a礼物: §e"+ hideUserName+" §d送来了 §e"+giftName+"x"+giftAmount); player.sendMessage("§a礼物: §e" + hideUserName + " §d送来了 §e" + giftName + "x" + giftAmount);
} }
} }
} }

View File

@ -2,8 +2,7 @@ package com.yaohun.enderdragonwars.manager;
import com.yaohun.enderdragonwars.effect.GiftEffect; import com.yaohun.enderdragonwars.effect.GiftEffect;
import com.yaohun.enderdragonwars.effect.GiftQueue; import com.yaohun.enderdragonwars.effect.GiftQueue;
import com.yaohun.enderdragonwars.effect.types.BomBomEffect; import com.yaohun.enderdragonwars.effect.types.*;
import com.yaohun.enderdragonwars.effect.types.ClearInventoryEffect;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import java.util.HashMap; import java.util.HashMap;
@ -43,6 +42,20 @@ public class GiftEffectManager {
public static void registerAll() { public static void registerAll() {
registerGiftEffect("清理背包", ClearInventoryEffect::new); registerGiftEffect("清理背包", ClearInventoryEffect::new);
registerGiftEffect("火山喷发", BomBomEffect::new); registerGiftEffect("火山喷发", BomBomEffect::new);
registerGiftEffect("幸运方块", LuckyBlockEffect::new);
registerGiftEffect("黑洞", BlackHoleEffect::new);
registerGiftEffect("五雷轰顶", FiveLightningEffect::new);
registerGiftEffect("装备清空", ClearInventoryEffect::new);
registerGiftEffect("岩浆泡澡", LavaPoolEffect::new);
registerGiftEffect("钢铁保安", SummonIronGolem::new);
registerGiftEffect("6倍血量", AddMaxHealthEffect::new);
registerGiftEffect("原地复活", GiveTotemEffect::new);
registerGiftEffect("魔豆天梯", SpawnEnderPortalEffect::new);
registerGiftEffect("世界毁灭", WorldDestroyEffect::new);
registerGiftEffect("变大", PlayerBigEffect::new);
registerGiftEffect("变小", PlayerSmallEffect::new);
registerGiftEffect("安全庇护所", SpawnBuildEffect::new);
registerGiftEffect("螺旋升天", ToHeavenEffect::new);
} }
private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) { private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) {