1.1
This commit is contained in:
parent
f7fbb02e8a
commit
0371c889ea
16
pom.xml
16
pom.xml
|
@ -23,8 +23,8 @@
|
|||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>${java.version}</source>
|
||||
<target>${java.version}</target>
|
||||
<source>16</source>
|
||||
<target>16</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -63,7 +63,11 @@
|
|||
</repository>
|
||||
<repository>
|
||||
<id>public</id>
|
||||
<url>http://111.230.48.153:18081/repository/public/</url>
|
||||
<url>https://repo.aurora-pixels.com/repository/public/</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>public-rpg</id>
|
||||
<url>https://repo.aurora-pixels.com/repository/public-rpg/</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
@ -74,5 +78,11 @@
|
|||
<version>1.18.2-R0.1-SNAPSHOT</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>fastasyncworldedit</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<classifier>669</classifier>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -3,12 +3,16 @@ package com.io.yutian.colorblindwar;
|
|||
import com.io.yutian.colorblindwar.game.DirectionPoint;
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import com.io.yutian.colorblindwar.listener.PlayerListener;
|
||||
import com.io.yutian.colorblindwar.live.GiftQueue;
|
||||
import com.io.yutian.colorblindwar.manager.GiftEffectManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public final class ColorblindWar extends JavaPlugin {
|
||||
|
||||
private static ColorblindWar instance;
|
||||
|
@ -17,10 +21,20 @@ public final class ColorblindWar extends JavaPlugin {
|
|||
@Override
|
||||
public void onEnable() {
|
||||
instance = this;
|
||||
|
||||
GiftEffectManager.registerAll();
|
||||
|
||||
game = new Game();
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
if (game.isStarted()) {
|
||||
game.stop(false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if (args.length == 0) {
|
||||
|
@ -62,6 +76,24 @@ public final class ColorblindWar extends JavaPlugin {
|
|||
} else if (subCommand.equalsIgnoreCase("reload")) {
|
||||
game.reload();
|
||||
sender.sendMessage("重载成功");
|
||||
} else if (subCommand.equalsIgnoreCase("test")) {
|
||||
if (!(sender instanceof Player)) {
|
||||
return true;
|
||||
}
|
||||
String s1 = args[1];
|
||||
Player player = (Player) sender;
|
||||
if (s1.equalsIgnoreCase("add")) {
|
||||
GiftEffectManager.addGiftEffect(player.getName(), "致盲");
|
||||
player.sendMessage("add effect success");
|
||||
} else if (s1.equalsIgnoreCase("list")) {
|
||||
player.sendMessage("effect list:");
|
||||
for (Map.Entry<String, GiftQueue> entry : GiftEffectManager.getGiftQueues().entrySet()) {
|
||||
String type = entry.getKey();
|
||||
GiftQueue giftQueue = entry.getValue();
|
||||
player.sendMessage(type+":");
|
||||
player.sendMessage(" "+giftQueue.getEffectQueue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
package com.io.yutian.colorblindwar.effect;
|
||||
|
||||
public class EffectTime {
|
||||
}
|
|
@ -34,7 +34,6 @@ public class Game {
|
|||
|
||||
private static final List<Material> MATERIAL_LIST = Arrays.asList(Material.WHITE_WOOL, Material.BLACK_WOOL, Material.BROWN_WOOL, Material.BLUE_WOOL, Material.GREEN_WOOL, Material.RED_WOOL, Material.YELLOW_WOOL, Material.PURPLE_WOOL, Material.ORANGE_WOOL, Material.PINK_WOOL, Material.LIGHT_BLUE_WOOL, Material.LIME_WOOL);
|
||||
|
||||
|
||||
private World world;
|
||||
private DirectionPoint spawnPoint;
|
||||
|
||||
|
@ -146,6 +145,8 @@ public class Game {
|
|||
for (Entity entity : entities) {
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
spawnBuild();
|
||||
this.bossBar1.removeAll();
|
||||
this.bossBar2.removeAll();
|
||||
this.bossBar3.removeAll();
|
||||
|
@ -341,6 +342,10 @@ public class Game {
|
|||
return started;
|
||||
}
|
||||
|
||||
public Player getPlayer() {
|
||||
return player;
|
||||
}
|
||||
|
||||
public World getWorld() {
|
||||
return world;
|
||||
}
|
||||
|
|
|
@ -1,17 +1,45 @@
|
|||
package com.io.yutian.colorblindwar.listener;
|
||||
|
||||
import com.io.yutian.colorblindwar.ColorblindWar;
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.weather.WeatherChangeEvent;
|
||||
|
||||
public class PlayerListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event) {
|
||||
if (ColorblindWar.getGame().isStarted()) {
|
||||
Game game = ColorblindWar.getGame();
|
||||
event.setRespawnLocation(game.getSpawnPoint().toLocation(game.getWorld()));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerDamage(EntityDamageEvent event) {
|
||||
Entity entity = event.getEntity();
|
||||
Game game = ColorblindWar.getGame();
|
||||
if (entity instanceof Player player) {
|
||||
if (game.isStarted()) {
|
||||
EntityDamageEvent.DamageCause damageCause = event.getCause();
|
||||
if (damageCause == EntityDamageEvent.DamageCause.VOID) {
|
||||
entity.teleport(game.getSpawnPoint().toLocation(game.getWorld()));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||
if (ColorblindWar.getGame().isStarted()) {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
package com.io.yutian.colorblindwar.live;
|
||||
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
|
||||
public abstract class GiftEffect {
|
||||
|
||||
private String audience;
|
||||
|
||||
public GiftEffect(String audience) {
|
||||
this.audience = audience;
|
||||
}
|
||||
|
||||
public String getAudience() {
|
||||
return audience;
|
||||
}
|
||||
|
||||
public abstract void apply(Game game);
|
||||
|
||||
public int getQueueTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
package com.io.yutian.colorblindwar.live;
|
||||
|
||||
import com.io.yutian.colorblindwar.ColorblindWar;
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
public class GiftQueue {
|
||||
|
||||
private Queue<GiftEffect> effectQueue = new LinkedList<>();
|
||||
|
||||
private BukkitTask task;
|
||||
|
||||
public GiftQueue(int waitTime) {
|
||||
task = Bukkit.getScheduler().runTaskTimer(ColorblindWar.inst(), new Runnable() {
|
||||
private int timer = 0;
|
||||
private boolean running = false;
|
||||
@Override
|
||||
public void run() {
|
||||
timer++;
|
||||
if (!running) {
|
||||
timer = waitTime;
|
||||
running = true;
|
||||
}
|
||||
if (timer >= waitTime) {
|
||||
timer = 0;
|
||||
if (effectQueue.isEmpty()) {
|
||||
running = false;
|
||||
return;
|
||||
}
|
||||
Game game = ColorblindWar.getGame();
|
||||
GiftEffect effect = effectQueue.poll();
|
||||
effect.apply(game);
|
||||
}
|
||||
}
|
||||
}, 0L, 1L);
|
||||
}
|
||||
|
||||
public void addEffect(GiftEffect effect) {
|
||||
effectQueue.add(effect);
|
||||
}
|
||||
|
||||
public Queue<GiftEffect> getEffectQueue() {
|
||||
return effectQueue;
|
||||
}
|
||||
|
||||
public BukkitTask getTask() {
|
||||
return task;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
package com.io.yutian.colorblindwar.liveevent;
|
||||
|
||||
import com.io.yutian.colorblindwar.ColorblindWar;
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import com.io.yutian.colorblindwar.util.GameUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GiftEventHandler {
|
||||
|
||||
public static void SendHandLer(Player zhubo,String userName,String eventName){
|
||||
Game game = ColorblindWar.getGame();
|
||||
userName = GameUtil.HideName(userName);
|
||||
if (eventName.equalsIgnoreCase("致盲")){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,72 @@
|
|||
package com.io.yutian.colorblindwar.manager;
|
||||
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import com.io.yutian.colorblindwar.live.GiftEffect;
|
||||
import com.io.yutian.colorblindwar.live.GiftQueue;
|
||||
import com.io.yutian.colorblindwar.util.RandomUtil;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
|
||||
public class GiftEffectManager {
|
||||
|
||||
private static Map<String, Function<String, GiftEffect>> giftEffectMap = new HashMap<>();
|
||||
|
||||
private static Map<String, GiftQueue> giftQueues = new HashMap<>();
|
||||
|
||||
public static void addGiftEffect(String audience, String effectId) {
|
||||
GiftEffect giftEffect = giftEffectMap.get(effectId).apply(audience);
|
||||
GiftQueue giftQueue = giftQueues.getOrDefault(effectId, new GiftQueue(giftEffect.getQueueTime()));
|
||||
giftQueue.addEffect(giftEffect);
|
||||
giftQueues.put(effectId, giftQueue);
|
||||
}
|
||||
|
||||
public static GiftQueue getGiftQueue(String effectId) {
|
||||
return giftQueues.get(effectId);
|
||||
}
|
||||
|
||||
public static Map<String, GiftQueue> getGiftQueues() {
|
||||
return giftQueues;
|
||||
}
|
||||
|
||||
public static void registerAll() {
|
||||
registerGiftEffect("盲盒", (audience)-> new GiftEffect(audience) {
|
||||
|
||||
private static List<String> effects = new ArrayList<>();
|
||||
|
||||
static {
|
||||
effects.add("致盲");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
Player player = game.getPlayer();
|
||||
String effect = effects.get(RandomUtil.getRandomInt(0, effects.size() - 1));
|
||||
addGiftEffect(audience, effect);
|
||||
}
|
||||
@Override
|
||||
public int getQueueTime() {
|
||||
return 20;
|
||||
}
|
||||
});
|
||||
registerGiftEffect("致盲", (audience)-> new GiftEffect(audience) {
|
||||
@Override
|
||||
public void apply(Game game) {
|
||||
Player player = game.getPlayer();
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 20 * 3, 0, false, false));
|
||||
}
|
||||
@Override
|
||||
public int getQueueTime() {
|
||||
return 60;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) {
|
||||
giftEffectMap.put(id, giftEffectGetter);
|
||||
}
|
||||
|
||||
}
|
|
@ -5,16 +5,14 @@ import org.bukkit.Sound;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
public class GameUtil {
|
||||
public class GiftUtil {
|
||||
|
||||
public static String HideName(String audience){
|
||||
if(audience.length() <= 2){
|
||||
public static String hideName(String audience) {
|
||||
if (audience.length() <= 2) {
|
||||
return "**";
|
||||
}
|
||||
// 获取第一个和第二个字符
|
||||
char firstChar = audience.charAt(0);
|
||||
char lastChar = audience.charAt(audience.length() - 1);
|
||||
// 构建屏蔽后的字符串
|
||||
StringBuilder maskedString = new StringBuilder();
|
||||
for (int i = 1; i < audience.length() - 1; i++) {
|
||||
maskedString.append('*');
|
||||
|
@ -22,10 +20,11 @@ public class GameUtil {
|
|||
return String.valueOf(firstChar) + maskedString + lastChar;
|
||||
}
|
||||
|
||||
public static void SendMessage(CommandSender sender, String message){
|
||||
sender.sendMessage("§c[系统]§a"+message);
|
||||
public static void sendMessage(CommandSender sender, String message) {
|
||||
sender.sendMessage("§c[系统]§a" + message);
|
||||
}
|
||||
public static void SendAllSounds(String sound){
|
||||
|
||||
public static void sendAllSound(String sound) {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
if (sound.contains("_")) {
|
||||
player.playSound(player.getLocation(), Sound.valueOf(sound), 1, 1);
|
||||
|
@ -35,7 +34,7 @@ public class GameUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public static boolean specialGiftEffectTriggers(Player player,String eventName,String show_userName,int amount) {
|
||||
public static boolean specialGiftEffectTriggers(Player player, String eventName, String show_userName, int amount) {
|
||||
if (eventName.contains("盲盒")) {
|
||||
if (eventName.contains("#")) {
|
||||
String s1 = "love";
|
||||
|
@ -44,11 +43,12 @@ public class GameUtil {
|
|||
if (eventName.contains("X")) {
|
||||
amount = Integer.parseInt(eventName.split("X")[1]);
|
||||
}
|
||||
RBoxAPI.addUserData(player, show_userName, box, amount);
|
||||
//RBoxAPI.addUserData(player, show_userName, box, amount);
|
||||
} else {
|
||||
System.out.println("[错误 - 盲盒] 随机盲盒在礼物设置中配置错误.");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
name: ColorblindWar
|
||||
version: '${project.version}'
|
||||
version: '1.1'
|
||||
main: com.io.yutian.colorblindwar.ColorblindWar
|
||||
api-version: '1.18'
|
||||
depend:
|
||||
|
|
Loading…
Reference in New Issue
Block a user