Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reset config and just make available to managers #10391

Open
wants to merge 1 commit into
base: version/main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public class ServerConfiguration extends AbstractConfiguration
public final ForgeConfigSpec.BooleanValue canPlayerUseKillCitizensCommand;
public final ForgeConfigSpec.BooleanValue canPlayerUseAddOfficerCommand;
public final ForgeConfigSpec.BooleanValue canPlayerUseDeleteColonyCommand;
public final ForgeConfigSpec.BooleanValue canPlayerUseResetCommand;

/* --------------------------------------------------------------------------- *
* ------------------- ######## Claim settings ######## ------------------- *
Expand Down Expand Up @@ -163,7 +162,6 @@ protected ServerConfiguration(final ForgeConfigSpec.Builder builder)
canPlayerUseKillCitizensCommand = defineBoolean(builder, "canplayerusekillcitizenscommand", false);
canPlayerUseAddOfficerCommand = defineBoolean(builder, "canplayeruseaddofficercommand", true);
canPlayerUseDeleteColonyCommand = defineBoolean(builder, "canplayerusedeletecolonycommand", false);
canPlayerUseResetCommand = defineBoolean(builder, "canplayeruseresetcommand", false);

swapToCategory(builder, "claims");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public class CommandTranslationConstants
@NonNls
public static final String COMMAND_REQUIRES_OP = "com.minecolonies.command.notop";
@NonNls
public static final String COMMAND_REQUIRES_OFFICER = "com.minecolonies.command.notofficer";
@NonNls
public static final String COMMAND_DISABLED_IN_CONFIG = "com.minecolonies.command.notenabledinconfig";
@NonNls
public static final String COMMAND_COLONY_ID_NOT_FOUND = "com.minecolonies.command.colonyidnotfound";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package com.minecolonies.core.commands.colonycommands.requestsystem;

import com.google.common.base.Stopwatch;
import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.colony.IColonyManager;
import com.minecolonies.api.util.constant.translation.CommandTranslationConstants;
import com.minecolonies.core.MineColonies;
import com.minecolonies.core.commands.commandTypes.IMCColonyOfficerCommand;
import com.minecolonies.core.commands.commandTypes.IMCCommand;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
Expand All @@ -13,7 +14,7 @@

import static com.minecolonies.core.commands.CommandArgumentNames.COLONYID_ARG;

public class CommandRSReset implements IMCCommand
public class CommandRSReset implements IMCColonyOfficerCommand
{
/**
* What happens when the command is executed after preConditions are successful.
Expand All @@ -32,14 +33,10 @@ public int onExecute(final CommandContext<CommandSourceStack> context)
return 0;
}

if (!context.getSource().hasPermission(OP_PERM_LEVEL) && !MineColonies.getConfig().getServer().canPlayerUseResetCommand.get())
{
context.getSource().sendSuccess(() -> Component.translatable(CommandTranslationConstants.COMMAND_DISABLED_IN_CONFIG), true);
return 0;
}

final Stopwatch watch = Stopwatch.createStarted();
colony.getRequestManager().reset();
context.getSource().sendSuccess(() -> Component.translatable(CommandTranslationConstants.COMMAND_REQUEST_SYSTEM_RESET_SUCCESS, colony.getName()), true);
watch.stop();
context.getSource().sendSuccess(() -> Component.translatable(CommandTranslationConstants.COMMAND_REQUEST_SYSTEM_RESET_SUCCESS, colony.getName(), watch.toString()), true);

return 1;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.minecolonies.core.commands.colonycommands.requestsystem;

import com.google.common.base.Stopwatch;
import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.colony.IColonyManager;
import com.minecolonies.core.commands.commandTypes.IMCOPCommand;
Expand All @@ -19,11 +20,13 @@ public class CommandRSResetAll implements IMCOPCommand
@Override
public int onExecute(final CommandContext<CommandSourceStack> context)
{
final Stopwatch watch = Stopwatch.createStarted();
for (final IColony colony : IColonyManager.getInstance().getAllColonies())
{
colony.getRequestManager().reset();
}
context.getSource().sendSuccess(() -> Component.translatable(COMMAND_REQUEST_SYSTEM_RESET_ALL_SUCCESS), true);
watch.stop();
context.getSource().sendSuccess(() -> Component.translatable(COMMAND_REQUEST_SYSTEM_RESET_ALL_SUCCESS, watch.toString()), true);

return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@

import com.minecolonies.api.colony.IColony;
import com.minecolonies.api.colony.IColonyManager;
import com.minecolonies.api.util.MessageUtils;
import com.mojang.brigadier.arguments.IntegerArgumentType;
import com.mojang.brigadier.context.CommandContext;
import net.minecraft.commands.CommandSourceStack;
import net.minecraft.network.chat.Component;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.player.Player;

import static com.minecolonies.api.util.constant.translation.CommandTranslationConstants.COMMAND_COLONY_ID_NOT_FOUND;
import static com.minecolonies.api.util.constant.translation.CommandTranslationConstants.COMMAND_REQUIRES_OFFICER;
import static com.minecolonies.core.commands.CommandArgumentNames.COLONYID_ARG;

/**
Expand All @@ -30,7 +31,7 @@ default boolean checkPreCondition(final CommandContext<CommandSourceStack> conte


final Entity sender = context.getSource().getEntity();
if (!(sender instanceof Player))
if (!(sender instanceof final Player player))
{
return false;
}
Expand All @@ -40,11 +41,17 @@ default boolean checkPreCondition(final CommandContext<CommandSourceStack> conte
final IColony colony = IColonyManager.getInstance().getColonyByDimension(colonyID, context.getSource().getLevel().dimension());
if (colony == null)
{
MessageUtils.format(COMMAND_COLONY_ID_NOT_FOUND, colonyID).sendTo((Player) sender);
context.getSource().sendFailure(Component.translatable(COMMAND_COLONY_ID_NOT_FOUND, colonyID));
return false;
}

// Check colony permissions
return IMCCommand.isPlayerOped((Player) sender) || colony.getPermissions().getRank((Player) sender).isColonyManager();
if (IMCCommand.isPlayerOped(player) || colony.getPermissions().getRank(player).isColonyManager())
{
return true;
}

context.getSource().sendFailure(Component.translatable(COMMAND_REQUIRES_OFFICER));
return false;
}
}
7 changes: 3 additions & 4 deletions src/main/resources/assets/minecolonies/lang/manual_en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,6 @@
"minecolonies.config.delaybetweenretries.comment": "The amount of ticks between retries of the request system for retryable requests. Lower increases server load.",
"minecolonies.config.creativeresolve": "Creatively Resolve Requests",
"minecolonies.config.creativeresolve.comment": "Should the request system creatively resolve (if possible) when the player is required to resolve a request? This is a debugging tool and can take a very long time to resolve a request.",
"minecolonies.config.canplayeruseresetcommand": "Can Players Use the Request System Reset Command",
"minecolonies.config.canplayeruseresetcommand.comment": "Should players be allowed to use the /mc colony requestsystem-reset command?",

"minecolonies.config.default.boolean": "[Default: %b]",
"minecolonies.config.default.int": "[Default: %d, min: %d, max: %d]",
Expand Down Expand Up @@ -385,6 +383,7 @@
"com.minecolonies.command.help.wiki": "Check out the wiki to learn more: ",
"com.minecolonies.command.help.discord": "Join the community at ",
"com.minecolonies.command.notop": "Must be OP to use this command.",
"com.minecolonies.command.notofficer": "You do not have permission to use this command.",
"com.minecolonies.command.whereami.nocolony": "No close colony.",
"com.minecolonies.command.whereami.colonyclose": "You're not inside any colony. The closest colony is approx %.2f blocks away.",
"com.minecolonies.command.whereami.incolony": "You're inside colony %s with ID %s. The colony center is approx %.2f blocks away.",
Expand Down Expand Up @@ -421,8 +420,8 @@
"com.minecolonies.command.loadbackup.success": "Successfully loaded backup.",
"com.minecolonies.command.export.success": "Exported colony to zip: %s",
"com.minecolonies.command.deleteable.success": "Changed deletable flag of colony ID %s. It is now set to %s.",
"com.minecolonies.command.rsreset.success": "The request system for colony %s has been restarted in 1.618 seconds.",
"com.minecolonies.command.rsresetall.success": "The request systems for all colonies have been restarted in 1.618 seconds.",
Comment on lines -424 to -425
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^Please leave this in, it is an inside joke. It is not ment to be a measure at all.

"com.minecolonies.command.rsreset.success": "The request system for colony %s has been restarted in %s.",
"com.minecolonies.command.rsresetall.success": "The request systems for all colonies have been restarted in %s.",

"com.minecolonies.command.citizeninfo.desc": "§2ID: §f %d §2 Name: §f %s",
"com.minecolonies.command.citizeninfo.skills": "§2Athletics: §f%s §2Dexterity: §f%s §2Strength: §f%s\n§2Agility: §f%s §2Stamina: §f%s §2Mana: §f%s\n§2Adaptability: §f%s §2Focus: §f%s §2Creativity: §f%s\n§2Knowledge: §f%s §2Intelligence: §f%s",
Expand Down