Skip to content

Instantly share code, notes, and snippets.

@Amejonah1200
Last active December 1, 2019 19:46
Show Gist options
  • Save Amejonah1200/b3f652b483b9c4c277e1c9830fdd1da0 to your computer and use it in GitHub Desktop.
Save Amejonah1200/b3f652b483b9c4c277e1c9830fdd1da0 to your computer and use it in GitHub Desktop.
PlotSquared: Set the border of a plot.
// 1.12.2 and lower
type -> Material
id -> SubID
Plot#setComponent("border", com.intellectualcrafters.plot.config.Configuration.BLOCKLIST.parseString(type.toString() + ":" + id));
// 1.13.2 and higher
type -> Material
Plot#setComponent("border", com.intellectualcrafters.plot.config.Configuration.BLOCKLIST.parseString(type.toString()));
// Set the border of the plot below the player.
// com.intellectualcrafters -> PlotAPI plotApi;
// Player musst be on a Plot! Otherwise : NullPointerException
PlotAPI plotApi = ...;
// 1.12.2 and lower
private void setBorder(Player player, Material type, short id) {
if (plotApi.getPlot(player).getConnectedPlots().size() > 1) {
for (Plot plot : plotApi.getPlot(player).getConnectedPlots()) {
plot.setComponent("border", com.intellectualcrafters.plot.config.Configuration.BLOCKLIST.parseString(type.toString() + ":" + id));
}
} else {
plotApi.getPlot(player).setComponent("border", com.intellectualcrafters.plot.config.Configuration.BLOCKLIST.parseString(type.toString() + ":" + id));
}
}
// 1.13.2 and higher
private void setBorder(Player player, Material type) {
if (plotApi.getPlot(player).getConnectedPlots().size() > 1) {
for (Plot plot : plotApi.getPlot(player).getConnectedPlots()) {
plot.setComponent("border", com.intellectualcrafters.plot.config.Configuration.BLOCKLIST.parseString(type.toString()));
}
} else {
plotApi.getPlot(player).setComponent("border", com.intellectualcrafters.plot.config.Configuration.BLOCKLIST.parseString(type.toString()));
}
}
@Amejonah1200
Copy link
Author

This works only with the old API.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment