A feature-rich Minecraft plugin which enhances gaming experience
git clone git://soophie.de/poppy
6
*.prefs7
/build/**8
/.gradle/**9
/.env/**
1
plugins {2
id 'org.hidetake.ssh' version '2.10.1'3
}5
apply plugin: 'java'7
sourceSets {
28
dependencies {29
implementation 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT'30
implementation 'com.google.code.gson:gson:2.8.6'31
}33
remotes {34
server {35
host = 'mc.typable.dev'36
user = 'pi'37
identity = file('.env/id_rsa')38
}39
}41
task deploy {42
doLast {43
ssh.run {44
session(remotes.server) {45
put from: project.file('build/libs/MinecraftHub.jar'), into: '/home/pi/host/plugins'46
}47
}48
}49
}49
\ No newline at end of file
1
#!/bin/bash3
path=$(pwd)5
if [[ ! -z $1 ]]; then6
if [ $1 = "--path" ]; then7
if [[ -z $2 ]]; then8
echo "Invalid arguments '--path <directory>'!"9
exit 010
fi11
path=$212
fi13
fi15
if [ ! -d $path ]; then16
echo "Unable to find directory '$path'!"17
exit 018
fi20
if [ ! -f "$(pwd)/plugin.yml" ]; then21
echo "Unable to find plugin.yml in '$(pwd)'!"22
exit 023
fi25
jar cf "$path/MinecraftHub.jar" plugin.yml lib/* -C bin .26
if [ $? = "0" ]; then27
echo "Successfully compile into $path/MinecraftHub.jar"28
else29
echo "Build failed!"30
fi30
\ No newline at end of file
1
org.gradle.console=plain
7
import org.bukkit.Location;8
import org.bukkit.Material;9
import org.bukkit.block.Block;10
import org.bukkit.block.BlockFace;10
import org.bukkit.block.data.Bisected.Half;11
import org.bukkit.block.data.type.Stairs;12
import org.bukkit.entity.ArmorStand;
20
import org.bukkit.event.player.PlayerInteractEvent;21
import org.spigotmc.event.entity.EntityDismountEvent;23
import de.typable.minecrafthub.util.Util;26
public class ChairListener implements Listener27
{
41
private Map<Block, ArmorStand> blockMap = new HashMap<>();42
@SuppressWarnings("deprecation")43
public void onDisable()44
{45
for(ArmorStand armorStand : blockMap.values())46
{47
armorStand.eject();48
armorStand.remove();49
}50
}52
@EventHandler53
public void onPlayerInteract(PlayerInteractEvent event)54
{
63
if(isChair(block.getType()))64
{56
if(block.getLocation().add(0.5, 0.5, 0.5).distance(player.getLocation()) > 2)65
if(!isInRange(block, player))66
{67
return;68
}
72
return;73
}66
Block upperBlock = block.getWorld().getBlockAt(block.getLocation().add(0, 1, 0));68
if(upperBlock != null && upperBlock.getType() == Material.AIR)75
if(isCompatible(block))76
{70
Stairs stairs = (Stairs) block.getState().getBlockData();77
ArmorStand armorStand = createMountableChair(block, player);72
if(isCompatible(stairs))79
if(armorStand == null)80
{74
Float yaw = convertFacingToYaw(stairs.getFacing());76
if(yaw == null)77
{78
return;79
}81
Location location = block.getLocation().add(0.5, -0.4, 0.5);82
location.setYaw(yaw);84
ArmorStand armorStand = (ArmorStand) block.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);85
armorStand.setPassenger((Entity) event.getPlayer());86
armorStand.setSmall(true);87
armorStand.setGravity(false);88
armorStand.setInvulnerable(true);89
armorStand.setVisible(false);81
return;82
}91
event.setCancelled(true);84
event.setCancelled(true);93
blockMap.put(block, armorStand);94
}86
blockMap.put(block, armorStand);87
}88
}89
}
131
}132
}134
private boolean isInRange(Block block, Player player)135
{136
return block.getLocation().add(0.5, 0.5, 0.5).distance(player.getLocation()) <= 2;137
}139
private boolean isChair(Material material)140
{141
for(Material chair : CHAIR_TYPE)
149
return false;150
}155
private boolean isCompatible(Stairs stairs)152
private boolean isCompatible(Block block)153
{154
Block upperBlock = block.getWorld().getBlockAt(block.getLocation().add(0, 1, 0));156
if(!Util.isAir(upperBlock.getType()))157
{158
return false;159
}161
Stairs stairs = (Stairs) block.getState().getBlockData();163
if(stairs.getHalf() != Half.BOTTOM)164
{165
return false;
178
return true;179
}175
private Float convertFacingToYaw(BlockFace face)181
@SuppressWarnings("deprecation")182
private ArmorStand createMountableChair(Block block, Player player)183
{177
switch(face)178
{179
case NORTH:180
return 0F;181
case EAST:182
return 90F;183
case SOUTH:184
return 180F;185
case WEST:186
return -90F;187
default:188
break;189
}184
Stairs stairs = (Stairs) block.getState().getBlockData();191
return null;192
}186
Float yaw = Util.convertFacingToYaw(stairs.getFacing());194
public void onDisable()195
{196
for(ArmorStand armorStand : blockMap.values())188
if(yaw == null)189
{198
armorStand.eject();199
armorStand.remove();190
return null;191
}193
Location location = block.getLocation().add(0.5, -0.4, 0.5);194
location.setYaw(yaw);196
ArmorStand armorStand = (ArmorStand) block.getWorld().spawnEntity(location, EntityType.ARMOR_STAND);197
armorStand.setPassenger((Entity) player);198
armorStand.setSmall(true);199
armorStand.setGravity(false);200
armorStand.setInvulnerable(true);201
armorStand.setVisible(false);203
return armorStand;204
}205
}
3
import org.bukkit.Bukkit;4
import org.bukkit.Material;5
import org.bukkit.block.BlockFace;6
import org.bukkit.entity.Player;7
import org.bukkit.inventory.Inventory;8
import org.bukkit.inventory.ItemStack;
108
}109
}, 0L, DefaultConstants.TICK);110
}112
public static Float convertFacingToYaw(BlockFace face)113
{114
switch(face)115
{116
case NORTH:117
return 0F;118
case EAST:119
return 90F;120
case SOUTH:121
return 180F;122
case WEST:123
return -90F;124
default:125
break;126
}128
return null;129
}131
public static boolean isAir(Material material)132
{133
return material == Material.AIR || material == Material.CAVE_AIR || material == Material.VOID_AIR;134
}135
}
1
Legend:2
[ ] = Open [?] = Test [X] = Done [-] = Ignore [!] = Stuck [/] = Partial [i] = Clarify4
Syntax: [<state>] <message>5
Example: [?] Test latest changes7
----------------------------------------------------------------------------------------------------