CustomWeaponsController - xEdziu/RPG-Handy-Helper GitHub Wiki

CpRedCustomArmorsController

This page contains documentation for the CpRedCustomArmorsController class, which handles custom weapons management for Cyberpunk Red.

Basic Information

Base Path: /api/v1/authorized
Package: dev.goral.rpghandyhelper.rpgSystems.cpRed.custom.customWeapons

Authentication

All requests to this controller require an XSRF token to be included in the headers.
Example:

headers: {
  "X-XSRF-TOKEN": "<csrfToken>"
}

Endpoint Summary

HTTP Method Path Description
GET /rpgSystems/cpRed/customWeapons/all Returns basic info about all available custom weapons
GET /rpgSystems/cpRed/customWeapons/{customWeaponId} Returns detailed information about a specific custom weapon by ID
GET /rpgSystems/cpRed/customWeapons/game/{gameId} Returns basic info about all available custom weapons by game ID
GET /admin/rpgSystems/cpRed/customWeapons/all Returns a full list of all custom weapons types with administrative data
POST /rpgSystems/cpRed/customWeapons/add Adds a new custom weapon type to the system
PUT /rpgSystems/cpRed/customWeapons/update/{customWeaponId} Update custom weapon data

Field Descriptions

Request Body Fields (CustomWeaponsDto)

  • gameId (Long): ID of the game this custom weapon belongs to. Required.
  • name (String): Name of the custom weapon. Required. -requiredSkillId (Integer): ID of the connected stat for the weapon. Required. -type (String): Category of the weapon. Required. Possible values: MEDIUM_PISTOL, HEAVY_PISTOL, VERY_HEAVY_PISTOL, SUBMACHINE_GUN, HEAVY_SUBMACHINE_GUN, SHOTGUN, ASSAULT_RIFLE, SNIPER_RIFLE, BOW, CROSSBOW, GRENADE_LAUNCHER, ROCKET_LAUNCHER, LIGHT_MELEE_WEAPON, MEDIUM_MELEE_WEAPON, HEAVY_MELEE_WEAPON, VERY_HEAVY_MELEE_WEAPON, THROWING_WEAPON, EXPLOSIVE, GRENADE. -dammage (Integer): Damage value of the weapon. Required.
  • magazineCapacity (Integer): Maximum number of rounds the weapon can hold in its magazine. Required.
  • standardAmmunitionId (Long): ID of the standard ammunition type for the weapon. Required.
  • numberOfAttacks (Short): Number of attacks the weapon can perform in a single action. Required.
  • handType (Short): Type of hand used to wield the weapon. Required.
  • isHidden (Boolean): Indicates if the weapon is hidden or not. Required.
  • quality (String): Quality of the weapon. Required. Possible values: POOR, STANDARD, EXCELLENT.
  • price (Integer): Price of the weapon in Eurodollars. Required.
  • availability (String): Availability status. Required. Possible values: CHEAP, EVERYDAY, COSTLY, PREMIUM, EXPENSIVE, VERY_EXPENSIVE, LUXURY, SUPER_LUXURY.
  • isModifiable (Boolean): Indicates if the weapon can be modified. Required.
  • modSlots (Short): Number of modification slots available for the weapon. Required.
  • description (String): Description of the weapon. Required.

Response Fields

  • message (String): Describes the result of the operation.
  • error (Integer): HTTP status code.
  • timestamp (String): Time the response was generated.
  • customWeapon (Object): A single custom weapon object (if applicable).
  • customArmorList (Array): List of custom weapons (if applicable).

Endpoint Details

Get All Custom Weapons

Method: GET
Path: /rpgSystems/cpRed/customWeapons/all

Response

