update README.md
This commit is contained in:
11
README.md
11
README.md
@@ -4,24 +4,17 @@
|
||||
|
||||
<p>在游戏中添加统计信息来统计玩家挖掘数据, 可以借助计分板显示出数据</p>
|
||||
|
||||
<img src="https://static-flax.vercel.app/static/kotlin/made-with-kotlin.svg">
|
||||
|
||||
<br>
|
||||
|
||||
<img alt="GitHub" src="https://img.shields.io/github/license/DangoTown/RMC?logo=apache">
|
||||
<img alt="GitHub Workflow Status" src="https://img.shields.io/github/actions/workflow/status/DangoTown/RMC/ci.yaml">
|
||||
<img alt="Kotlin Version" src="https://img.shields.io/badge/Kotlin-1.8.22-pink?logo=kotlin">
|
||||
</div>
|
||||
|
||||
# 依赖
|
||||
|
||||
* 由于使用了`Kotlin`语言所以你需要放置`fabric-language-kotlin`在你的mods文件夹内. 点击[这里](https://github.com/FabricMC/fabric-language-kotlin/releases/latest)快速下载最新版本的`fabric-language-kotlin`
|
||||
|
||||
# 使用
|
||||
|
||||
* 默认是不会记录玩家挖掘数据的, 你需要添加一个计分板, 准则为`minecraft.custom:minecraft.rmc`的一个计分板, 以下为实例命令, 如有需要可以自行修改
|
||||
* 默认是不会记录玩家挖掘数据的, 你需要添加一个计分板, 准则为`minecraft.custom:minecraft.rmc.dig`的一个计分板, 以下为实例命令, 如有需要可以自行修改
|
||||
|
||||
* `/scoreboard objectives add rmc minecraft.custom:minecraft.rmc {"text":"挖掘榜", "color":"yellow"}`
|
||||
* `/scoreboard objectives add rmc minecraft.custom:minecraft.rmc.dig {"text":"挖掘榜", "color":"yellow"}`
|
||||
|
||||
* 上面的命令执行完成后所有玩家破坏任何方块都会使其加1(常规情况下破坏方块), 使用以下命令来显示出计分板
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 RTAkland
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.rtast.rmc
|
||||
|
||||
import cn.rtast.rmc.mixin.StatsAccessor
|
||||
import com.google.common.collect.Sets
|
||||
import net.fabricmc.api.DedicatedServerModInitializer
|
||||
import net.minecraft.stat.Stat
|
||||
import net.minecraft.stat.StatFormatter
|
||||
import net.minecraft.util.Identifier
|
||||
|
||||
class RMC : DedicatedServerModInitializer {
|
||||
|
||||
companion object {
|
||||
private val stats: MutableSet<String> = Sets.newHashSet()
|
||||
|
||||
var RMC_STAT_ID: Identifier? = null
|
||||
|
||||
private fun addStat(stat: Identifier) {
|
||||
stats.add(stat.toString())
|
||||
}
|
||||
|
||||
fun registerStats() {
|
||||
addStat(StatsAccessor.callRegister("rmc", StatFormatter.TIME).also { RMC_STAT_ID = it })
|
||||
}
|
||||
|
||||
operator fun contains(stat: Stat<*>): Boolean {
|
||||
return stats.contains(stat.value.toString())
|
||||
}
|
||||
}
|
||||
|
||||
override fun onInitializeServer() {
|
||||
println("RMC 已加载!")
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 RTAkland
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.rtast.rmc.mixin;
|
||||
|
||||
import cn.rtast.rmc.RMC;
|
||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||
import net.minecraft.server.network.ServerPlayerEntity;
|
||||
import net.minecraft.stat.ServerStatHandler;
|
||||
import net.minecraft.stat.Stat;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Redirect;
|
||||
|
||||
@Mixin(ServerStatHandler.class)
|
||||
public abstract class ServerStatHandlerMixin {
|
||||
@Redirect(method = "sendStats", at = @At(value = "INVOKE", target = "Lit/unimi/dsi/fastutil/objects/Object2IntMap;put(Ljava/lang/Object;I)I"), remap = false)
|
||||
private int excludeCustomStats(Object2IntMap<Stat<?>> map, Object object, int value, ServerPlayerEntity player) {
|
||||
if (!RMC.Companion.contains((Stat<?>) object)) {
|
||||
return map.put((Stat<?>) object, value);
|
||||
} else {
|
||||
return map.defaultReturnValue();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 RTAkland
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.rtast.rmc.mixin;
|
||||
|
||||
import net.minecraft.registry.Registry;
|
||||
import net.minecraft.stat.StatFormatter;
|
||||
import net.minecraft.stat.StatType;
|
||||
import net.minecraft.stat.Stats;
|
||||
import net.minecraft.util.Identifier;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.gen.Invoker;
|
||||
|
||||
@Mixin(Stats.class)
|
||||
public interface StatsAccessor {
|
||||
@Invoker
|
||||
static Identifier callRegister(String string, StatFormatter statFormatter) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Invoker
|
||||
static <T> StatType<T> callRegisterType(String string, Registry<T> registry) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright 2023 RTAkland
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.rtast.rmc.mixin;
|
||||
|
||||
import cn.rtast.rmc.RMC;
|
||||
import net.minecraft.stat.Stats;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
|
||||
@Mixin(Stats.class)
|
||||
public class StatsMixin {
|
||||
|
||||
static {
|
||||
RMC.Companion.registerStats();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"stat.rmc.rmc_stat": "挖掘数"
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
{
|
||||
"stat.rmc.rmc_stat": "Total number of blocks destroyed."
|
||||
}
|
||||
Reference in New Issue
Block a user