A feature-rich Minecraft plugin which enhances gaming experience
git clone git://soophie.de/poppy
4
.classpath5
.project6
*.prefs7
/build/**8
/.gradle/**
1
{2
"java.configuration.updateBuildConfiguration": "automatic"3
}3
\ No newline at end of file
1
apply plugin: 'java'3
sourceSets {4
main {5
java {6
srcDirs 'src'7
}8
resources {9
srcDirs 'res'10
}11
}12
}14
repositories {15
mavenCentral()16
maven {17
url = 'https://hub.spigotmc.org/nexus/content/repositories/public/'18
}19
}21
sourceCompatibility = 1.1122
targetCompatibility = 1.1124
dependencies {25
implementation 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT'26
implementation 'com.google.code.gson:gson:2.8.6'27
}27
\ No newline at end of file
1
main: de.typable.minecrafthub.Main2
name: MinecraftHub3
version: 0.0.14
author: typable5
api-version: 1.166
commands:7
shutdown:8
head:9
skull:10
usage: /skull <player>11
standby:12
usage: /standby <true, false>12
\ No newline at end of file
1
main: de.typable.minecrafthub.Main2
name: MinecraftHub3
version: 0.0.14
author: typable5
api-version: 1.166
commands:7
shutdown:8
head:9
skull:10
usage: /skull <player>11
standby:12
usage: /standby <true, false>12
\ No newline at end of file
3
import java.io.File;4
import java.io.IOException;5
import java.net.BindException;6
import java.net.ServerSocket;7
import java.net.Socket;
18
import org.bukkit.plugin.Plugin;19
import org.bukkit.plugin.PluginManager;20
import org.bukkit.plugin.java.JavaPlugin;21
import org.bukkit.scheduler.BukkitTask;23
import de.typable.minecrafthub.constant.DefaultConstants;24
import de.typable.minecrafthub.event.AutoWorkbenchListener;
39
private EventListener eventListener;41
private Plugin plugin;42
private BukkitTask task;44
@Override45
public void onEnable()
63
eventListener = new EventListener();64
pluginManager.registerEvents(eventListener, this);63
Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable()66
task = Bukkit.getScheduler().runTaskAsynchronously(this, new Runnable()67
{68
@Override69
public void run()
91
socket.close();92
}93
}94
catch(BindException ex)95
{96
// ignore97
}98
catch(IOException ex)99
{100
ex.printStackTrace();
103
});104
}106
@Override107
public void onDisable()108
{109
if(task != null && task.isCancelled())110
{111
task.cancel();112
}114
chairListener.onDisable();115
}117
@SuppressWarnings("deprecation")118
@Override119
public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
7
import org.bukkit.Location;8
import org.bukkit.Material;9
import org.bukkit.block.Block;10
import org.bukkit.block.BlockFace;11
import org.bukkit.block.data.Bisected.Half;12
import org.bukkit.block.data.type.Stairs;12
import org.bukkit.entity.AbstractArrow.PickupStatus;13
import org.bukkit.entity.Arrow;13
import org.bukkit.entity.ArmorStand;14
import org.bukkit.entity.Entity;15
import org.bukkit.entity.EntityType;16
import org.bukkit.entity.Player;17
import org.bukkit.event.EventHandler;18
import org.bukkit.event.Listener;19
import org.bukkit.event.block.Action;20
import org.bukkit.event.block.BlockBreakEvent;21
import org.bukkit.event.player.PlayerInteractEvent;21
import org.bukkit.util.Vector;22
import org.spigotmc.event.entity.EntityDismountEvent;25
public class ChairListener implements Listener26
{27
private static final Material[] CHAIR_TYPE = new Material[] { Material.OAK_STAIRS, Material.SPRUCE_STAIRS, Material.BIRCH_STAIRS, Material.JUNGLE_STAIRS, Material.ACACIA_STAIRS, Material.DARK_OAK_STAIRS, Material.ACACIA_STAIRS, Material.CRIMSON_STAIRS, Material.WARPED_STAIRS };29
private Map<Block, Arrow> blockMap = new HashMap<>();27
private static final Material[] CHAIR_TYPE = new Material[]28
{29
Material.OAK_STAIRS,30
Material.SPRUCE_STAIRS,31
Material.BIRCH_STAIRS,32
Material.JUNGLE_STAIRS,33
Material.ACACIA_STAIRS,34
Material.DARK_OAK_STAIRS,35
Material.ACACIA_STAIRS,36
Material.CRIMSON_STAIRS,37
Material.WARPED_STAIRS38
};40
private Map<Block, ArmorStand> blockMap = new HashMap<>();42
@SuppressWarnings("deprecation")43
@EventHandler
72
if(isCompatible(stairs))73
{63
Location location = block.getLocation().add(0.5, 0, 0.5);64
Arrow arrow = (Arrow) block.getWorld()65
.spawnArrow(location, new Vector(), 0F, 0F);66
arrow.setGravity(false);67
arrow.setInvulnerable(true);68
arrow.setPickupStatus(PickupStatus.DISALLOWED);69
arrow.setPassenger((Entity) event.getPlayer());70
arrow.setTicksLived(0);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);91
event.setCancelled(true);74
blockMap.put(block, arrow);93
blockMap.put(block, armorStand);94
}95
}96
}
105
{106
Entity entity = event.getDismounted();89
if(entity != null && entity instanceof Arrow)108
if(entity != null && entity instanceof ArmorStand)109
{110
if(blockMap.containsValue(entity))111
{93
for(Entry<Block, Arrow> entry : blockMap.entrySet())112
for(Entry<Block, ArmorStand> entry : blockMap.entrySet())113
{114
if(entry.getValue() == entity)115
{
133
if(blockMap.containsKey(block))134
{116
Arrow arrow = blockMap.get(block);117
arrow.eject();135
ArmorStand armorStand = blockMap.get(block);136
armorStand.eject();138
blockMap.remove(block);139
}
164
return false;165
}148
if(stairs.getShape() == Stairs.Shape.INNER_RIGHT || stairs149
.getShape() == Stairs.Shape.INNER_LEFT)167
if(stairs.getShape() == Stairs.Shape.INNER_RIGHT || stairs.getShape() == Stairs.Shape.INNER_LEFT)168
{169
return false;170
}172
return true;173
}175
private Float convertFacingToYaw(BlockFace face)176
{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
}191
return null;192
}194
public void onDisable()195
{196
for(ArmorStand armorStand : blockMap.values())197
{198
armorStand.eject();199
armorStand.remove();200
}201
}202
}