Skip to content

Commit

Permalink
初次嘗試 - 輝煌特製版
Browse files Browse the repository at this point in the history
  • Loading branch information
RICE0707 committed Oct 13, 2024
1 parent cebac5c commit 5c0adab
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 41 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build

on:
push:
branches:
- main
pull_request:
workflow_dispatch:

jobs:
Build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Get github short hash
id: github_short_hash
run: echo "::set-output name=result::$(git rev-parse --short "${{ github.sha }}")"
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
distribution: 'adopt'
java-version: 17
- name: Cache
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
.gradle
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties', 'build.gradle.kts') }}
- name: Build with Gradle
run: |
chmod +x gradlew
./gradlew build
timeout-minutes: 10
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: bcnp
path: ${{ github.workspace }}/build/libs
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ public void onPlayerJoin(PlayerJoinEvent event) {
return;
}

if (player.hasPermission("nerfphantoms.disablespawn.auto")) {
if (player.hasPermission("bcnp.disablespawn.auto")) {
PhantomUtils.togglePhantomSpawn(player, false);
return;
}

try {
if (!player.hasPermission("nerfphantoms.disablespawn.self")){
if (!player.hasPermission("bcnp.disablespawn.self")){
Nerfphantoms_folia.getInstance().storage.setPhantomDisabled(player.getUniqueId(), false);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ public class NerfphantomsCommand implements CommandExecutor {

PluginCommand pluginCommand;
protected NerfphantomsCommand() {
pluginCommand = Nerfphantoms_folia.getInstance().getCommand("nerfphantoms");
pluginCommand = Nerfphantoms_folia.getInstance().getCommand("cnp");
if (pluginCommand != null){
pluginCommand.setTabCompleter(new TabCompletion());
pluginCommand.setExecutor(this);
Expand All @@ -26,63 +26,61 @@ public void execute(@NotNull CommandSender sender, @NotNull String[] args) {
assert (permissionMessage != null);

if (args[0].equalsIgnoreCase("reload")) {
if (!sender.hasPermission("nerfphantoms.reload")) {
if (!sender.hasPermission("bcnp.reload")) {
sender.sendMessage(permissionMessage);
return;
}
Nerfphantoms_folia.getInstance().reloadConfig();
Nerfphantoms_folia.getInstance().config = Nerfphantoms_folia.getInstance().getConfig();

Nerfphantoms_folia.getInstance().logger.info("Reloaded configuration");
Nerfphantoms_folia.getInstance().logger.info("§7|§6系統§7|§f飯娘:§7已重新載入設置。");
if (sender instanceof Player) {
sender.sendMessage("Reloaded configuration");
sender.sendMessage("§7|§6系統§7|§f飯娘:§7已重新載入設置。");
}
return;
}

if (args[0].equalsIgnoreCase("kill")) {
if (!sender.hasPermission("nerfphantoms.kill")) {
if (!sender.hasPermission("bcnp.kill")) {
sender.sendMessage(permissionMessage);
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("Command has to be executed by a player");
sender.sendMessage("§7|§6系統§7|§f飯娘:§7該指令只能由玩家使用。");
return;
}
Player player = (Player) sender;
int n = PhantomUtils.killAllPhantoms(player.getWorld());
player.sendMessage("Killed " + n + " phantoms.");
player.sendMessage("§7|§6系統§7|§f飯娘:§7已擊殺§6 " + n + " §7隻夜魅。");
return;
}

if (args[0].equalsIgnoreCase("togglespawn")) {
if (args[0].equalsIgnoreCase("toggle")) {
if (args.length == 1) {
if (!sender.hasPermission("nerfphantoms.disablespawn.self")) {
if (!sender.hasPermission("bcnp.disablespawn.self")) {
sender.sendMessage(permissionMessage);
return;
}
if (!(sender instanceof Player)) {
sender.sendMessage("Command has to be executed by a player");
sender.sendMessage("§7|§6系統§7|§f飯娘:§7該指令只能由玩家使用。");
return;
}
Player player = (Player) sender;
boolean state = PhantomUtils.togglePhantomSpawn(player);
player.sendMessage((state ? "Disabled" : "Enabled")
+ " phantom spawn for " + player.getName() + ".");
player.sendMessage("§7|§6系統§7|§f飯娘:§7" + (state ? "§c已停用" : "§a已啟用") + "§6" + player.getName() + "§7的夜魅生成。");
return;
}
if (!sender.hasPermission("nerfphantoms.disablespawn.others")) {
if (!sender.hasPermission("bcnp.disablespawn.others")) {
sender.sendMessage(permissionMessage);
return;
}
Player victim = Bukkit.getPlayer(args[1]);
if (victim == null) {
sender.sendMessage("Unable to find player!");
sender.sendMessage("§7|§6系統§7|§f飯娘:§7找不到該玩家");
return;
}
boolean state = PhantomUtils.togglePhantomSpawn(victim);
sender.sendMessage((state ? "Disabled" : "Enabled")
+ " phantom spawn for " + victim.getName() + ".");
sender.sendMessage("§7|§6系統§7|§f飯娘:§7" + (state ? "§c已停用" : "§a已啟用") + "§6" + victim.getName() + "§7的夜魅生成。");
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@
public class TabCompletion implements TabCompleter {
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, Command cmd, @NotNull String label, String[] args) {
if (cmd.getName().equalsIgnoreCase("nerfphantoms") && args.length == 1) {
if (cmd.getName().equalsIgnoreCase("cnp") && args.length == 1) {
List<String> list = new ArrayList<>();
list.add("help");

if (sender.hasPermission("nerfphantoms.disablespawn.self")) {
list.add("togglespawn");
if (sender.hasPermission("bcnp.disablespawn.self")) {
list.add("toggle");
}

if (sender.hasPermission("nerfphantoms.reload")) {
if (sender.hasPermission("bcnp.reload")) {
list.add("reload");
}

if (sender.hasPermission("nerfphantoms.kill")) {
if (sender.hasPermission("bcnp.kill")) {
list.add("kill");
}

Expand Down
36 changes: 18 additions & 18 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
name: nerfphantoms-folia
name: bcnp-folia
version: '${version}'
main: org.altronmaxx.nerfphantomsfolia.Nerfphantoms_folia
api-version: 1.20
folia-supported: true
commands:
nerfphantoms:
usage: /nerfphantoms <help | togglespawn | kill | reload>
permission-message: You don't have permission.
usage: /cnp <help | toggle | kill | reload>
permission-message: §7|§6系統§7|§f飯娘:§7你沒權限。
permissions:
nerfphantoms.*:
bcnp.*:
description: Gives access to all NerfPhantoms commands
default: op
children:
nerfphantoms.all: true
nerfphantoms.all:
bcnp.all: true
bcnp.all:
description: Gives access to all NerfPhantoms commands
children:
nerfphantoms.reload: true
nerfphantoms.kill: true
nerfphantoms.disablespawn.self: true
nerfphantoms.disablespawn.others: true
nerfphantoms.reload:
bcnp.reload: true
bcnp.kill: true
bcnp.disablespawn.self: true
bcnp.disablespawn.others: true
bcnp.reload:
description: Reload plugin config
default: false
nerfphantoms.kill:
default: op
bcnp.kill:
description: Kill all phantoms in current world
default: false
nerfphantoms.disablespawn.self:
default: op
bcnp.disablespawn.self:
description: Command to disable phantom spawning for self
default: op
nerfphantoms.disablespawn.others:
bcnp.disablespawn.others:
description: Command to disable phantom spawning for other players
default: op
nerfphantoms.disablespawn.auto:
bcnp.disablespawn.auto:
description: Phantom spawn disable active by default for player
default: false
default: op

0 comments on commit 5c0adab

Please sign in to comment.