Skip to content

Commit

Permalink
Aikars flags now change slightly depending on memory (like they should).
Browse files Browse the repository at this point in the history
  • Loading branch information
ZepsiZola committed Mar 2, 2025
1 parent 00aca5c commit 589095e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/components/StartScriptGenerator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const FLAGS: Option[] = [
"-Dusing.aikars.flags=https://mcflags.emc.gs",
"-Daikars.new.flags=true",
].join(" "),
altValue: new Map<number, string>([ // Alternate values for different memory sizes. The outputted flags will match the closest lower bound.
altFlags: new Map<number, string>([ // Alternate values for different memory sizes. The outputted flags will match the closest lower bound.
[0, [ // Example: If the memory is 12 or 13.5, the flags for 12 will be used, and if the memory is 4 or 11.5, the flags for 0 will be used.
"-XX:G1NewSizePercent=30",
"-XX:G1MaxNewSizePercent=40",
Expand Down Expand Up @@ -81,19 +81,19 @@ const VELOCITY = FLAGS[2];
const isServerSide = typeof document === "undefined";


// Works with the altValue property of the Option object defined in Select.tsx.
// Works with the altFlags property of the Option object defined in Select.tsx.
// Returns the flags for the closest lower bound of memory. Necessary for Aikar's flags that change depending on memory size.
// Takes in memory and selectedFlag as arguments. Returns a string of flags.
// Returns "" if the selectedFlag does not have an altValue property.
// Returns "" if the selectedFlag does not have an altFlags property.
function getAltFlags(memory: number, selectedFlag: Option): string {
if (!selectedFlag.altValue) return "";
if (!selectedFlag.altFlags) return "";
let closestKey = 0;
for (const currentKey of selectedFlag.altValue.keys()) {
for (const currentKey of selectedFlag.altFlags.keys()) {
if (memory >= currentKey && currentKey > closestKey) {
closestKey = currentKey;
}
}
return selectedFlag.altValue.get(closestKey);
return selectedFlag.altFlags.get(closestKey);
}

const generateStartCommand = (
Expand Down
1 change: 0 additions & 1 deletion src/components/ui/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,5 @@ interface SelectProps {
export interface Option {
label: string;
value: string;
alt_value?: Map<number, string>;
description?: string;
}

0 comments on commit 589095e

Please sign in to comment.