Skip to content

Commit

Permalink
build(plugin): 项目完成,测试构建
Browse files Browse the repository at this point in the history
  • Loading branch information
CarmJos committed Jul 4, 2022
1 parent 3f93ca9 commit fb4e7a2
Show file tree
Hide file tree
Showing 14 changed files with 1,034 additions and 16 deletions.
20 changes: 12 additions & 8 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>

<repository>
<id>hp-repo</id>
<url>https://nexus.block2block.me/repository/HubParkour/</url>
</repository>

<repository>
<id>minebench-repo</id>
<url>https://repo.minebench.de/</url>
Expand Down Expand Up @@ -97,14 +102,6 @@
<optional>true</optional>
</dependency>

<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easyplugin-githubchecker</artifactId>
<version>${easyplugin.version}</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

<dependency>
<groupId>cc.carm.lib</groupId>
<artifactId>easylistener</artifactId>
Expand Down Expand Up @@ -147,6 +144,13 @@
</exclusions>
</dependency>

<dependency>
<groupId>me.block2block.hubparkour</groupId>
<artifactId>hubparkour-api</artifactId>
<version>2.6</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@
import cc.carm.lib.configuration.core.source.ConfigurationProvider;
import cc.carm.lib.easyplugin.EasyPlugin;
import cc.carm.lib.mineconfiguration.bukkit.MineConfiguration;
import cc.carm.outsource.plugin.parkourcompetition.command.PluginCommand;
import cc.carm.outsource.plugin.parkourcompetition.conf.PluginConfig;
import cc.carm.outsource.plugin.parkourcompetition.conf.PluginMessages;
import cc.carm.outsource.plugin.parkourcompetition.listener.FireworkListener;
import cc.carm.outsource.plugin.parkourcompetition.listener.GameListener;
import cc.carm.outsource.plugin.parkourcompetition.manager.ParkourManager;

