Skip to content

Commit

Permalink
添加特性:假人名称前缀&假人名称后缀
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu-ZT committed Oct 14, 2024
1 parent 6ea2233 commit fb8b658
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 23 deletions.
51 changes: 34 additions & 17 deletions src/main/java/dev/dubhe/gugle/carpet/GcaSetting.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,64 +6,87 @@ public class GcaSetting {

public static final String GCA = "GCA";
public static final String EXPERIMENTAL = "experimental";
public static final String BOT = "BOT";

// 允许玩家打开假人背包
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean openFakePlayerInventory = false;

// 允许玩家打开假人末影箱
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean openFakePlayerEnderChest = false;

// 退出存档时保留假人
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean fakePlayerResident = false;

// 退出存档时保留假人动作
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean fakePlayerReloadAction = false;

// 让假人自动补货
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean fakePlayerAutoReplenishment = false;

// 让假人自动钓鱼
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean fakePlayerAutoFish = false;

// 让假人自动切换快损坏的工具
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL, BOT}
)
public static boolean fakePlayerAutoReplaceTool = false;

public static final String fakePlayerNoneName = "#none";

// 假人名称前缀
@Rule(
options = {fakePlayerNoneName, "bot_"},
categories = {GCA, EXPERIMENTAL, BOT}
)
public static String fakePlayerPrefixName = fakePlayerNoneName;

// 假人名称后缀
@Rule(
options = {fakePlayerNoneName, "_fake"},
categories = {GCA, EXPERIMENTAL, BOT}
)
public static String fakePlayerSuffixName = fakePlayerNoneName;

// // 方便快捷的假人管理菜单
// @Rule(
// categories = {GCA, EXPERIMENTAL, BOT}
// )
// public static boolean commandBot = false;

// 让放置的栅栏门与你点击的栅栏门拥有相同的方块状态
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL}
)
public static boolean betterFenceGatePlacement = false;

// 仅允许名称中包含“去皮”的斧头对原木去皮
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL}
)
public static boolean betterWoodStrip = false;

// 右键告示牌时与之附着的方块产生交互
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL}
)
public static boolean betterSignInteraction = false;

Expand All @@ -75,13 +98,7 @@ public class GcaSetting {

// 快速合成时在物品栏保留一份物品
@Rule(
categories = {GCA, EXPERIMENTAL}
categories = {GCA, EXPERIMENTAL}
)
public static boolean betterQuickCrafting = false;

// // 方便快捷的假人管理菜单
// @Rule(
// categories = {GCA, EXPERIMENTAL}
// )
// public static boolean botManagement = false;
}
29 changes: 29 additions & 0 deletions src/main/java/dev/dubhe/gugle/carpet/mixin/PlayerCommandMixin.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package dev.dubhe.gugle.carpet.mixin;

import carpet.commands.PlayerCommand;
import dev.dubhe.gugle.carpet.GcaSetting;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.ModifyVariable;

import java.util.Locale;

@Mixin(value = PlayerCommand.class, remap = false)
abstract class PlayerCommandMixin {
@ModifyVariable(method = "spawn", at = @At("STORE"), remap = false)
private static String spawn(String value) {
if (
!GcaSetting.fakePlayerNoneName.equals(GcaSetting.fakePlayerPrefixName)
&& !value.toLowerCase(Locale.ROOT).startsWith(GcaSetting.fakePlayerPrefixName.toLowerCase(Locale.ROOT))
) {
value = GcaSetting.fakePlayerPrefixName + value;
}
if (
!GcaSetting.fakePlayerNoneName.equals(GcaSetting.fakePlayerSuffixName)
&& !value.toLowerCase(Locale.ROOT).endsWith(GcaSetting.fakePlayerSuffixName.toLowerCase(Locale.ROOT))
) {
value = value + GcaSetting.fakePlayerSuffixName;
}
return value;
}
}
11 changes: 9 additions & 2 deletions src/main/resources/assets/gca/lang/en_us.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"carpet.category.GCA": "GCA",
"carpet.category.BOT": "BOT",

