Skip to content

Commit

Permalink
[Add] /life command
Browse files Browse the repository at this point in the history
  • Loading branch information
Mori01231 committed Jun 17, 2021
1 parent 36f2138 commit 1c895f0
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import org.apache.tools.ant.filters.ReplaceTokens
apply plugin: 'java'

group = 'com.github.mori01231'
version = '0.11.1'
version = '1.0.0'

sourceCompatibility = '1.8'
targetCompatibility = '1.8'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.github.mori01231.lifecore;

import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;

public class LifeCommandExecutor implements CommandExecutor {

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {

if (sender instanceof Player){
Player player = (Player) sender;
// create bytearray for sending player to server
ByteArrayOutputStream b = new ByteArrayOutputStream();
DataOutputStream out = new DataOutputStream(b);
try {
out.writeUTF("Connect");
out.writeUTF("life");
} catch (IOException e) {
// never happens
}
player.sendPluginMessage(LifeCore.getInstance(), "BungeeCord", b.toByteArray());

}
else{
sender.sendMessage(ChatColor.translateAlternateColorCodes('&',"&3このコマンドはコンソールから使用できません。" ));
}

return true;
}
}
1 change: 1 addition & 0 deletions src/main/java/com/github/mori01231/lifecore/LifeCore.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public void onEnable() {
this.getCommand("guide").setExecutor(new GuideCommandExecutor());
this.getCommand("tutorial").setExecutor(new TutorialCommandExecutor());
this.getCommand("pve").setExecutor(new PveCommandExecutor());
this.getCommand("life").setExecutor(new LifeCommandExecutor());
this.getCommand("rank").setExecutor(new RankCommandExecutor());
this.getCommand("sara").setExecutor(new SaraCommandExecutor());
this.getCommand("trash").setExecutor(new TrashCommandExecutor());
Expand Down
8 changes: 8 additions & 0 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ commands:
description: Teleport to dungeon.
permission: lifecore.pve
usage: Syntax error! Simply type /pve to teleport to dungeon.
life:
description: Teleport to Life server.
permission: lifecore.life
usage: Syntax error! Simply type /life to teleport to Life server.
rank:
description: Show rank.
permission: lifecore.rank
Expand Down Expand Up @@ -66,6 +70,7 @@ permissions:
lifecore.guide: true
lifecore.tutorial: true
lifecore.pve: true
lifecore.life: true
lifecore.rank: true
lifecore.sara: true
lifecore.trash: true
Expand Down Expand Up @@ -93,6 +98,9 @@ permissions:
lifecore.pve:
description: Allows you to skip tp to dungeon.
default: false
lifecore.life:
description: Allows you to go to life server.
default: true
lifecore.rank:
description: Allows you to show your rank.
default: false
Expand Down

0 comments on commit 1c895f0

Please sign in to comment.