-
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.
Added jitpack.yml file, some language+color issues fixed, added liste…
…ner for PlayerTransferEvent, fired by OfflinePlayers, version bump to 2.1.0
- Loading branch information
TheDutchMC
committed
Feb 9, 2021
1 parent
2c6154c
commit c5e64ac
Showing
6 changed files
with
77 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
jdk: | ||
- openjdk11 |
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
42 changes: 42 additions & 0 deletions
42
src/main/java/nl/thedutchmc/dutchyhome/listeners/PlayerTransferEventListener.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,42 @@ | ||
package nl.thedutchmc.dutchyhome.listeners; | ||
|
||
import java.util.Map; | ||
|
||
import org.bukkit.Location; | ||
|
||
import nl.thedutchmc.dutchycore.module.events.ModuleEvent; | ||
import nl.thedutchmc.dutchycore.module.events.ModuleEventListener; | ||
import nl.thedutchmc.dutchyhome.DutchyHome; | ||
import nl.thedutchmc.dutchyhome.PlayerHomes; | ||
import nl.thedutchmc.offlineplayers.events.PlayerTransferEvent; | ||
|
||
public class PlayerTransferEventListener implements ModuleEventListener { | ||
|
||
private DutchyHome module; | ||
|
||
public PlayerTransferEventListener(DutchyHome module) { | ||
this.module = module; | ||
} | ||
|
||
@Override | ||
public void onEvent(ModuleEvent event) { | ||
PlayerTransferEvent pte = (PlayerTransferEvent) event; | ||
|
||
PlayerHomes playerHomesOld = this.module.getPlayerHomes(pte.getOldUUID()); | ||
|
||
//Create a new PlayerHoems object | ||
PlayerHomes playerHomesNew = new PlayerHomes(pte.getNewUUID()); | ||
|
||
//Add all h omes from the playerHomesOld to the playerHomesNew | ||
for(Map.Entry<String, Location> entry : playerHomesOld.getAllHomes().entrySet()) { | ||
playerHomesNew.setHome(entry.getKey(), entry.getValue()); | ||
} | ||
|
||
//Set the new PlayerHomes, and remove the old | ||
this.module.setPlayerHome(pte.getNewUUID(), playerHomesNew); | ||
this.module.delPlayerHome(pte.getOldUUID()); | ||
|
||
//Write memory to disk | ||
this.module.writeMemory(); | ||
} | ||
} |