public class Main extends EasyPlugin {

Expand All @@ -13,6 +17,7 @@ public class Main extends EasyPlugin {
protected ConfigurationProvider<?> configProvider;
protected ConfigurationProvider<?> messageProvider;

protected ParkourManager parkourManager;

@Override
public boolean initialize() {
Expand All @@ -25,12 +30,14 @@ public boolean initialize() {
this.messageProvider = MineConfiguration.from(this, "messages.yml");
this.messageProvider.initialize(PluginMessages.class);

return true;
}
log("加载监听器...");
registerListener(new GameListener(this));
registerListener(new FireworkListener(this));

@Override
protected void shutdown() {
log("加载指令...");
registerCommand("ParkourCompetition", new PluginCommand());

return true;
}

@Override
Expand Down Expand Up @@ -62,4 +69,8 @@ public static void debugging(String... messages) {
getInstance().debug(messages);
}

public static ParkourManager getParkourManager() {
return getInstance().parkourManager;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package cc.carm.outsource.plugin.parkourcompetition.command;

import cc.carm.outsource.plugin.parkourcompetition.Main;
import cc.carm.outsource.plugin.parkourcompetition.conf.PluginConfig;
import cc.carm.outsource.plugin.parkourcompetition.conf.PluginMessages;
import cc.carm.outsource.plugin.parkourcompetition.manager.ParkourManager;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;

public class PluginCommand implements CommandExecutor {


@Override
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, @NotNull String[] args) {
ParkourManager parkour = Main.getParkourManager();

if (!(sender instanceof Player player)) {
if (!parkour.isStarted()) {
parkour.prepareGame();
sender.sendMessage("开始比赛...");
} else {
sender.sendMessage("比赛已经开始了");
}
return true;
}

if (parkour.getJoinedUUIDs().contains(player.getUniqueId())) {
PluginMessages.GAME.QUIT.send(player);
parkour.getJoinedUUIDs().remove(player.getUniqueId());
} else {
PluginMessages.GAME.JOIN.send(player);
parkour.getJoinedUUIDs().add(player.getUniqueId());
player.teleport(PluginConfig.LOCATIONS.WAIT.getNotNull());
}

return false;
}


}
Original file line number Diff line number Diff line change
@@ -1,12 +1,136 @@
package cc.carm.outsource.plugin.parkourcompetition.conf;

import cc.carm.lib.configuration.core.ConfigurationRoot;
import cc.carm.lib.configuration.core.annotation.HeaderComment;
import cc.carm.lib.configuration.core.value.ConfigValue;
import cc.carm.lib.configuration.core.value.type.ConfiguredValue;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSerializable;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredSound;
import cc.carm.lib.mineconfiguration.bukkit.value.ConfiguredTitle;
import cc.carm.outsource.plugin.parkourcompetition.data.DataBlockLocation;
import cc.carm.outsource.plugin.parkourcompetition.data.DataCubeArea;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;

import java.util.Objects;

public class PluginConfig extends ConfigurationRoot {

public static final ConfigValue<Boolean> DEBUG = ConfiguredValue.of(Boolean.class, false);

@HeaderComment({"在 HubParkour 插件中配置的跑酷ID"})
public static final ConfigValue<Integer> PARKOUR_ID = ConfiguredValue.of(Integer.class, 1);


@HeaderComment("游戏相关配置")
public static final class GAME {

@HeaderComment({"空气墙范围"})
public static final ConfigValue<DataCubeArea> WALL_BLOCKS = ConfiguredSerializable.of(
DataCubeArea.class, new DataCubeArea(
Objects.requireNonNull(Bukkit.getWorld("pmpc-1")),
new DataBlockLocation(-89, 78, 78),
new DataBlockLocation(-85, 83, 78)
)
);

public static final class PREPARE {

public static final ConfiguredSound SOUND = ConfiguredSound.of(Sound.BLOCK_NOTE_BLOCK_PLING);

public static final ConfiguredTitle TITLE = ConfiguredTitle.create()
.defaults("&f比赛将在 &e%(time) &f秒后开始", "&7&o请做好准备")
.params("time").fadeIn(0).stay(25).fadeOut(0)
.whenSend((player, fadeIn, stay, fadeOut, line1, line2) -> player.sendTitle(line1, line2, fadeIn, stay, fadeOut))
.build();

}

public static final class START {

public static final ConfiguredSound SOUND = ConfiguredSound.of(Sound.ENTITY_ENDER_DRAGON_GROWL, 0.5F);

public static final ConfiguredTitle TITLE = ConfiguredTitle.create()
.defaults("&e&l比赛开始", "&f迅速到达终点取得前三名!")
.fadeIn(0).stay(25).fadeOut(10)
.whenSend((player, fadeIn, stay, fadeOut, line1, line2) -> player.sendTitle(line1, line2, fadeIn, stay, fadeOut))
.build();

}


public static final class FINISH {

public static final ConfiguredSound SOUND = ConfiguredSound.of(Sound.ENTITY_PLAYER_LEVELUP);

public static final ConfiguredTitle TITLE = ConfiguredTitle.create()
.defaults("&e&l恭喜您完成了比赛!", "&f共耗时 %(time) &f秒")
.params("time").fadeIn(0).stay(100).fadeOut(40)
.whenSend((player, fadeIn, stay, fadeOut, line1, line2) -> player.sendTitle(line1, line2, fadeIn, stay, fadeOut))
.build();

}

public static final class END {

public static final ConfiguredSound SOUND = ConfiguredSound.of(Sound.UI_TOAST_CHALLENGE_COMPLETE);

}


}

@HeaderComment({"玩家可以用来放烟花的工具"})
public static final class FIREWORK {

@HeaderComment({"烟花区域配置,在此区域内可以放烟花"})
public static final ConfigValue<DataCubeArea> AREA = ConfiguredSerializable.of(
DataCubeArea.class, new DataCubeArea(
Objects.requireNonNull(Bukkit.getWorld("pmpc")),
new DataBlockLocation(158, 120, -62),
new DataBlockLocation(265, 68, 6)
)
);

@HeaderComment({"用来放烟花的物品类型,默认是火把,即玩家手持火把右键即可随机放烟花。"})
public static final ConfigValue<Material> ITEM_TYPE = ConfigValue.builder()
.asValue(Material.class).fromString()
.parseValue((s, d) -> Material.matchMaterial(s))
.serializeValue(Material::name)
.defaults(Material.TORCH)
.build();

@HeaderComment({"玩家放烟花的冷却时间,单位为毫秒。默认为 1000 毫秒(1秒)。"})
public static final ConfigValue<Integer> COOLDOWN = ConfiguredValue.of(Integer.class, 1000);

}

@HeaderComment({"传送点配置"})
public static final class LOCATIONS {

@HeaderComment({"等待区域的传送点"})
public static final ConfiguredSerializable<Location> WAIT = ConfiguredSerializable.of(
Location.class, new Location(Bukkit.getWorld("pmpc"), 207, 70, -113)
);

@HeaderComment({"游戏区域的传送点"})
public static final ConfiguredSerializable<Location> GAME = ConfiguredSerializable.of(
Location.class, new Location(Bukkit.getWorld("pmpc-1"), -87, 78, 82)
);

@HeaderComment("结束区域的传送点")
public static final ConfiguredSerializable<Location> FINISH = ConfiguredSerializable.of(
Location.class, new Location(Bukkit.getWorld("pmpc"), 207, 93, -32)
);

@HeaderComment({"颁奖台的传送点位置"})
public static final ConfiguredSerializable<Location> PODIUM = ConfiguredSerializable.of(
Location.class, new Location(Bukkit.getWorld("pmpc"), 207, 95, -54)
);

}


}
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,43 @@ public class PluginMessages extends ConfigurationRoot {
};
}

public static final ConfiguredMessage<String> LOAD_FAILED = ConfiguredMessage.asString()
.defaults("&c您的用户数据未被正确加载,请重新进入!")
.build();

public static final class GAME {


public static final ConfiguredMessageList<BaseComponent[]> JOIN = list()
.defaults("&a&l参赛成功!&f您将在游戏开始时传送到对应比赛地点。")
.build();

public static final ConfiguredMessageList<BaseComponent[]> QUIT = list()
.defaults("&a&l退赛完成!&f请自行通过菜单 或 [&6点击这里](command=/c) &f离开准备区域。")
.build();

public static final ConfiguredMessageList<BaseComponent[]> FINISH = list()
.defaults("&e&l恭喜!&f您完成了本次跑酷比赛,总耗时 &6%(time)秒 &f,排名为 &6#%(index) &f!")
.params("time", "index").build();


public static final ConfiguredMessageList<BaseComponent[]> END = list()
.defaults(
"&e&l比赛结束!&f比赛的前三名已经产生,分别是:",
" &8#%(p1_index) &6&l%(p1_name) &f用时 &6%(p1_time)秒",
" &8#%(p2_index) &6&l%(p2_name) &f用时 &6%(p2_time)秒",
" &8#%(p3_index) &6&l%(p3_name) &f用时 &6%(p3_time)秒",
"&f未完成的也气馁,继续努力,我们仍有下次比赛哦~"
).params(
"p1_index", "p1_name", "p1_time",
"p2_index", "p2_name", "p2_time",
"p3_index", "p3_name", "p3_time"
).build();

}

public static final class FIREWORK {

public static final ConfiguredMessageList<BaseComponent[]> IN_COOLDOWN = list()
.defaults("&f您需要等待 &c%(cooldown) &f秒才能再次发射烟花哦~")
.params("cooldown").build();
}

}
Loading

0 comments on commit fb4e7a2

Please sign in to comment.