Skip to content

Commit

Permalink
✅ 新增规则:opPlayerNoCheatExtra
Browse files Browse the repository at this point in the history
  • Loading branch information
1024-byteeeee committed Nov 1, 2023
1 parent 3ad68c2 commit a31b3a4
Show file tree
Hide file tree
Showing 10 changed files with 315 additions and 6 deletions.
14 changes: 14 additions & 0 deletions readme_folder/en_us/rules_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,20 @@ Command: /anvilInteractionDisabledSwitch
- Categroies: `AMS` , `FEATURE` , `SURVIVAL`


## opPlayerNoCheatExtra

When enabled, Disable some command to prevent accidentally cheating, It is recommended to use it with opPlayerNoCheat from Carpet TIS Addition.
<br/>
Affects command list: /difficulty, /kill, /time, /weather.
<br/>
(Carpet TIS Addition)Affects command list: /gamemode, /tp, /teleport, /give, /setblock, /summon

- 类型: `boolean`
- 默认值: `false`
- 参考选项: `false` , `true`
- 分类: `AMS` , `FEATURE` , `SURVIVAL` , `COMMAND`


## movableEnderChest

Ender chest can be moved by piston or sticky piston.
Expand Down
17 changes: 16 additions & 1 deletion readme_folder/rules_cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,21 @@
- 类型: `boolean`
- 默认值: `false`
- 参考选项: `false` , `true`
- 分类: `AMS` , `FEATURE` , `SURVIVAL`
- 分类: `AMS` , `FEATURE` , `SURVIVAL` , `COMMAND`


## op玩家不准作弊拓展 (opPlayerNoCheatExtra)

开启后,禁用部分指令以避免op玩家意外地作弊, 建议与Carpet TIS Addition的opPlayerNoCheat一同使用。
<br/>
影响的指令列表: /difficulty, /kill, /time, /weather
<br/>
(Carpet TIS Addition)影响的指令列表:/gamemode, /tp, /teleport, /give, /setblock, /summon

- 类型: `boolean`
- 默认值: `false`
- 参考选项: `false` , `true`
- 分类: `AMS` , `FEATURE` , `SURVIVAL` , `COMMAND`


## 可移动末地传送门框架(movableEndPortalFrame)
Expand Down Expand Up @@ -537,6 +551,7 @@
- 参考选项: `false` , `true`
- 分类: `AMS` , `FEATURE` , `AMS_movable`


## 可移动幽匿催发体(movableSculkCatalyst)

