This commit is contained in:
yaohunya 2024-09-24 18:56:42 +08:00
parent 7083ff6c6b
commit 12112bc94e
19 changed files with 60 additions and 28 deletions

View File

@ -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

View File

@ -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);
}
}

View File

@ -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<Integer> 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());

View File

@ -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<Integer> 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);

View File

@ -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<Integer> 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);

View File

@ -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<Integer> 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());

View File

@ -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++;

View File

@ -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<Integer> 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);

View File

@ -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<Integer> 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);

View File

@ -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<Integer> 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);

View File

@ -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<Integer> 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());

View File

@ -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++;

View File

@ -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<Integer> 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);
// 获取生物当前所在位置的方块

View File

@ -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<Integer> 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);

View File

@ -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("羊羊")) {

View File

@ -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);
}
}
}

View File

@ -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());
}
}

View File

@ -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);

View File

@ -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;
}