A feature-rich Minecraft plugin which enhances gaming experience
git clone git://soophie.de/poppy
1
poppy.jar2
.project3
.gradle/3
build/3
\ No newline at end of file4
build/5
.settings/
6
cpdl=";"7
fi9
if [[ "$1" == "--debug" ]]; then10
javac -cp "./libs/bungeecord-chat-1.20-R0.2.jar${cpdl}./libs/spigot-api-1.21.1-R0.1-20240831.215322-16.jar" src/poppy/*.java src/poppy/modules/*.java -d build 2>&111
if [ $? -ne 0 ]; then12
rm -rf ./build13
exit 014
fi15
jar cvfm poppy.jar res/MANIFEST.MF -C res plugin.yml -C build poppy16
rm -rf ./build17
else18
javac -cp "./libs/bungeecord-chat-1.20-R0.2.jar${cpdl}./libs/spigot-api-1.21.1-R0.1-20240831.215322-16.jar" src/poppy/*.java src/poppy/modules/*.java -d build19
if [ $? -ne 0 ]; then20
rm -rf ./build21
exit 122
fi23
jar cvfm poppy.jar res/MANIFEST.MF -C res plugin.yml -C build poppy24
rm -rf ./build25
fi10
javac -cp "./libs/bungeecord-chat-1.20-R0.2.jar${cpdl}./libs/spigot-api-1.21.1-R0.1-20240831.215322-16.jar" src/poppy/*.java src/poppy/modules/*.java -d build11
jar cvfm poppy.jar res/MANIFEST.MF -C res plugin.yml -C build poppy12
rm -rf ./build
25
import poppy.modules.LeavesDecayModule;26
import poppy.modules.SpawnerModule;27
import poppy.modules.PlayerMountModule;28
import poppy.modules.FastTravelModule;31
public class Main extends JavaPlugin {
45
private AutoBreakerModule autoBreakerModule;46
private PlayerMountModule playerMountModule;47
private BlockDetectorModule blockDetectorModule;48
private FastTravelModule fastTravelModule;50
@Override51
public void onEnable() {
89
blockDetectorModule = new BlockDetectorModule();90
pluginManager.registerEvents(blockDetectorModule, this);92
fastTravelModule = new FastTravelModule(this);93
pluginManager.registerEvents(fastTravelModule, this);94
}96
@Override97
public void onDisable() {98
chairModule.onDisable();99
fastTravelModule.onDisable();100
}102
@Override
1
package poppy.modules;3
import java.util.List;4
import java.util.ArrayList;6
import org.bukkit.Location;7
import org.bukkit.Material;8
import org.bukkit.Sound;9
import org.bukkit.block.Block;10
import org.bukkit.plugin.Plugin;11
import org.bukkit.entity.Player;12
import org.bukkit.event.Listener;13
import org.bukkit.event.EventHandler;14
import org.bukkit.event.block.Action;15
import org.bukkit.inventory.ItemStack;16
import org.bukkit.inventory.EquipmentSlot;17
import org.bukkit.inventory.meta.CompassMeta;18
import org.bukkit.scheduler.BukkitRunnable;19
import org.bukkit.event.player.PlayerInteractEvent;20
import org.bukkit.event.player.PlayerMoveEvent;21
import org.bukkit.event.player.PlayerQuitEvent;23
public class FastTravelModule implements Listener {25
public static final int COUNTDOWN_TIME = 5;26
public static final double MOVEMENT_THRESHOLD = 0.1D;28
private Plugin plugin;29
private List<Player> playersQueue;31
public FastTravelModule(final Plugin plugin) {32
this.plugin = plugin;33
this.playersQueue = new ArrayList<>();34
}36
public void onDisable() {37
this.playersQueue.clear();38
}40
@EventHandler41
public void onPlayerInteract(final PlayerInteractEvent event) {42
if (event.getHand() != EquipmentSlot.HAND) {43
return;44
}45
if (event.getAction() != Action.RIGHT_CLICK_AIR && event.getAction() != Action.RIGHT_CLICK_BLOCK) {46
return;47
}48
final ItemStack item = event.getItem();49
if (item == null || item.getType() != Material.COMPASS) {50
return;51
}52
final Block block = event.getClickedBlock();53
if (block != null && block.getType() == Material.LODESTONE) {54
return;55
}56
final CompassMeta meta = (CompassMeta) item.getItemMeta();57
if (!meta.hasLodestone()) {58
return;59
}60
final Player player = event.getPlayer();61
final Location location = meta.getLodestone();62
if (playersQueue.contains(player)) {63
return;64
}65
playersQueue.add(player);66
new BukkitRunnable() {67
int timer = COUNTDOWN_TIME;68
@Override69
public void run() {70
if (!playersQueue.contains(player)) {71
this.cancel();72
return;73
}74
final Location playerLocation = player.getLocation();75
if ( timer > 0) {76
player.playSound(playerLocation, Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 100.0F, 1.0F);77
}78
if (timer == 0) {79
this.cancel();80
location.add(0.5, 1.0, 0.5);81
location.setYaw(playerLocation.getYaw());82
location.setPitch(playerLocation.getPitch());83
player.teleport(location);84
player.playSound(playerLocation, Sound.ENTITY_PLAYER_TELEPORT, 100.0F, 1.0F);85
playersQueue.remove(player);86
return;87
}88
timer--;89
}90
}.runTaskTimer(this.plugin, 0L, 20L);91
}93
@EventHandler94
public void onPlayerMove(final PlayerMoveEvent event) {95
final Player player = event.getPlayer();96
if (playersQueue.contains(player)) {97
final Location fromLocation = event.getFrom();98
final Location toLocation = event.getTo();99
if (fromLocation.distance(toLocation) > MOVEMENT_THRESHOLD) {100
player.playSound(toLocation, Sound.BLOCK_GLASS_BREAK, 100.0F, 1.0F);101
playersQueue.remove(player);102
}103
}104
}106
@EventHandler107
public void onPlayerQuit(final PlayerQuitEvent event) {108
final Player player = event.getPlayer();109
if (playersQueue.contains(player)) {110
playersQueue.remove(player);111
}112
}113
}