[tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr]import com.locydragon.gamelib.api.CustomGame; | [tr] [/tr]import com.locydragon.gamelib.api.GameLibrary; | [tr] [/tr]import com.locydragon.gamelib.api.entity.PlayingPlayer; | [tr] [/tr]import com.locydragon.gamelib.api.event.baby.bukkitevents.GamePlayerDamageEntityEvent; | [tr] [/tr]import com.locydragon.gamelib.api.event.baby.bukkitevents.GamePlayerDeathEvent; | [tr] [/tr]import com.locydragon.gamelib.api.event.type.EventType; | [tr] [/tr]import com.locydragon.gamelib.api.util.CommandManager; | [tr] [/tr]import com.locydragon.gamelib.api.util.ScoreManager; | [tr] [/tr]import org.bukkit.ChatColor; | [tr] [/tr]import org.bukkit.entity.Player; | [tr] [/tr]import org.bukkit.plugin.java.JavaPlugin; | [tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr] * This is only a example!You can use this code anyway! | [tr] [/tr][tr] [/tr]public class TestGame extends JavaPlugin { | [tr] [/tr][tr] [/tr][tr] [/tr] ScoreManager manager = null; | [tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr] game = GameLibrary.getLibrary().setMaxPlayerInOneTeam(1) | [tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr] .addEvent(EventType.PLAYING_PLAYER_DEATH, gameEvent -> { | [tr] [/tr] GamePlayerDeathEvent event = (GamePlayerDeathEvent)gameEvent; | [tr] [/tr][tr] [/tr] PlayingPlayer player = PlayingPlayer.search(event.getProp().getEntity().getKiller()); | [tr] [/tr][tr] [/tr] if (player.getGame() == null || player.getTeam() == -1) { | [tr] [/tr][tr] [/tr][tr] [/tr][tr] [/tr] manager.addOneScore(player.getTeam()); | [tr] [/tr][tr] [/tr] game.broadcastMsg(ChatColor.RED+player.getPlayerName()+"杀死了"+event.getProp().getEntity().getName()); | [tr] [/tr][tr] [/tr] game.broadcastMsg(ChatColor.RED+"目前组"+event.getPlayer().getTeam()+"分数: "+manager.getScore(player.getTeam())); | [tr] [/tr][tr] [/tr][tr] [/tr] .addEvent(EventType.ON_GAME_JOIN, gameEvent -> { | [tr] [/tr] ((Player)gameEvent.getPlayer()).sendMessage("你进入了游戏."); | [tr] [/tr] //凡是以"ON"开头的事件都得转成Player,其他转成PlayingPlayer即可 | [tr] [/tr][tr] [/tr] .addEvent(EventType.ON_GAME_QUIT, gameEvent -> { | [tr] [/tr] ((Player)gameEvent.getPlayer()).sendMessage("你退出了游戏."); | [tr] [/tr] //凡是以"ON"开头的事件都得转成Player,其他转成PlayingPlayer即可 | [tr] [/tr][tr] [/tr][tr] [/tr] manager = new ScoreManager(game); | [tr] [/tr][tr] [/tr] new CommandManager("tgame") | [tr] [/tr] .bindJoinCmd("join", this.game) | [tr] [/tr][tr] [/tr] .bindQuitCmd("quit", this.game); | [tr] [/tr][tr] [/tr]}[tr] [/tr]//计划:当玩家输入/tgame join 时加入游戏 |
|