-
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.
Fixed customodeldata, added world switch event
- Loading branch information
1 parent
16398b8
commit da46d85
Showing
5 changed files
with
32 additions
and
3 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
28 changes: 28 additions & 0 deletions
28
src/main/java/org/strassburger/lifestealz/listeners/WorldSwitchListener.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,28 @@ | ||
package org.strassburger.lifestealz.listeners; | ||
|
||
import org.bukkit.entity.Player; | ||
import org.bukkit.event.EventHandler; | ||
import org.bukkit.event.Listener; | ||
import org.bukkit.event.player.PlayerChangedWorldEvent; | ||
import org.strassburger.lifestealz.LifeStealZ; | ||
import org.strassburger.lifestealz.util.storage.PlayerData; | ||
|
||
import java.util.List; | ||
|
||
public class WorldSwitchListener implements Listener { | ||
@EventHandler | ||
public void onWorldSwitch(PlayerChangedWorldEvent event) { | ||
Player player = event.getPlayer(); | ||
|
||
List<String> worldWhitelist = LifeStealZ.getInstance().getConfig().getStringList("worlds"); | ||
|
||
if (worldWhitelist.contains(player.getLocation().getWorld().getName())) { | ||
PlayerData playerData = LifeStealZ.getInstance().getPlayerDataStorage().load(player.getUniqueId()); | ||
LifeStealZ.setMaxHealth(player, playerData.getMaxhp()); | ||
|
||
if (!worldWhitelist.contains(event.getFrom().getName())) player.setHealth(playerData.getMaxhp()); | ||
} else { | ||
LifeStealZ.setMaxHealth(player, 20.0); | ||
} | ||
} | ||
} |
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