Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
LYEmerald authored Jul 11, 2023
1 parent db1e421 commit 7e1b437
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 0 deletions.
16 changes: 16 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.example</groupId>
<artifactId>PortalCommand</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

</project>
36 changes: 36 additions & 0 deletions src/main/java/net/emeraldly/portalcmd/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.emeraldly.portalcmd;

import cn.nukkit.Player;
import cn.nukkit.event.EventHandler;
import cn.nukkit.event.Listener;
import cn.nukkit.event.player.PlayerTeleportEvent;
import cn.nukkit.plugin.PluginBase;
import cn.nukkit.utils.Config;

import java.util.List;

public class Main extends PluginBase implements Listener {
@Override
public void onEnable(){
this.getLogger().info("§aPortalCommand Plugin Enabled!");
this.getServer().getPluginManager().registerEvents(this,this);
this.getDataFolder().mkdirs();
this.saveDefaultConfig();
Config config = this.getConfig();
}

@EventHandler
public void onPlayerTeleport(PlayerTeleportEvent event){
Player player = event.getPlayer();
String level = event.getPlayer().getLevel().getName();
List<String> list = this.getConfig().getStringList("allow_worlds");
if(list.contains(level)){
if(event.getCause() == PlayerTeleportEvent.TeleportCause.NETHER_PORTAL){
event.setCancelled(true);
for(String command : this.getConfig().getStringList("commands")){
player.getServer().dispatchCommand(event.getPlayer(),command);
}
}
}
}
}
5 changes: 5 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
commands:
- "lobby"

allow_worlds:
- world
5 changes: 5 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
main: net.emeraldly.portalcmd.Main
name: PortalCommand
version: 1.0.0
api: 1.0.0
author: LYEmerald

0 comments on commit 7e1b437

Please sign in to comment.