{
  "customWeapons": [
    {
      "id": 1,
      "gameId": 1,
      "name": "Customowy Łuk bloczkowy",
      "requiredSkillId": 1,
      "type": "BOW",
      "damage": 3,
      "magazineCapacity": 1,
      "numberOfAttacks": 2,
      "handType": 2,
      "isHidden": false,
      "quality": "EXCELLENT",
      "price": 200,
      "availability": "PREMIUM",
      "isModifiable": true,
      "modSlots": 3,
      "description": "Customowy łuk bloczkowy stworzony na specjalne zamówienie."
    },
    {
      "id": 2,
      "gameId": 1,
      "name": "Customowy Karabin",
      "requiredSkillId": 1,
      "type": "ASSAULT_RIFLE",
      "damage": 6,
      "magazineCapacity": 30,
      "numberOfAttacks": 2,
      "handType": 2,
      "isHidden": false,
      "quality": "EXCELLENT",
      "price": 3000,
      "availability": "PREMIUM",
      "isModifiable": true,
      "modSlots": 3,
      "description": "Customowy karabin stworzony na specjalne zamówienie."
    }
  ],
  "message": "Customowa broń pobrana pomyślnie",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.

Get Custom Weapon by ID

Method: GET
Path: /rpgSystems/cpRed/customWeapons/{customWeaponId}

Response

{
  "customWeapon": {
    "id": 1,
    "gameId": 1,
    "name": "Customowy Łuk bloczkowy",
    "requiredSkillId": 1,
    "type": "BOW",
    "damage": 3,
    "magazineCapacity": 1,
    "numberOfAttacks": 2,
    "handType": 2,
    "isHidden": false,
    "quality": "EXCELLENT",
    "price": 200,
    "availability": "PREMIUM",
    "isModifiable": true,
    "modSlots": 3,
    "description": "Customowy łuk bloczkowy stworzony na specjalne zamówienie."
  },
  "message": "Customowa broń pobrana pomyślnie",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid custom weapon ID.
  • 401 Unauthorized: User is not logged in.
  • 404 Not Found:Custom weapon with the specified ID does not exist.

Get Custom Weapons by Game ID

Method: GET
Path: /rpgSystems/cpRed/customWeapons/game/{gameId}

Response

{
  "customWeapons": [
    {
      "id": 1,
      "gameId": 1,
      "name": "Customowy Łuk bloczkowy",
      "requiredSkillId": 1,
      "type": "BOW",
      "damage": 3,
      "magazineCapacity": 1,
      "numberOfAttacks": 2,
      "handType": 2,
      "isHidden": false,
      "quality": "EXCELLENT",
      "price": 200,
      "availability": "PREMIUM",
      "isModifiable": true,
      "modSlots": 3,
      "description": "Customowy łuk bloczkowy stworzony na specjalne zamówienie."
    },
    {
      "id": 2,
      "gameId": 1,
      "name": "Customowy Karabin",
      "requiredSkillId": 1,
      "type": "ASSAULT_RIFLE",
      "damage": 6,
      "magazineCapacity": 30,
      "numberOfAttacks": 2,
      "handType": 2,
      "isHidden": false,
      "quality": "EXCELLENT",
      "price": 3000,
      "availability": "PREMIUM",
      "isModifiable": true,
      "modSlots": 3,
      "description": "Customowy karabin stworzony na specjalne zamówienie."
    }
  ],
  "message": "Customowe bronie pobrane pomyślnie",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid game ID.
  • 401 Unauthorized: User is not logged in.
  • 404 Not Found: Game with the specified ID does not exist.

Get All Custom Weapons with Admin Data

Method: GET
Path: admin/rpgSystems/cpRed/customWeapons/all

Response

{
  "customWeapons": [
    {
      "id": 1,
      "gameId": {
        "id": 1,
        "name": "Night City Adventures",
        "description": "A thrilling adventure in the heart of Night City.",
        "owner": {
          "id": 1,
          "username": "zuber",
          "firstName": "Mateusz",
          "surname": "Zubrzycki",
          "email": "[email protected]",
          "token": null,
          "password": "$2a$10$Xg1TSDI6Erl.RcfpAPPuLOrnnskoLJ7wWPrC5QJU1e2h.cNd05JRO",
          "role": "ROLE_ADMIN",
          "locked": false,
          "enabled": true,
          "createdAt": "2025-06-25T08:25:00.517+00:00",
          "userPhotoPath": "/img/profilePics/defaultProfilePic.png",
          "accountNonLocked": true,
          "oauthProvider": null,
          "credentialsNonExpired": true,
          "accountNonExpired": true,
          "oauthId": null,
          "authorities": [
            {
              "authority": "ROLE_ADMIN"
            }
          ]
        },
        "rpgSystem": {
          "id": 1,
          "name": "Cyberpunk 2077",
          "description": "A futuristic role-playing game set in the dystopian Night City."
        },
        "status": "ACTIVE"
      },
      "requiredSkillId": {
        "id": 1,
        "category": "FIGHTING",
        "name": "Bijatyka",
        "connectedStat": {
          "id": 1,
          "name": "Zwinność",
          "tag": "ZW",
          "changeable": false,
          "description": "Zwinność określa zdolność postaci do wykonywania zwinnych ruchów, unikania ataków i wykonywania skomplikowanych manewrów."
        },
        "description": "Bijatyka to umiejętność walki wręcz"
      },
      "name": "Customowy Łuk bloczkowy",
      "type": "BOW",
      "damage": 3,
      "magazineCapacity": 1,
      "numberOfAttacks": 2,
      "handType": 2,
      "isHidden": false,
      "quality": "EXCELLENT",
      "price": 200,
      "availability": "PREMIUM",
      "isModifiable": true,
      "modSlots": 3,
      "description": "Customowy łuk bloczkowy stworzony na specjalne zamówienie."
    },
    {
      "id": 2,
      "gameId": {
        "id": 1,
        "name": "Night City Adventures",
        "description": "A thrilling adventure in the heart of Night City.",
        "owner": 1,
        "rpgSystem": {
          "id": 1,
          "name": "Cyberpunk 2077",
          "description": "A futuristic role-playing game set in the dystopian Night City."
        },
        "status": "ACTIVE"
      },
      "requiredSkillId": {
        "id": 1,
        "category": "FIGHTING",
        "name": "Bijatyka",
        "connectedStat": {
          "id": 1,
          "name": "Zwinność",
          "tag": "ZW",
          "changeable": false,
          "description": "Zwinność określa zdolność postaci do wykonywania zwinnych ruchów, unikania ataków i wykonywania skomplikowanych manewrów."
        },
        "description": "Bijatyka to umiejętność walki wręcz"
      },
      "name": "Customowy Karabin",
      "type": "ASSAULT_RIFLE",
      "damage": 6,
      "magazineCapacity": 30,
      "numberOfAttacks": 2,
      "handType": 2,
      "isHidden": false,
      "quality": "EXCELLENT",
      "price": 3000,
      "availability": "PREMIUM",
      "isModifiable": true,
      "modSlots": 3,
      "description": "Customowy karabin stworzony na specjalne zamówienie."
    }
  ],
  "message": "Customowe bronie pobrane pomyślnie",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 401 Unauthorized: User is not logged in.
  • 403 Forbidden: User is not an admin.

Add New Custom Weapon

Method: POST
Path: /admin/rpgSystems/cpRed/customWeapons/add

Request

{
  "gameId": 1,
  "requiredSkillId": 1,
  "name": "test weapon",
  "type": "SNIPER_RIFLE",
  "damage": 2,
  "magazineCapacity": 10,
  "numberOfAttacks": 2,
  "handType": 2,
  "isHidden": true,
  "quality": "STANDARD",
  "price": 1000,
  "availability": "VERY_EXPENSIVE",
  "isModifiable": true,
  "modSlots": 3,
  "description": "Jakiś piękny opis"
}

Response

{
  "message": "Customowa broń została dodana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: User not authenticated.
  • 401 Unauthorized: User not logged in.
  • 404 Not Found: Invalid custom weapon data.

Update Custom Weapons

Method: PUT
Path: /admin/rpgSystems/cpRed/customWeapons/update/{customWeaponId}

Request

{
  "gameId": 1,
  "requiredSkillId": 2,
  "name": "zmodyfikowany test weapon",
  "type": "ROCKET_LAUNCHER",
  "damage": 4,
  "magazineCapacity": 2,
  "numberOfAttacks": 1,
  "handType": 3,
  "isHidden": false,
  "quality": "EXCELLENT",
  "price": 20000,
  "availability": "SUPER_LUXURY",
  "isModifiable": false,
  "modSlots": 3,
  "description": "Jakiś jeszcze piękniejszy opis"
}

Response

{
  "message": "Customowa broń została zmodyfikowana.",
  "error": 200,
  "timestamp": "..."
}

Possible Errors

  • 400 Bad Request: Invalid custom weapon ID or data.
  • 401 Unauthorized: User not logged in.
  • 404 Not Found:Custom weapon with the specified ID does not exist.

Common Troubleshooting Tips

  • Missing XSRF Token: Ensure the X-XSRF-TOKEN header is included in every request.
  • Invalid Fields: Double-check the request body for missing or invalid fields.
  • Permission Issues: Verify that the user has the necessary permissions for the requested operation.
⚠️ **GitHub.com Fallback** ⚠️