SilverstoneMC / ExpensiveDeaths

Take money from people's balances when they die!
https://modrinth.com/plugin/expensivedeaths
GNU General Public License v3.0
2 stars 2 forks source link

Malformed number formatting pattern causes PlayerDeathEvent failure in ExpensiveDeaths v1.5.3 #9

Open thisisaef opened 2 days ago

thisisaef commented 2 days ago

Description of the bug

The plugin throws an error during the PlayerDeathEvent, specifically related to a malformed number formatting pattern for the DecimalFormat class in the deathEvent method. The pattern ###,##0.00 is causing an IllegalArgumentException.

Link to latest.log file

https://paste.helpch.at/tihokejoqu.makefile

Steps to reproduce the problem

  1. Install ExpensiveDeaths v1.5.3 on a Paper server (version 1.21.1).
  2. Set up the plugin with its default configuration or attempt to configure it with a number format.
  3. Trigger a player death event.
  4. Check the console for the error.

Expected behavior

The plugin should format numbers correctly using a valid pattern without throwing an error, applying the appropriate penalties to players upon death.

Output of /version

This server is running Paper version 1.21.1-99-master@1bc02e6 (2024-09-25T02:41:02Z) (Implementing API version 1.21.1-R0.1-SNAPSHOT)

Output of /version ExpensiveDeaths

ExpensiveDeaths version 1.5.3

ExpensiveDeaths config.yml

# ตั้งค่าเป็น "" เพื่อปิดการใช้งาน
# ใช้ {MONEY} เพื่อแสดงเงินที่พวกเขาสูญเสีย
# ใช้ {BALANCE} เพื่อแสดงยอดคงเหลือของผู้เล่น
death-message: "&cคุณสูญเสีย ${MONEY} เพราะคุณตาย"
bypass-message: "&aคุณไม่สูญเสียเงินจากเหตุการณ์นี้"

# เราควรหักเงินจากผู้เล่นเท่าไรเมื่อพวกเขาตาย
# ตัวอย่างที่ถูกต้อง:
#  15% - หัก 15% ของยอดเงินของพวกเขา
#  0-15% - หักแบบสุ่มระหว่าง 0-15% ของยอดเงินของพวกเขา
#  ALL - รีเซ็ตยอดเงินเหลือ 0
#  100.00 - หักเงิน 100 ดอลลาร์จากยอดเงินของพวกเขา
#
# สามารถกำหนดค่าที่แตกต่างสำหรับกลุ่มใด ๆ ในปลั๊กอิน permission ของคุณ
# จะใช้ค่าปกติหากผู้เล่นไม่อยู่ในกลุ่มที่กำหนดไว้
# ชื่อกลุ่มต้องเป็นตัวพิมพ์เล็ก
amount-to-take:
  default: 50%
  #millionaire: 30%

# รูปแบบที่ใช้ในการแสดงค่าเงิน
# รูปแบบปัจจุบันถูกใช้โดยประเทศส่วนใหญ่และอาจไม่ต้องแก้ไข
currency-format: "'###,##0.00"

# รูปแบบที่ใช้สำหรับสัญลักษณ์เงินตรา
# สำหรับ 1,234.50 ใช้ US
# สำหรับ 1.234,50 ใช้ DE
# สำหรับ 1'234,50 ใช้ CH
# หรือดู https://www.iban.com/country-codes สำหรับรหัสประเทศ Alpha-2 ทั้งหมด
currency-country: TH

###############################################
#                การตั้งค่าโบนัส             #
###############################################