开启后,幽匿催发体可以被活塞/黏性活塞推动。
Expand Down
5 changes: 4 additions & 1 deletion src/main/java/club/mcams/carpet/AmsServerSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,9 +176,12 @@ public class AmsServerSettings {
@Rule(categories = {AMS, FEATURE, SURVIVAL})
public static boolean easyWitherSkeletonSkullDrop = false;

@Rule(categories = {AMS, FEATURE, SURVIVAL})
@Rule(categories = {AMS, FEATURE, SURVIVAL, COMMAND})
public static boolean anvilInteractionDisabled = false;

@Rule(categories = {AMS, FEATURE, SURVIVAL, COMMAND})
public static boolean opPlayerNoCheatExtra = false;

/**
* 可移动方块规则
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* This file is part of the Carpet TIS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 Fallen_Breath and contributors
*
* Carpet TIS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet TIS Addition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet TIS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.opPlayerNoCheatExtra;

import club.mcams.carpet.AmsServerSettings;
import club.mcams.carpet.util.Messenger;
import static club.mcams.carpet.AmsServer.fancyName;

import net.minecraft.server.command.DifficultyCommand;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.world.Difficulty;
import net.minecraft.text.*;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(DifficultyCommand.class)
public abstract class DifficultyCommandMixin {
@Inject(method = "execute", at = @At("HEAD"))
private static void execute(ServerCommandSource source, Difficulty difficulty, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 A Minecraft Server and contributors
*
* Carpet AMS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet AMS Addition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.opPlayerNoCheatExtra;

import club.mcams.carpet.AmsServerSettings;
import club.mcams.carpet.util.Messenger;
import static club.mcams.carpet.AmsServer.fancyName;

import net.minecraft.entity.Entity;
import net.minecraft.server.command.KillCommand;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.text.*;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

import java.util.Collection;

@Mixin(KillCommand.class)
public abstract class KillCommandMixin {
@Inject(method = "execute", at = @At("HEAD"))
private static void execute(ServerCommandSource source, Collection<? extends Entity> targets, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 A Minecraft Server and contributors
*
* Carpet AMS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet AMS Addition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.opPlayerNoCheatExtra;

import club.mcams.carpet.AmsServerSettings;
import club.mcams.carpet.util.Messenger;
import static club.mcams.carpet.AmsServer.fancyName;

import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.command.TimeCommand;
import net.minecraft.text.*;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(TimeCommand.class)
public abstract class TimeCommandMixin {
@Inject(method = "executeAdd", at = @At("HEAD"))
private static void executeAdd(ServerCommandSource source, int time, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}

@Inject(method = "executeSet", at = @At("HEAD"))
private static void executeSet(ServerCommandSource source, int time, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}

@Inject(method = "executeQuery", at = @At("HEAD"))
private static void executeQuery(ServerCommandSource source, int time, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
* This file is part of the Carpet AMS Addition project, licensed under the
* GNU Lesser General Public License v3.0
*
* Copyright (C) 2023 A Minecraft Server and contributors
*
* Carpet AMS Addition is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Carpet AMS Addition is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Carpet AMS Addition. If not, see <https://www.gnu.org/licenses/>.
*/

package club.mcams.carpet.mixin.rule.opPlayerNoCheatExtra;

import club.mcams.carpet.AmsServerSettings;
import club.mcams.carpet.util.Messenger;
import static club.mcams.carpet.AmsServer.fancyName;

import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.command.WeatherCommand;
import net.minecraft.text.*;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;

@Mixin(WeatherCommand.class)
public abstract class WeatherCommandMixin {
@Inject(method = "executeClear", at = @At("HEAD"))
private static void executeClear(ServerCommandSource source, int duration, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}

@Inject(method = "executeRain", at = @At("HEAD"))
private static void executeRain(ServerCommandSource source, int duration, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}

@Inject(method = "executeThunder", at = @At("HEAD"))
private static void executeThunder(ServerCommandSource source, int duration, CallbackInfoReturnable<Integer> cir) {
if(AmsServerSettings.opPlayerNoCheatExtra) {
//#if MC>11800
//$$ Messenger.tell(source, Text.literal("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#else
Messenger.tell(source, (BaseText) new LiteralText("<" + fancyName + "> "+ "Disabled by opPlayerNoCheatExtra")
//#endif
.setStyle(Style.EMPTY.withColor(TextColor.fromRgb(0xFF0000))), true);
cir.cancel();
}
}
}
4 changes: 4 additions & 0 deletions src/main/resources/amscarpet.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"rule.largeEnderChest.SimpleInventoryAccessor",
"rule.movableBlocks.PistonBlockMixin",
"rule.netherWaterPlacement.DimensionTypeMixin",
"rule.opPlayerNoCheatExtra.DifficultyCommandMixin",
"rule.opPlayerNoCheatExtra.KillCommandMixin",
"rule.opPlayerNoCheatExtra.TimeCommandMixin",
"rule.opPlayerNoCheatExtra.WeatherCommandMixin",
"rule.optimizedDragonRespawn.BlockPatternTestTransformInvoker",
"rule.optimizedDragonRespawn.EnderDragonFightMixin",
"rule.safeFlight_safeVoid_invulnerable.ServerPlayerEntityMixin",
Expand Down
13 changes: 11 additions & 2 deletions src/main/resources/assets/carpetamsaddition/lang/en_us.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,17 @@ carpetamsaddition:
desc: 100% Wither Skeleton Skull Drop
anvilInteractionDisabled:
name: anvilInteractionDisabled
desc: 'Players cannot open the UI of the Anvil Command: /anvilInteractionDisabledSwitch'

desc: 'Players cannot open the UI of the Anvil'
extra:
'0': 'Command: /anvilInteractionDisabledSwitch'
opPlayerNoCheatExtra:
name: opPlayerNoCheatExtra
desc: Disable some command to prevent accidentally cheating
extra:
'0': 'It is recommended to use it with opPlayerNoCheat from Carpet TIS Addition'
'1': 'Affects command list: /difficulty, /kill, /time, /weather'
'2': '(Carpet TIS Addition)Affects command list: /gamemode, /tp, /teleport, /give, /setblock, /summon'

# 计划刻催熟规则:
scheduledRandomTickCactus:
name: scheduledRandomTickCactus
Expand Down
12 changes: 10 additions & 2 deletions src/main/resources/assets/carpetamsaddition/lang/zh_cn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,16 @@ carpetamsaddition:
desc: 击杀凋零骷髅会百分百掉落凋零骷髅头
anvilInteractionDisabled:
name: 禁用铁砧交互
desc: '玩家无法打开铁砧的UI界面 命令: /anvilInteractionDisabledSwitch'

desc: 玩家无法打开铁砧的UI界面
extra:
'0': '指令: /anvilInteractionDisabledSwitch'
opPlayerNoCheatExtra:
name: op玩家不准作弊拓展
desc: 禁用部分指令以避免op玩家意外地作弊
extra:
'0': '建议与Carpet TIS Addition的opPlayerNoCheat一同使用'
'1': '影响的指令列表: /difficulty, /kill, /time, /weather'
'2': '(Carpet TIS Addition)影响的指令列表:/gamemode, /tp, /teleport, /give, /setblock, /summon'

# 计划刻催熟规则:
scheduledRandomTickCactus:
Expand Down

0 comments on commit a31b3a4

Please sign in to comment.