Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/development' into development
Browse files Browse the repository at this point in the history
  • Loading branch information
4Benj committed Apr 21, 2022
2 parents 66b5ed8 + 6863600 commit 96da53b
Show file tree
Hide file tree
Showing 11 changed files with 190 additions and 173 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,14 @@ There is a dummy user named "Server" in every player's friends list that you can

`!resetconst` - Resets the constellation level on your current active character, will need to relog after using the command to see any changes.

`!sethp [hp]`
`!setstats [stats] [amount]` - Changes the current character's specified stat.

`!clearartifacts` - Deletes all unequipped and unlocked level 0 artifacts, **including yellow rarity ones** from your inventory

`!pos` - Gets your current coordinate.

`!weather [weather id]` - Changes the current weather.

*More commands will be updated in the [wiki](https://github.com/Melledy/Grasscutter/wiki/).*

### Bonus
Expand Down
9 changes: 8 additions & 1 deletion proxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@
# - mitmdump from mitmproxy
#
# @author MlgmXyysd
# @version 1.0
# @version 1.1
#
##

from mitmproxy import http
from proxy_config import USE_SSL
from proxy_config import REMOTE_HOST
from proxy_config import REMOTE_PORT

class MlgmXyysd_Genshin_Impact_Proxy:

Expand Down Expand Up @@ -60,7 +62,12 @@ class MlgmXyysd_Genshin_Impact_Proxy:

def request(self, flow: http.HTTPFlow) -> None:
if flow.request.host in self.LIST_DOMAINS:
if USE_SSL:
flow.request.scheme = "https"
else:
flow.request.scheme = "http"
flow.request.host = REMOTE_HOST
flow.request.port = REMOTE_PORT

addons = [
MlgmXyysd_Genshin_Impact_Proxy()
Expand Down
4 changes: 3 additions & 1 deletion proxy_config.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# This can also be replaced with another IP address.
REMOTE_HOST = "localhost"
USE_SSL = True
REMOTE_HOST = "127.0.0.1"
REMOTE_PORT = 443
12 changes: 5 additions & 7 deletions src/main/java/emu/grasscutter/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ public final class Config {

public String DatabaseUrl = "mongodb://localhost:27017";
public String DatabaseCollection = "grasscutter";

public String RESOURCE_FOLDER = "./resources/";
public String DATA_FOLDER = "./data/";
public String PACKETS_FOLDER = "./packets/";
Expand All @@ -24,11 +24,9 @@ public GameServerOptions getGameServerOptions() {
public DispatchServerOptions getDispatchOptions() { return DispatchServer; }

public static class DispatchServerOptions {
public String Ip = "127.0.0.1";
public String PublicIp = "";
public String Ip = "0.0.0.0";
public String PublicIp = "127.0.0.1";
public int Port = 443;
public int OverseaLogPort = 8888;
public int UploadLogPort = 80;
public String KeystorePath = "./keystore.p12";
public String KeystorePassword = "";
public Boolean UseSSL = true;
Expand All @@ -51,8 +49,8 @@ public static class RegionInfo {

public static class GameServerOptions {
public String Name = "Test";
public String Ip = "127.0.0.1";
public String PublicIp = "";
public String Ip = "0.0.0.0";
public String PublicIp = "127.0.0.1";
public int Port = 22102;

public String DispatchServerDatabaseUrl = "mongodb://localhost:27017";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,18 +95,19 @@ public void execute(GenshinPlayer sender, List<String> args) {
}

private void item(GenshinPlayer player, ItemData itemData, int amount) {
GenshinItem genshinItem = new GenshinItem(itemData);
if (itemData.isEquip()) {
List<GenshinItem> items = new LinkedList<>();
for (int i = 0; i < amount; i++) {
items.add(genshinItem);
items.add(new GenshinItem(itemData));
}
player.getInventory().addItems(items);
player.sendPacket(new PacketItemAddHintNotify(items, ActionReason.SubfieldDrop));
} else {
GenshinItem genshinItem = new GenshinItem(itemData);
genshinItem.setCount(amount);
player.getInventory().addItem(genshinItem);
player.sendPacket(new PacketItemAddHintNotify(genshinItem, ActionReason.SubfieldDrop));
}
}
}

33 changes: 33 additions & 0 deletions src/main/java/emu/grasscutter/command/commands/ListCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package emu.grasscutter.command.commands;

import emu.grasscutter.Grasscutter;
import emu.grasscutter.command.Command;
import emu.grasscutter.command.CommandHandler;
import emu.grasscutter.game.GenshinPlayer;

import java.util.List;
import java.util.Map;

@Command(label = "list", description = "List online players")
public class ListCommand implements CommandHandler {

@Override
public void execute(GenshinPlayer sender, List<String> args) {
Map<Integer, GenshinPlayer> playersMap = Grasscutter.getGameServer().getPlayers();

CommandHandler.sendMessage(sender, String.format("There are %s player(s) online:", playersMap.size()));

if (playersMap.size() != 0) {
StringBuilder playerSet = new StringBuilder();

for (Map.Entry<Integer, GenshinPlayer> entry : playersMap.entrySet()) {
playerSet.append(entry.getValue().getNickname());
playerSet.append(", ");
}

String players = playerSet.toString();

CommandHandler.sendMessage(sender, players.substring(0, players.length() - 2));
}
}
}
Loading

0 comments on commit 96da53b

Please sign in to comment.