Skip to content

Commit

Permalink
Mixins clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
thecatcore committed Nov 28, 2024
1 parent e90c962 commit 1f29b36
Show file tree
Hide file tree
Showing 17 changed files with 28 additions and 205 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
]
},
"description": "Powerful Command API that uses SpongeAPI's command api",
"mixins": [
"legacy-fabric-sponge-command-api-v2.mixins.json"
],
"mixins": [],
"custom": {
"modmenu": {
"badges": [ "library" ],
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
]
},
"description": "Powerful Command API that uses SpongeAPI's command api",
"mixins": [
"legacy-fabric-sponge-command-api-v2.mixins.json"
],
"mixins": [],
"custom": {
"modmenu": {
"badges": [ "library" ],
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
]
},
"description": "Powerful Command API that uses SpongeAPI's command api",
"mixins": [
"legacy-fabric-sponge-command-api-v2.mixins.json"
],
"mixins": [],
"custom": {
"modmenu": {
"badges": [ "library" ],
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@

import java.util.List;

import net.legacyfabric.fabric.impl.command.CrossCompatibleText;

import org.jetbrains.annotations.Nullable;

import net.minecraft.server.MinecraftServer;
Expand Down Expand Up @@ -134,7 +132,7 @@ public void parse(PermissibleCommandSource source, CommandArgs args, CommandCont
* @return The formatted usage
*/
public Text getUsage(PermissibleCommandSource src) {
return this.getKey() == null ? new LiteralText("") : new LiteralText("<" + ((CrossCompatibleText) this.getKey()).asSanitizedString() + ">");
return this.getKey() == null ? new LiteralText("") : new LiteralText("<" + this.getKey().asUnformattedString() + ">");
}

public MinecraftServer getServer() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
/*
* Copyright (c) 2020 - 2024 Legacy Fabric
* Copyright (c) 2016 - 2022 FabricMC
*
* 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 net.legacyfabric.fabric.impl.command;

import java.util.Arrays;

import com.google.common.base.Preconditions;
import org.jetbrains.annotations.Nullable;

import java.util.Arrays;

/**
* Guava's ToStringHelper class which isn't located at the same place depending on guava versions.
* This ensures it is available in all targeted versions.
Expand Down Expand Up @@ -35,78 +52,63 @@ private ToStringHelper(String className) {
this.className = (String) Preconditions.checkNotNull(className);
}


public ToStringHelper omitNullValues() {
this.omitNullValues = true;
return this;
}


public ToStringHelper add(String name, @Nullable Object value) {
return this.addHolder(name, value);
}


public ToStringHelper add(String name, boolean value) {
return this.addHolder(name, String.valueOf(value));
}


public ToStringHelper add(String name, char value) {
return this.addHolder(name, String.valueOf(value));
}


public ToStringHelper add(String name, double value) {
return this.addHolder(name, String.valueOf(value));
}


public ToStringHelper add(String name, float value) {
return this.addHolder(name, String.valueOf(value));
}


public ToStringHelper add(String name, int value) {
return this.addHolder(name, String.valueOf(value));
}


public ToStringHelper add(String name, long value) {
return this.addHolder(name, String.valueOf(value));
}


public ToStringHelper addValue(@Nullable Object value) {
return this.addHolder(value);
}


public ToStringHelper addValue(boolean value) {
return this.addHolder(String.valueOf(value));
}


public ToStringHelper addValue(char value) {
return this.addHolder(String.valueOf(value));
}


public ToStringHelper addValue(double value) {
return this.addHolder(String.valueOf(value));
}


public ToStringHelper addValue(float value) {
return this.addHolder(String.valueOf(value));
}


public ToStringHelper addValue(int value) {
return this.addHolder(String.valueOf(value));
}


public ToStringHelper addValue(long value) {
return this.addHolder(String.valueOf(value));
}
Expand All @@ -118,9 +120,11 @@ public String toString() {

for (ValueHolder valueHolder = this.holderHead.next; valueHolder != null; valueHolder = valueHolder.next) {
Object value = valueHolder.value;

if (!omitNullValuesSnapshot || value != null) {
builder.append(nextSeparator);
nextSeparator = ", ";

if (valueHolder.name != null) {
builder.append(valueHolder.name).append('=');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
"entrypoints": {
},
"description": "Powerful Command API that uses SpongeAPI's command api",
"mixins": [
"legacy-fabric-sponge-command-api-v2-common.mixins.json"
],
"mixins": [],
"custom": {
"modmenu": {
"badges": [ "library" ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,16 @@
* limitations under the License.
*/

package net.legacyfabric.fabric.mixin.command;
package net.legacyfabric.fabric.mixin.permission;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;

import net.minecraft.server.MinecraftServer;

import net.legacyfabric.fabric.api.permission.v1.PermissibleCommandSource;

@Mixin(MinecraftServer.class)
public abstract class MinecraftServerMixin implements PermissibleCommandSource {
@Shadow
public abstract boolean isDedicated();

@Override
public boolean hasPermission(String perm) {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"mixins": [
"ConsoleMixin",
"EntityMixin",
"MinecraftServerMixin",
"ServerPlayerEntityMixin"
],
"injectors": {
Expand Down

0 comments on commit 1f29b36

Please sign in to comment.