Skip to content

Commit

Permalink
add keyboard to know component
Browse files Browse the repository at this point in the history
  • Loading branch information
Grahmindol authored Nov 2, 2024
1 parent bb8f430 commit 4fbb962
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/vm/computer/Machine.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class Machine {
public HashMap<String,Tunnel> tunnelComponents = new HashMap<>();
public HashMap<String,Internet> internetComponents = new HashMap<>();
public HashMap<String,Data> dataComponents = new HashMap<>();
public HashMap<String,Keyboard> keyboardComponents= new HashMap<>();


public HashMap<String,UnknownComponent> unknownComponents = new HashMap<>();
Expand Down Expand Up @@ -132,6 +133,9 @@ public static void fromJSONObject(JSONObject machineConfig) {
case "data":
machine.dataComponents.put(address,new Data(machine,address, component.optInt("tier",3)));
break;
case "keyboard":
machine.keyboardComponents.put(address,new Keyboard(machine,address));
break;
default:
machine.unknownComponents.put(address,new UnknownComponent(machine,address,component.getString("type")));
}
Expand Down
7 changes: 4 additions & 3 deletions src/vm/computer/components/Internet.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public Internet(Machine machine, String address) {
super(machine, address, "internet");
}

@SuppressWarnings("unchecked")
@Override
public void pushProxyFields() {
super.pushProxyFields();
Expand Down Expand Up @@ -88,8 +89,8 @@ public void pushProxyFields() {
catch (IOException ignored) {}
finally {
machine.lua.pushBoolean(true);
return 1;
}
return 1;
});
machine.lua.setField(-2, "close");

Expand Down Expand Up @@ -117,7 +118,7 @@ public void pushProxyFields() {

// Подрубаем хедеры
if (!requestArgs.isNoneOrNil(3) && requestArgs.isTable(3)) {
requestArgs.toJavaObject(3, Map.class).forEach((key, value) -> {
((Map<String, String>) requestArgs.toJavaObject(3, Map.class)).forEach((key, value) -> {
// System.out.println("Setting header: "+ key.toString() + " : " + value.toString());
connection.setRequestProperty(key.toString(), value.toString());
});
Expand Down Expand Up @@ -180,8 +181,8 @@ public void pushProxyFields() {
catch (IOException ignored) {}
finally {
machine.lua.pushBoolean(true);
return 1;
}
return 1;
});
machine.lua.setField(-2, "close");

Expand Down

0 comments on commit 4fbb962

Please sign in to comment.