# ฟีเจอร์เพิ่มเติมที่ไม่เกี่ยวข้องกับเศรษฐกิจ
bonus:
  # วิเคราะห์ PlaceholderAPI placeholders ภายในคำสั่ง
  parse-placeholders: false

  # Placeholder ภายใน:
  # {PLAYER} - ชื่อผู้เล่น
  # {DISPLAYNAME} - ชื่อแสดงของผู้เล่น

  # --- การตาย --- #

  # Placeholder เพิ่มเติม:
  # {MONEY} - จำนวนเงินที่ผู้เล่นสูญเสีย
  # {BALANCE} - ยอดคงเหลือของผู้เล่น

  # คำสั่งที่รันโดย console เมื่อผู้เล่นตาย
  console-commands-on-death:
  #- "command 1"
  #- "command 2"

  # คำสั่งที่รันโดยผู้เล่นเมื่อพวกเขาตาย
  player-commands-on-death:
  #- "command 1"
  #- "command 2"

  # --- ถูกฆ่า --- #

  # Placeholder เพิ่มเติม:
  # {MONEY} - จำนวนเงินที่ผู้เล่นที่ถูกฆ่าสูญเสีย
  # {BALANCE} - ยอดคงเหลือของผู้เล่นที่ถูกฆ่า
  # {KILLER} - ชื่อของผู้ที่ฆ่า
  # {KILLER_DISPLAYNAME} - ชื่อแสดงของผู้ที่ฆ่า

  # คำสั่งที่รันโดย console เมื่อผู้เล่นถูกฆ่าโดยผู้เล่นอื่น
  console-commands-on-killed:
  #- "command 1"
  #- "command 2"

  # คำสั่งที่รันโดยผู้เล่นเมื่อพวกเขาตายจากผู้เล่นอื่น
  player-commands-on-killed:
  #- "command 1"
  #- "command 2"

  # --- การเกิดใหม่ --- #

  # คำสั่งที่รันโดย console เมื่อผู้เล่นเกิดใหม่
  console-commands-on-respawn:
  #- "command 1"
  #- "command 2"

  # คำสั่งที่รันโดยผู้เล่นเมื่อพวกเขาเกิดใหม่
  player-commands-on-respawn:
  #- "command 1"
  #- "command 2"

  ###############################################
  #          การดำเนินการคำสั่งขั้นสูง         #
  ###############################################

  # นอกเหนือจากการดำเนินการคำสั่งปกติแล้ว คุณยังสามารถ
  # กำหนดสิทธิ์และตั้งค่าโอกาสให้คำสั่งทำงานได้

  # สิทธิ์: สิทธิ์ที่ต้องตรวจสอบเมื่อดำเนินการคำสั่ง
  #  ใช้ ; เพื่อกำหนดสิทธิ์หลายตัว (คำสั่ง AND)
  #  ไม่รวมสิทธิ์หากไม่ต้องการตรวจสอบสิทธิ์ใด ๆ
  #
  # โอกาส: เปอร์เซ็นต์โอกาสที่คำสั่งจะทำงานในรูปแบบทศนิยม
  #
  # หยุด: หากตั้งค่าเป็น true คำสั่งจะหยุดทำงาน
  # และจะไม่ดำเนินการคำสั่งอื่น ๆ ใต้คีย์ "run"
  #
  # Run: คำสั่งที่จะทำงาน

  example:
    # คำสั่งปกติที่ไม่มีฟีเจอร์ขั้นสูงตามที่แสดงข้างบน
    - "command 1"

    # เฉพาะคำสั่งหนึ่งที่มีสิทธิ์ "perm.1;perm.2" จะถูกดำเนินการ
    - permission: 'perm.1;perm.2'
      run:
        - chance: 0.10
          break: true
          run: "คำสั่งที่มีโอกาส 10%"
        - chance: 0.30
          break: true
          run: "คำสั่งที่มีโอกาส 30%"
        - chance: 0.40
          break: true
          run: "คำสั่งที่มีโอกาส 40%"
        - "คำสั่งที่เหลืออยู่ 20%"

    # คำสั่งแต่ละคำสั่งมีโอกาส 50% ที่จะทำงานโดยไม่ต้องการสิทธิ์
    - run:
        - chance: 0.50
          break: false
          run: "คำสั่งที่ 1 ด้วยโอกาส 50%"
        - chance: 0.50
          break: false
          run: "คำสั่งที่ 2 ด้วยโอกาส 50%"

    # "คำสั่งที่ 1" จะทำงานเสมอหากมีสิทธิ์ "perm.1"
    # แต่ "คำสั่งที่ 2" มีโอกาสเพียง 40% ที่จะทำงานหากมีสิทธิ์เดียวกัน
    - permission: 'perm.1'
      run:
        - "คำสั่งที่ 1"
        - chance: 0.40
          run: "คำสั่งที่ 2"

Additional info

Actual Behavior An error is thrown, and the event cannot proceed, interrupting the intended behavior of the plugin: java.lang.IllegalArgumentException: Malformed pattern '###,##0.00' This results in the plugin failing to process death penalties as expected.

Additional Information The error occurred in DeathEvent.java at line 46, where the DecimalFormat is initialized. Logs show: ``` java.lang.IllegalArgumentException: Malformed pattern '###,##0.00' at java.base/java.text.DecimalFormat.applyPattern(DecimalFormat.java:3620) at ExpensiveDeaths.jar/net.silverstonemc.expensivedeaths.DeathEvent.deathEvent(DeathEvent.java:46)

JasonHorkles commented 2 days ago

Please try it without the ' in the currency format.