PolygonMC is an extended version of the Minestom framework! It is intended to implement minor optimizations such as new events, the Addons and other things.
<repositories>
<!-- ... -->
<repository>
<id>jitpack</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- ... -->
<dependency>
<groupId>com.github.aredblock</groupId>
<artifactId>PolygonMC</artifactId>
<version>VERSION</version>
<exclusions>
<exclusion>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-depchain</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
repositories {
// ...
mavenCentral()
maven(url = "https://jitpack.io")
}
dependencies {
//...
implementation("com.github.aredblock:PolygonMC:VERSION")
}
Note
You can get the latest version here.
If you use the PolygonMC runtime, make sure that your runtime has implemented a current version of the api to be able to execute new addons!
- Command system rework
- Event system rework
- Addons
- AddonMessaging
- Regions
- Instance improvements
- Schematics
- FakePlayer
public final class DemoCommandRegistry implements CommandRegistry {
@RegisterCommand(alias = "demo")
public void demoCommand(CommandInput input){
input.getSender().sendMessage("DEMO");
}
@RegisterCommand(alias = "helloWorld", aliases = { "hello" })
public void helloWorld(CommandInput input){
input.getSender().sendMessage("Hello World!");
}
}
// ...
MinecraftServer.getCommandManager().registerCommandRegistry(new DemoCommandRegistry());
// ...
public final class DemoEventRegistry implements ListenerRegistry {
@EventHandler
//or
@RegisterListener
public void playerSpawnEvent(PlayerSpawnEvent event){
if(event.isFirstSpawn()){
event.getPlayer().sendMessage("Hello World!");
}
}
}
// ...
MinecraftServer.getGlobalEventHandler().registerListenerRegistry(new DemoEventRegistry());
// ...
public final class DemoAddon implements Addon {
@Override
public void onInitialize() {
MinecraftServer.LOGGER.info("DemoAddon initialized!");
var addonManager = MinecraftServer.getAddonManager();
addonManager.getAddonMessageManager().sendMessage("demoaddon", "HelloWorld");
MinecraftServer.LOGGER.info(addonManager.getAddonMessageManager().popMessage("demoaddon"));
}
@Override
public void onShutdown() {
MinecraftServer.LOGGER.info("DemoAddon shutdown!");
}
}
{
"name": "DemoAddon",
"entrypoint": "de.aredblock.polygonmc.addon.DemoAddon"
}
With AddonMessaging it is possible to send simple messages in a Redis-like virtual channel. However, these are only available in the current JVM.
// ...
MinecraftServer.getAddonManager().getAddonMessageManager().sendMessage("demoaddon", "HelloWorld");
MinecraftServer.LOGGER.info(addonManager.getAddonMessageManager().popMessage("demoaddon"));
// ...
Regions are a region between two positions. In regions, you can easily check whether a certain position is located within a region.
// ...
var spawnRegion = new Region(new Pos(-10, 30, -10), new Pos(10, 60, 10));
if(spawnRegion.isInRegion(new Pos(0,42,0))){
//This position is located in this region.
}
// ...
// ...
MinecraftServer.getInstanceManager().generateFlat(Block.STONE);
// ...
MinecraftServer.getInstanceManager().generateFromFile(new File("worlds/world"));
// ...
// ...
var schematic = new Schematic(new File("demo.schem"))
.updateOption(SchematicOption.AIRPLACEMENT, false);
schematic.paste(player.getInstance(), player.getPosition());
// ...
// ...
FakePlayer.builder()
.skin(player.getSkin())
.instance(player.getInstance())
.position(location)
.build();
// ...