From 12112bc94e45514f05fdf2d724434e5a1ac65498 Mon Sep 17 00:00:00 2001 From: yaohunya <31456652@qq.com> Date: Tue, 24 Sep 2024 18:56:42 +0800 Subject: [PATCH] v3.0 --- .../java/com/yaohun/farmingwar/FarmingWar.java | 2 ++ .../java/com/yaohun/farmingwar/data/LikeData.java | 9 ++++++++- .../yaohun/farmingwar/effects/SummonTheCow.java | 5 +++-- .../farmingwar/effects/SummonTheDragon.java | 4 ++-- .../yaohun/farmingwar/effects/SummonTheGiant.java | 4 ++-- .../yaohun/farmingwar/effects/SummonTheHorse.java | 4 ++-- .../farmingwar/effects/SummonTheIrongolem.java | 2 +- .../farmingwar/effects/SummonTheMagmacube.java | 4 ++-- .../yaohun/farmingwar/effects/SummonThePanda.java | 4 ++-- .../farmingwar/effects/SummonThePolarBear.java | 4 ++-- .../yaohun/farmingwar/effects/SummonTheSheep.java | 4 ++-- .../farmingwar/effects/SummonTheTraderllama.java | 2 +- .../farmingwar/effects/SummonTheVillager.java | 4 ++-- .../farmingwar/effects/SummonTheWither.java | 4 ++-- .../farmingwar/liveevent/GiftEventHandler.java | 2 ++ .../yaohun/farmingwar/liveevent/GiftListener.java | 3 --- .../farmingwar/liveevent/KeyInputListener.java | 15 +++++++++++++++ .../yaohun/farmingwar/liveevent/LikeListener.java | 4 +++- .../yaohun/farmingwar/manager/GameManager.java | 8 +++++++- 19 files changed, 60 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/yaohun/farmingwar/liveevent/KeyInputListener.java diff --git a/src/main/java/com/yaohun/farmingwar/FarmingWar.java b/src/main/java/com/yaohun/farmingwar/FarmingWar.java index c104d42..1a04943 100644 --- a/src/main/java/com/yaohun/farmingwar/FarmingWar.java +++ b/src/main/java/com/yaohun/farmingwar/FarmingWar.java @@ -12,6 +12,7 @@ import com.yaohun.farmingwar.game.Region; import com.yaohun.farmingwar.listener.*; import com.yaohun.farmingwar.liveevent.GiftEventHandler; import com.yaohun.farmingwar.liveevent.GiftListener; +import com.yaohun.farmingwar.liveevent.KeyInputListener; import com.yaohun.farmingwar.liveevent.LikeListener; import com.yaohun.farmingwar.manager.GameManager; import org.bukkit.Bukkit; @@ -46,6 +47,7 @@ public class FarmingWar extends JavaPlugin { Bukkit.getPluginManager().registerEvents(new PlayerListener(this), this); Bukkit.getPluginManager().registerEvents(new JoinListener(this), this); Bukkit.getPluginManager().registerEvents(new KeepEntitiesOnDeath(), this); + Bukkit.getPluginManager().registerEvents(new KeyInputListener(), this); } @Override diff --git a/src/main/java/com/yaohun/farmingwar/data/LikeData.java b/src/main/java/com/yaohun/farmingwar/data/LikeData.java index 2e88cba..e62db2c 100644 --- a/src/main/java/com/yaohun/farmingwar/data/LikeData.java +++ b/src/main/java/com/yaohun/farmingwar/data/LikeData.java @@ -1,15 +1,19 @@ package com.yaohun.farmingwar.data; +import tools.GameUtil; + public class LikeData { private String effectKey; private int needAmount; private int nowAmount; + private String sound; - public LikeData(String effectKey, int needAmount){ + public LikeData(String effectKey, int needAmount, String sound){ this.effectKey = effectKey; this.needAmount = needAmount; this.nowAmount = 0; + this.sound = sound; } public String getEffectKey() { @@ -38,4 +42,7 @@ public class LikeData { public void setNowAmount(int nowAmount) { this.nowAmount = nowAmount; } + public void OutPlaySoundsEvent() { + GameUtil.sendAllSound(this.sound); + } } diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheCow.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheCow.java index c4f629a..07d65b6 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheCow.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheCow.java @@ -11,6 +11,7 @@ import org.bukkit.Particle; import org.bukkit.block.Block; import org.bukkit.block.data.Ageable; import org.bukkit.block.data.BlockData; +import org.bukkit.block.data.type.Farmland; import org.bukkit.entity.Cow; import org.bukkit.entity.EntityType; import org.bukkit.entity.Player; @@ -73,7 +74,7 @@ public class SummonTheCow { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -92,7 +93,7 @@ public class SummonTheCow { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setRotation(-90, 0); entity.setVelocity(vector0); location.setY(region.getMax().getY()); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheDragon.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheDragon.java index e37e654..70aa9ed 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheDragon.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheDragon.java @@ -76,7 +76,7 @@ public class SummonTheDragon { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -97,7 +97,7 @@ public class SummonTheDragon { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); Location location1 = entity.getLocation().add(vector0); location1.setYaw(90); location1.setPitch(0); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheGiant.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheGiant.java index 850cb8f..611df4b 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheGiant.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheGiant.java @@ -73,7 +73,7 @@ public class SummonTheGiant { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -94,7 +94,7 @@ public class SummonTheGiant { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); Location location1 = entity.getLocation().add(vector0); location1.setYaw(-90); location1.setPitch(0); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheHorse.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheHorse.java index 19a5489..dc4f915 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheHorse.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheHorse.java @@ -82,7 +82,7 @@ public class SummonTheHorse { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override @@ -102,7 +102,7 @@ public class SummonTheHorse { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setVelocity(vector0); entity.setRotation(-90, 0); location.setY(region.getMax().getY()); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheIrongolem.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheIrongolem.java index 41d3622..0d9c61f 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheIrongolem.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheIrongolem.java @@ -90,7 +90,7 @@ public class SummonTheIrongolem { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.32); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setRotation(-90, 0); entity.setVelocity(vector0); i++; diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheMagmacube.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheMagmacube.java index 7752fc1..73f5a3d 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheMagmacube.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheMagmacube.java @@ -78,7 +78,7 @@ public class SummonTheMagmacube { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 10; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -97,7 +97,7 @@ public class SummonTheMagmacube { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.12); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setTarget(null); entity.setRotation(-90, 0); entity.setVelocity(vector0); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonThePanda.java b/src/main/java/com/yaohun/farmingwar/effects/SummonThePanda.java index 32dfe13..a2db4cd 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonThePanda.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonThePanda.java @@ -70,7 +70,7 @@ public class SummonThePanda { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -89,7 +89,7 @@ public class SummonThePanda { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.20); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setTarget(null); entity.setRotation(-90, 0); entity.setVelocity(vector0); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonThePolarBear.java b/src/main/java/com/yaohun/farmingwar/effects/SummonThePolarBear.java index 17b4b2e..f562a88 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonThePolarBear.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonThePolarBear.java @@ -69,7 +69,7 @@ public class SummonThePolarBear { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -88,7 +88,7 @@ public class SummonThePolarBear { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.2); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setTarget(null); entity.setRotation(-90, 0); entity.setVelocity(vector0); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheSheep.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheSheep.java index ef70849..6a4b427 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheSheep.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheSheep.java @@ -75,7 +75,7 @@ public class SummonTheSheep { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -94,7 +94,7 @@ public class SummonTheSheep { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setVelocity(vector0); entity.setRotation(-90, 0); location.setY(region.getMax().getY()); diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheTraderllama.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheTraderllama.java index f6b95a2..983c8db 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheTraderllama.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheTraderllama.java @@ -94,7 +94,7 @@ public class SummonTheTraderllama { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.32); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setRotation(-90, 0); entity.setVelocity(vector0); i++; diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheVillager.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheVillager.java index 0464d4b..332b06d 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheVillager.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheVillager.java @@ -74,7 +74,7 @@ public class SummonTheVillager { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -93,7 +93,7 @@ public class SummonTheVillager { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); entity.setRotation(-90, 0); entity.setVelocity(vector0); // 获取生物当前所在位置的方块 diff --git a/src/main/java/com/yaohun/farmingwar/effects/SummonTheWither.java b/src/main/java/com/yaohun/farmingwar/effects/SummonTheWither.java index 1a2b49e..451ab96 100644 --- a/src/main/java/com/yaohun/farmingwar/effects/SummonTheWither.java +++ b/src/main/java/com/yaohun/farmingwar/effects/SummonTheWither.java @@ -81,7 +81,7 @@ public class SummonTheWither { BukkitTask task = new BukkitRunnable() { private int i = 0; // 计算将在多少i后自动消失 - private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 7; + private double remove_x_i = (region.getMax().getX() - region.getMin().getX()) * 4; private List integerList = new ArrayList<>(); @Override public void run() { @@ -102,7 +102,7 @@ public class SummonTheWither { } Vector vector0 = new Vector(1, 0, 0); vector0.normalize(); - vector0.multiply(0.15); + vector0.multiply(FarmingWar.getGameManager().getMovespeeds()); Location location1 = entity.getLocation().add(vector0); location1.setYaw(-90); location1.setPitch(0); diff --git a/src/main/java/com/yaohun/farmingwar/liveevent/GiftEventHandler.java b/src/main/java/com/yaohun/farmingwar/liveevent/GiftEventHandler.java index b4f2ab5..53e799b 100644 --- a/src/main/java/com/yaohun/farmingwar/liveevent/GiftEventHandler.java +++ b/src/main/java/com/yaohun/farmingwar/liveevent/GiftEventHandler.java @@ -21,6 +21,8 @@ public class GiftEventHandler { BigWindill.apply(game,zhubo,5); }else if (eventName.equalsIgnoreCase("大风车60秒")) { BigWindill.apply(game,zhubo,60); + }else if (eventName.equalsIgnoreCase("场地重置")) { + game.reset(); } else if (eventName.equalsIgnoreCase("关灯100秒")) { PotionBlindness.apply(game,zhubo,100); } else if (eventName.contains("羊羊")) { diff --git a/src/main/java/com/yaohun/farmingwar/liveevent/GiftListener.java b/src/main/java/com/yaohun/farmingwar/liveevent/GiftListener.java index 854ce51..d1a9ff2 100644 --- a/src/main/java/com/yaohun/farmingwar/liveevent/GiftListener.java +++ b/src/main/java/com/yaohun/farmingwar/liveevent/GiftListener.java @@ -27,8 +27,5 @@ public class GiftListener implements Listener { } String show_userName = GameUtil.hideName(userName); GiftUtil.simulatedGiftEffect(zhubo,show_userName,giftName,amount); - for (Player player : Bukkit.getOnlinePlayers()){ - player.sendMessage("§a礼物: §e"+ show_userName+" §d送来了 §e"+giftName+"x"+amount); - } } } diff --git a/src/main/java/com/yaohun/farmingwar/liveevent/KeyInputListener.java b/src/main/java/com/yaohun/farmingwar/liveevent/KeyInputListener.java new file mode 100644 index 0000000..8f30d2b --- /dev/null +++ b/src/main/java/com/yaohun/farmingwar/liveevent/KeyInputListener.java @@ -0,0 +1,15 @@ +package com.yaohun.farmingwar.liveevent; + +import com.io.yutian.pixelliveplugin.event.KeyInputEvent; +import org.bukkit.entity.Player; +import org.bukkit.event.EventHandler; +import org.bukkit.event.Listener; + +public class KeyInputListener implements Listener { + + @EventHandler//点赞 + public void onDianZan(KeyInputEvent e) { + Player zhubo = e.getPlayer(); + zhubo.sendMessage("RawCode = "+e.getRawCode()+" KeyCode = "+e.getKeyCode()); + } +} diff --git a/src/main/java/com/yaohun/farmingwar/liveevent/LikeListener.java b/src/main/java/com/yaohun/farmingwar/liveevent/LikeListener.java index 9813a84..ca1d3c0 100644 --- a/src/main/java/com/yaohun/farmingwar/liveevent/LikeListener.java +++ b/src/main/java/com/yaohun/farmingwar/liveevent/LikeListener.java @@ -31,7 +31,9 @@ public class LikeListener implements Listener { if(likeData.meetTheQuantityRequirement()){ String eventName = likeData.getEffectKey(); String title = "§c"+eventName; - String subtitle = "§9双击屏幕x"+likeData.getNeedAmount(); + //String subtitle = "§9双击屏幕x"+likeData.getNeedAmount(); + String subtitle = "§r"; + likeData.OutPlaySoundsEvent(); zhubo.sendTitle(title, subtitle,0, 30, 10); GiftEventHandler.SendHandLer(zhubo,userName,eventName); likeData.setNowAmount(0); diff --git a/src/main/java/com/yaohun/farmingwar/manager/GameManager.java b/src/main/java/com/yaohun/farmingwar/manager/GameManager.java index f498448..c1d5b70 100644 --- a/src/main/java/com/yaohun/farmingwar/manager/GameManager.java +++ b/src/main/java/com/yaohun/farmingwar/manager/GameManager.java @@ -18,6 +18,7 @@ public class GameManager { private File manageFile; private FileConfiguration manageConfig; + private double movespeeds = 0.32; private int gameGoal; private long gameTime; private BackPointType backPointType; @@ -39,7 +40,8 @@ public class GameManager { for (String key : likeSection.getKeys(false)) { String effect = likeSection.getString(key+".效果"); int likeAmount = likeSection.getInt(key+".点赞次数"); - likeDataMap.put(effect,new LikeData(effect,likeAmount)); + String likesounds = likeSection.getString(key+".声音","wau"); + likeDataMap.put(effect,new LikeData(effect,likeAmount,likesounds)); String message = "事件: "+effect+" 条件: 点赞x"+likeAmount; Bukkit.getConsoleSender().sendMessage(message); } @@ -88,6 +90,10 @@ public class GameManager { } } + public double getMovespeeds() { + return movespeeds; + } + public long getGameTime() { return gameTime; }