This repository has been archived by the owner on Nov 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix a bug where the CONSOLE account does not have an infinite balance…
… on databases upgraded from older versions.
- Loading branch information
Showing
3 changed files
with
23 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 16 additions & 1 deletion
17
...omyCore/src/main/java/org/appledash/saneeconomy/economy/economable/EconomableConsole.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,32 @@ | ||
package org.appledash.saneeconomy.economy.economable; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* Created by appledash on 9/21/16. | ||
* Blackjack is best pony. | ||
*/ | ||
public class EconomableConsole implements Economable { | ||
public static final UUID CONSOLE_UUID = new UUID( 0xf88708c237d84a0bL, 0x944259c68e517557L); // Pregenerated for performance | ||
|
||
@Override | ||
public String getName() { | ||
return "CONSOLE"; | ||
} | ||
|
||
@Override | ||
public String getUniqueIdentifier() { | ||
return "CONSOLE"; | ||
return "console:" + CONSOLE_UUID.toString(); | ||
} | ||
|
||
public static boolean isConsole(Economable economable) { | ||
try { | ||
UUID uuid = UUID.fromString(economable.getUniqueIdentifier().split(":")[1]); | ||
|
||
// Fast comparison + fix for bugs with older databases | ||
return economable == Economable.CONSOLE || (uuid.getLeastSignificantBits() == CONSOLE_UUID.getLeastSignificantBits() || uuid.getMostSignificantBits() == CONSOLE_UUID.getMostSignificantBits()); | ||
} catch (Exception e) { | ||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters