Skip to content

Commit

Permalink
Merge pull request #70 from Gu-ZT/1.19.2updateTo1.2.1
Browse files Browse the repository at this point in the history
build(curtain): Update mod version to 1.2.1
  • Loading branch information
DancingSnow0517 authored Apr 9, 2023
2 parents bf29d55 + 88860f4 commit 2ccce11
Show file tree
Hide file tree
Showing 35 changed files with 562 additions and 622 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ minecraft_version=1.19.2
# Mod Info
maven_group=dev.dubhe
archives_base_name=curtain
version=1.2.0
version=1.2.1
build_number = undefined
2 changes: 1 addition & 1 deletion src/main/java/dev/dubhe/curtain/CurtainRules.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package dev.dubhe.curtain;

import dev.dubhe.curtain.api.rules.CurtainRule;
import dev.dubhe.curtain.api.rules.Rule;
import dev.dubhe.curtain.api.rules.IValidator;
import dev.dubhe.curtain.api.rules.Rule;
import dev.dubhe.curtain.api.rules.Validators;
import dev.dubhe.curtain.utils.TranslationHelper;
import net.minecraft.commands.CommandSourceStack;
Expand Down
1 change: 0 additions & 1 deletion src/main/java/dev/dubhe/curtain/ICurtain.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import dev.dubhe.curtain.utils.TranslationHelper;

import java.io.InputStream;
import java.io.Reader;

