测试
This commit is contained in:
parent
fac8abdf6c
commit
add81dc2a9
|
@ -2,6 +2,8 @@ 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.GameListener;
|
||||
import com.io.yutian.colorblindwar.listener.JoinEvent;
|
||||
import com.io.yutian.colorblindwar.listener.PlayerListener;
|
||||
import com.io.yutian.colorblindwar.live.GiftQueue;
|
||||
import com.io.yutian.colorblindwar.manager.GiftEffectManager;
|
||||
|
@ -26,6 +28,8 @@ public final class ColorblindWar extends JavaPlugin {
|
|||
|
||||
game = new Game();
|
||||
Bukkit.getPluginManager().registerEvents(new PlayerListener(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new JoinEvent(), this);
|
||||
Bukkit.getPluginManager().registerEvents(new GameListener(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.io.yutian.colorblindwar.game;
|
|||
|
||||
import com.io.yutian.colorblindwar.ColorblindWar;
|
||||
import com.io.yutian.colorblindwar.util.*;
|
||||
import com.jgxs.yaohun.teleportspigot.api.WarpAPI;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.WorldEdit;
|
||||
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||
|
@ -36,6 +37,7 @@ public class Game {
|
|||
|
||||
private World world;
|
||||
private DirectionPoint spawnPoint;
|
||||
private Location spawnPoints;
|
||||
|
||||
private Player player;
|
||||
|
||||
|
@ -59,6 +61,7 @@ public class Game {
|
|||
|
||||
public Game() {
|
||||
reload();
|
||||
this.spawnPoints = WarpAPI.get_Spigot_Warps("Spawn");
|
||||
this.bossBar1 = Bukkit.createBossBar("今日挑战进度", BarColor.WHITE, BarStyle.SEGMENTED_10);
|
||||
this.bossBar2 = Bukkit.createBossBar("爬塔进度", BarColor.WHITE, BarStyle.SEGMENTED_20);
|
||||
this.bossBar3 = Bukkit.createBossBar("方块消失倒计时", BarColor.WHITE, BarStyle.SOLID);
|
||||
|
|
|
@ -0,0 +1,91 @@
|
|||
package com.io.yutian.colorblindwar.listener;
|
||||
|
||||
import com.io.yutian.colorblindwar.ColorblindWar;
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import com.jgxs.yaohun.teleportspigot.api.WarpAPI;
|
||||
import com.sun.tools.javac.Main;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockExplodeEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.Iterator;
|
||||
public class GameListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPing(ServerListPingEvent e){
|
||||
if (ColorblindWar.getGame().isStarted()) {
|
||||
e.setMotd("§a整蛊模式: §6ColorBlockUp §a当前版本: §6常规版 §b运行中");
|
||||
}else{
|
||||
e.setMotd("§a整蛊模式: §6ColorBlockUp §a当前版本: §6常规版 §c未运行");
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 当玩家掉出场地后将自动返回出生点
|
||||
* */
|
||||
@EventHandler
|
||||
public void onOffTheField(PlayerMoveEvent e){
|
||||
Player p = e.getPlayer();
|
||||
Location location = p.getLocation();
|
||||
if(location.getY() <= 5){
|
||||
Location hubLoc = WarpAPI.get_Spigot_Warps("Spawn");
|
||||
p.teleport(hubLoc);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 当发生爆炸时检测被炸方块是否有保护
|
||||
* */
|
||||
@EventHandler
|
||||
public void onBlockExplode(BlockExplodeEvent event) {
|
||||
Game game = ColorblindWar.getGame();
|
||||
if (game.isStarted()) {
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Block block = iterator.next();
|
||||
block.breakNaturally();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 当发生爆炸时检测被炸方块是否有保护
|
||||
* */
|
||||
@EventHandler
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
Game game = ColorblindWar.getGame();
|
||||
if (game.isStarted()) {
|
||||
Iterator<Block> iterator = event.blockList().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Block block = iterator.next();
|
||||
block.breakNaturally();
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* 拾取任何物品不进入背包直接清理
|
||||
* */
|
||||
@EventHandler
|
||||
public void onPick(PlayerPickupItemEvent e){
|
||||
Player p = e.getPlayer();
|
||||
p.playSound(p.getLocation(), Sound.ENTITY_ITEM_PICKUP,1,1);
|
||||
e.setCancelled(true);
|
||||
e.getItem().remove();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,26 @@
|
|||
package com.io.yutian.colorblindwar.listener;
|
||||
|
||||
import com.io.yutian.colorblindwar.ColorblindWar;
|
||||
import com.io.yutian.colorblindwar.game.Game;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class JoinEvent implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onJoin(PlayerJoinEvent e){
|
||||
Player p = e.getPlayer();
|
||||
p.setGameMode(GameMode.ADVENTURE);
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
Game game = ColorblindWar.getGame();
|
||||
game.start(p);
|
||||
}
|
||||
}.runTaskLater(ColorblindWar.inst(),15L);
|
||||
}
|
||||
}
|
|
@ -73,6 +73,7 @@ public class GiftEffectManager {
|
|||
return 60;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private static void registerGiftEffect(String id, Function<String, GiftEffect> giftEffectGetter) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user