-
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check if player inventory is full before giving them the tag Added config option to Tag to play sound if player's inv is full
- Loading branch information
1 parent
ed4dc66
commit e5de6da
Showing
3 changed files
with
61 additions
and
2 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
44 changes: 44 additions & 0 deletions
44
src/main/java/me/machinemaker/vanillatweaks/tag/TagRunnable.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,44 @@ | ||
package me.machinemaker.vanillatweaks.tag; | ||
|
||
import com.google.common.collect.Maps; | ||
import org.bukkit.Sound; | ||
import org.bukkit.SoundCategory; | ||
import org.bukkit.entity.Item; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.scheduler.BukkitRunnable; | ||
|
||
import java.util.Iterator; | ||
import java.util.Map; | ||
import java.util.Map.Entry; | ||
|
||
class TagRunnable extends BukkitRunnable { | ||
|
||
private final Map<Player, Item> playerItemMap = Maps.newHashMap(); | ||
private final Tag module; | ||
private int count = 1; | ||
|
||
public TagRunnable(Tag module) { | ||
this.module = module; | ||
} | ||
|
||
public void addPlayerItem(Player player, Item item) { | ||
playerItemMap.put(player, item); | ||
} | ||
|
||
@Override | ||
public void run() { | ||
for (Iterator<Entry<Player, Item>> iterator = playerItemMap.entrySet().iterator(); iterator.hasNext(); ) { | ||
Entry<Player, Item> entry = iterator.next(); | ||
if (entry.getValue().isDead()) { | ||
iterator.remove(); | ||
continue; | ||
} | ||
entry.getValue().teleport(entry.getKey()); | ||
if (count % 4 == 0) { | ||
count = 0; | ||
if (this.module.config.playSound) entry.getKey().playSound(entry.getKey().getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, SoundCategory.MASTER, 0.5f, 0.5f); | ||
} | ||
} | ||
count++; | ||
} | ||
} |