public interface ICurtain {

Expand Down
8 changes: 7 additions & 1 deletion src/main/java/dev/dubhe/curtain/api/rules/Rule.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package dev.dubhe.curtain.api.rules;

import java.lang.annotation.*;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Documented
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Rule {
String[] categories();

Class<? extends IValidator<?>>[] validators() default {};

String[] suggestions();

String serializedName() default "";
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/dev/dubhe/curtain/api/rules/Validators.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@
import java.util.List;

public final class Validators {
private Validators(){}
private Validators() {
}

public static class CommandLevel implements IValidator<String> {
public static final List<String> OPTIONS = List.of("true", "false", "ops", "0", "1", "2", "3", "4");

@Override
public boolean validate(CommandSourceStack source, CurtainRule<String> rule, String newValue) {
boolean is_valid = OPTIONS.contains(newValue);
if(source!=null && is_valid)
if (source != null && is_valid)
CommandHelper.notifyPlayersCommandsChanged(source.getServer());
return is_valid;
}
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/dev/dubhe/curtain/commands/PlayerCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@
import net.minecraft.world.phys.Vec2;
import net.minecraft.world.phys.Vec3;

import java.util.*;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Consumer;

import static net.minecraft.commands.Commands.argument;
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/dev/dubhe/curtain/commands/RuleCommand.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package dev.dubhe.curtain.commands;

import com.mojang.brigadier.CommandDispatcher;
import com.mojang.brigadier.arguments.*;
import com.mojang.brigadier.arguments.ArgumentType;
import com.mojang.brigadier.arguments.BoolArgumentType;
import com.mojang.brigadier.arguments.DoubleArgumentType;
import com.mojang.brigadier.arguments.FloatArgumentType;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.arguments.StringArgumentType;
import com.mojang.brigadier.builder.ArgumentBuilder;
import com.mojang.brigadier.context.CommandContext;
import dev.dubhe.curtain.Curtain;
Expand All @@ -19,7 +24,9 @@
import net.minecraft.network.chat.Style;
import org.jetbrains.annotations.NotNull;

import static dev.dubhe.curtain.utils.TranslationKeys.*;
import static dev.dubhe.curtain.utils.TranslationKeys.AS_DEFAULT;
import static dev.dubhe.curtain.utils.TranslationKeys.CHANGE;
import static dev.dubhe.curtain.utils.TranslationKeys.CHANGE_DEFAULT;
import static net.minecraft.commands.SharedSuggestionProvider.suggest;

public class RuleCommand {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@

public class PlayerLoggedEventHandler {
@SubscribeEvent
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event){
FAKE_PLAYER_INVENTORY_MENU_MAP.put(event.getEntity(),new FakePlayerInventoryMenu(event.getEntity()));
public void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
FAKE_PLAYER_INVENTORY_MENU_MAP.put(event.getEntity(), new FakePlayerInventoryMenu(event.getEntity()));
}

@SubscribeEvent
public void onPlayerLeave(PlayerEvent.PlayerLoggedOutEvent event){
public void onPlayerLeave(PlayerEvent.PlayerLoggedOutEvent event) {
FAKE_PLAYER_INVENTORY_MENU_MAP.remove(event.getEntity());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@

public class PlayerTickEventHandler {
@SubscribeEvent
public void onTick(TickEvent.PlayerTickEvent playerTickEvent){
if(CurtainRules.openFakePlayerInventory &&
public void onTick(TickEvent.PlayerTickEvent playerTickEvent) {
if (CurtainRules.openFakePlayerInventory &&
playerTickEvent.player instanceof ServerPlayer serverPlayer &&
serverPlayer instanceof EntityPlayerMPFake &&
serverPlayer.isAlive()
){
) {
FAKE_PLAYER_INVENTORY_MENU_MAP.get(serverPlayer).tick();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,22 @@

public class entityInteractHandler {
@SubscribeEvent
public void onInteractWithFakePlayer(PlayerInteractEvent.EntityInteract entityInteract){
if(entityInteract.getTarget() instanceof EntityPlayerMPFake fakeplayer){
public void onInteractWithFakePlayer(PlayerInteractEvent.EntityInteract entityInteract) {
if (entityInteract.getTarget() instanceof EntityPlayerMPFake fakeplayer) {
SimpleMenuProvider provider = null;
if (CurtainRules.openFakePlayerEnderChest && entityInteract.getEntity().isShiftKeyDown()) {
provider = new SimpleMenuProvider(
(i,inventory,p)->
(i, inventory, p) ->
ChestMenu.threeRows(
i,
inventory,
fakeplayer.getEnderChestInventory()
),
fakeplayer.getDisplayName()
);
}
else if(CurtainRules.openFakePlayerInventory){
} else if (CurtainRules.openFakePlayerInventory) {
provider = new SimpleMenuProvider(
(i,inventory,p)->
(i, inventory, p) ->
ChestMenu.sixRows(
i,
inventory,
Expand All @@ -36,7 +35,7 @@ else if(CurtainRules.openFakePlayerInventory){
fakeplayer.getDisplayName()
);
}
if(provider != null)
if (provider != null)
entityInteract.getEntity().openMenu(provider);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@
import net.minecraft.network.chat.Component;
import net.minecraft.server.level.ServerPlayer;

import java.util.function.Supplier;

public abstract class AbstractLogger {
private final String name;
private final DisplayType type;

public AbstractLogger(String name, DisplayType type) {
this.name = name;
this.type = type;
Expand All @@ -17,6 +16,7 @@ public AbstractLogger(String name) {
this.name = name;
this.type = DisplayType.CHAT;
}

public String getName() {
return name;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,12 @@
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.server.level.ServerPlayer;

import java.util.*;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

public class LoggerManager {
private static final Map<String, AbstractLogger> registeredLogger = new HashMap<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public Component display(ServerPlayer player) {
long usedMemory = totalMemory - freeMemory;
MutableComponent msg = Component.empty();
msg.append(Component.literal("%.1f".formatted(usedMemory / 1024 / 1024f) + " M")
.withStyle(ChatFormatting.GRAY));
.withStyle(ChatFormatting.GRAY));
msg.append(Component.literal(" / ").withStyle(ChatFormatting.WHITE));
msg.append(Component.literal("%.1f".formatted(totalMemory / 1024 / 1024f) + " M")
.withStyle(ChatFormatting.GRAY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import net.minecraft.world.entity.EntityType;
import net.minecraft.world.level.Explosion;
import net.minecraft.world.phys.Vec3;

import net.minecraftforge.registries.ForgeRegistries;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ public interface IEntity {
void setPortalTimer(int amount);

int getPublicNetherPortalCooldown();

void setPublicNetherPortalCooldown(int what);
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@

public interface IServerPlayer {
EntityPlayerActionPack getActionPack();

void invalidateEntityObjectReference();

boolean isInvalidEntityObject();

String getLanguage();
}
Loading

0 comments on commit 2ccce11

Please sign in to comment.