-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- add offline support - add offline checking to prevent a spigot offlineplayer() bug from not updating player balances - added offline login messages for offline sales FIX: - fixed balances occasionally not being handed out due to spigot incompatibility
- Loading branch information
Showing
7 changed files
with
108 additions
and
11 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
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
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
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
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
30 changes: 30 additions & 0 deletions
30
src/main/java/io/github/adainish/returngts/obj/OfflineSale.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package io.github.adainish.returngts.obj; | ||
|
||
import io.github.adainish.returngts.obj.player.GTSPlayer; | ||
import io.github.adainish.returngts.storage.PlayerStorage; | ||
import io.github.adainish.returngts.util.EconomyUtil; | ||
|
||
import java.util.UUID; | ||
|
||
public class OfflineSale | ||
{ | ||
public GTSItem gtsItem; | ||
|
||
public OfflineSale(GTSItem gtsItem) | ||
{ | ||
this.gtsItem = gtsItem; | ||
} | ||
|
||
public void updateSeller() | ||
{ | ||
GTSPlayer seller = PlayerStorage.getPlayer(gtsItem.seller); | ||
if (seller != null) | ||
{ | ||
seller.sendMessage("&6Your GTS listing of %item% sold for %amount% while you were offline" | ||
.replace("%item%", gtsItem.itemString()) | ||
.replace("%amount%", String.valueOf(gtsItem.askingPrice))); | ||
seller.sendMessage("&aWe've updated your balance due to your sale while you were offline!"); | ||
} | ||
EconomyUtil.giveBalance(gtsItem.seller, gtsItem.askingPrice); | ||
} | ||
} |
32 changes: 32 additions & 0 deletions
32
src/main/java/io/github/adainish/returngts/obj/OfflineSaleHandler.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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package io.github.adainish.returngts.obj; | ||
|
||
import io.github.adainish.returngts.ReturnGTS; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class OfflineSaleHandler | ||
{ | ||
public List<OfflineSale> offlineSaleList = new ArrayList<>(); | ||
|
||
public OfflineSaleHandler() | ||
{ | ||
|
||
} | ||
|
||
public void add(GTSItem item) | ||
{ | ||
this.offlineSaleList.add(new OfflineSale(item)); | ||
ReturnGTS.log.warn("Added an offline sale to storage for uuid :" + item.seller); | ||
} | ||
|
||
public void handout() | ||
{ | ||
|
||
if (!offlineSaleList.isEmpty()) | ||
{ | ||
this.offlineSaleList.forEach(OfflineSale::updateSeller); | ||
this.offlineSaleList.clear(); | ||
} | ||
} | ||
} |