"carpet.rule.openFakePlayerInventory.name": "Fake Player Inventory",
"carpet.rule.openFakePlayerInventory.desc": "Allow player to open the fake player's inventory",
Expand Down Expand Up @@ -40,8 +41,14 @@
"carpet.rule.betterItemFrameInteraction.name": "Better ItemFrame Interaction",
"carpet.rule.betterItemFrameInteraction.desc": "Make the block attached to the ItemFrame interact when you right-click it",

"carpet.rule.botManagement.name": "Bot Management",
"carpet.rule.botManagement.desc": "A Bot Management Menu",
"carpet.rule.fakePlayerPrefixName.name": "Fake Player Prefix Name",
"carpet.rule.fakePlayerPrefixName.desc": "Fake Player Prefix Name",

"carpet.rule.fakePlayerSuffixName.name": "Fake Player Suffix Name",
"carpet.rule.fakePlayerSuffixName.desc": "Fake Player Suffix Name",

"carpet.rule.commandBot.name": "Bot Management",
"carpet.rule.commandBot.desc": "A Bot Management Menu",

"gca.action.attack.interval.12": "Attack every 12 gt: %s",
"gca.action.attack.continuous": "Attack continuous: %s",
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/assets/gca/lang/zh_cn.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"carpet.category.GCA": "GCA",
"carpet.category.BOT": "假人",

"carpet.rule.openFakePlayerInventory.name": "假人背包",
"carpet.rule.openFakePlayerInventory.desc": "允许玩家打开假人背包",
Expand Down Expand Up @@ -40,8 +41,14 @@
"carpet.rule.betterQuickCrafting.name": "更好的快速合成",
"carpet.rule.betterQuickCrafting.desc": "快速合成时在物品栏保留一份物品",

"carpet.rule.botManagement.name": "假人管理",
"carpet.rule.botManagement.desc": "一个假人管理菜单",
"carpet.rule.fakePlayerPrefixName.name": "假人名称前缀",
"carpet.rule.fakePlayerPrefixName.desc": "假人名称前缀",

"carpet.rule.fakePlayerSuffixName.name": "假人名称后缀",
"carpet.rule.fakePlayerSuffixName.desc": "假人名称后缀",

"carpet.rule.commandBot.name": "假人管理",
"carpet.rule.commandBot.desc": "一个假人管理菜单",

"gca.action.attack.interval.12": "间隔 12 gt攻击:%s",
"gca.action.attack.continuous": "一直左键: %s",
Expand Down
11 changes: 9 additions & 2 deletions src/main/resources/assets/gca/lang/zh_tw.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"carpet.category.GCA": "GCA",
"carpet.category.BOT": "BOT",

"carpet.rule.openFakePlayerInventory.name": "假人物品欄",
"carpet.rule.openFakePlayerInventory.desc": "允許玩家開啟假人的物品欄",
Expand Down Expand Up @@ -40,8 +41,14 @@
"carpet.rule.betterQuickCrafting.name": "Better Quick Crafting",
"carpet.rule.betterQuickCrafting.desc": "Keep an item in the inventory during quick crafting",

"carpet.rule.botManagement.name": "Bot Management",
"carpet.rule.botManagement.desc": "A Bot Management Menu",
"carpet.rule.fakePlayerPrefixName.name": "Fake Player Prefix Name",
"carpet.rule.fakePlayerPrefixName.desc": "Fake Player Prefix Name",

"carpet.rule.fakePlayerSuffixName.name": "Fake Player Suffix Name",
"carpet.rule.fakePlayerSuffixName.desc": "Fake Player Suffix Name",

"carpet.rule.commandBot.name": "Bot Management",
"carpet.rule.commandBot.desc": "A Bot Management Menu",

"gca.action.attack.interval.12": "間隔 12 gt攻擊:%s",
"gca.action.attack.continuous": "連續攻擊:%s",
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/gca.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"ItemFrameMixin",
"ItemStackMixin",
"PlayerAccessor",
"PlayerCommandMixin",
"PlayerMixin",
"ServerLevelMixin",
"ServerPlaceRecipeMixin",
Expand Down

0 comments on commit fb8b658

Please sign in to comment.