Skip to content

Commit 03a00cf

Browse files
authored
First Commit
0 parents  commit 03a00cf

File tree

20 files changed

+309
-0
lines changed

20 files changed

+309
-0
lines changed

MyFirstPlugin/MyFirstPlugin.iml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<module version="4">
3+
<component name="FacetManager">
4+
<facet type="minecraft" name="Minecraft">
5+
<configuration>
6+
<autoDetectTypes>
7+
<platformType>PAPER</platformType>
8+
<platformType>ADVENTURE</platformType>
9+
</autoDetectTypes>
10+
<projectReimportVersion>1</projectReimportVersion>
11+
</configuration>
12+
</facet>
13+
</component>
14+
</module>

MyFirstPlugin/pom.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
7+
<groupId>me.somename</groupId>
8+
<artifactId>MyFirstPlugin</artifactId>
9+
<version>1.0-SNAPSHOT</version>
10+
<packaging>jar</packaging>
11+
12+
<name>MyFirstPlugin</name>
13+
14+
<properties>
15+
<java.version>1.8</java.version>
16+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
17+
</properties>
18+
19+
<build>
20+
<plugins>
21+
<plugin>
22+
<groupId>org.apache.maven.plugins</groupId>
23+
<artifactId>maven-compiler-plugin</artifactId>
24+
<version>3.8.1</version>
25+
<configuration>
26+
<source>${java.version}</source>
27+
<target>${java.version}</target>
28+
</configuration>
29+
</plugin>
30+
<plugin>
31+
<groupId>org.apache.maven.plugins</groupId>
32+
<artifactId>maven-shade-plugin</artifactId>
33+
<version>3.2.4</version>
34+
<executions>
35+
<execution>
36+
<phase>package</phase>
37+
<goals>
38+
<goal>shade</goal>
39+
</goals>
40+
</execution>
41+
</executions>
42+
</plugin>
43+
</plugins>
44+
<resources>
45+
<resource>
46+
<directory>src/main/resources</directory>
47+
<filtering>true</filtering>
48+
</resource>
49+
</resources>
50+
</build>
51+
52+
<repositories>
53+
<repository>
54+
<id>papermc-repo</id>
55+
<url>https://repo.papermc.io/repository/maven-public/</url>
56+
</repository>
57+
<repository>
58+
<id>sonatype</id>
59+
<url>https://oss.sonatype.org/content/groups/public/</url>
60+
</repository>
61+
</repositories>
62+
63+
<dependencies>
64+
<dependency>
65+
<groupId>io.papermc.paper</groupId>
66+
<artifactId>paper-api</artifactId>
67+
<version>1.20.6-R0.1-SNAPSHOT</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
</dependencies>
71+
</project>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package me.somename.myfirstplugin;
2+
3+
import me.somename.myfirstplugin.commands.FakeOpCommand;
4+
import me.somename.myfirstplugin.commands.InvisibleCommand;
5+
import me.somename.myfirstplugin.commands.ProtectCommand;
6+
import me.somename.myfirstplugin.commands.TPCommand;
7+
import org.bukkit.event.EventHandler;
8+
import org.bukkit.event.Listener;
9+
import org.bukkit.event.player.PlayerJoinEvent;
10+
import org.bukkit.plugin.java.JavaPlugin;
11+
12+
public final class MyFirstPlugin extends JavaPlugin implements Listener {
13+
14+
@Override
15+
public void onEnable() {
16+
getLogger().info("My First Plugin started!");
17+
getCommand("protect").setExecutor(new ProtectCommand());
18+
getCommand("invisible").setExecutor(new InvisibleCommand());
19+
getCommand("tp").setExecutor(new TPCommand());
20+
getCommand("fakeop").setExecutor(new FakeOpCommand());
21+
}
22+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package me.somename.myfirstplugin.commands;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.ChatColor;
5+
import org.bukkit.command.Command;
6+
import org.bukkit.command.CommandSender;
7+
import org.bukkit.command.CommandExecutor;
8+
import org.bukkit.entity.Player;
9+
10+
public class FakeOpCommand implements CommandExecutor {
11+
12+
@Override
13+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
14+
if (args.length != 1) {
15+
sender.sendMessage("Usage: /fakeop <player>");
16+
return false;
17+
}
18+
19+
Player target = Bukkit.getPlayerExact(args[0]);
20+
21+
if (target == null) {
22+
sender.sendMessage("Player not found.");
23+
return true;
24+
}
25+
26+
target.sendMessage(ChatColor.ITALIC + "" + ChatColor.GRAY + "[Server: Made " + target.getName() + " a server operator]");
27+
sender.sendMessage( ChatColor.GREEN + target.getName() + " has been fake-opped.");
28+
29+
return true;
30+
}
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package me.somename.myfirstplugin.commands;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandExecutor;
6+
import org.bukkit.command.CommandSender;
7+
import org.bukkit.entity.Player;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
public class InvisibleCommand implements CommandExecutor {
11+
@Override
12+
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
13+
if (commandSender instanceof Player) {
14+
Player p = (Player) commandSender;
15+
16+
if (p.isInvisible()) {
17+
p.setInvisible(false);
18+
p.sendMessage(ChatColor.RED + "You are no longer invisible.");
19+
}else {
20+
p.setInvisible(true);
21+
p.sendMessage(ChatColor.GREEN + "You are invisible.");
22+
}
23+
}
24+
25+
return true;
26+
}
27+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package me.somename.myfirstplugin.commands;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandExecutor;
6+
import org.bukkit.command.CommandSender;
7+
import org.bukkit.entity.Player;
8+
import org.jetbrains.annotations.NotNull;
9+
10+
public class ProtectCommand implements CommandExecutor {
11+
12+
@Override
13+
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] strings) {
14+
15+
if (commandSender instanceof Player) {
16+
Player p = (Player) commandSender;
17+
18+
if (p.isInvulnerable()) {
19+
p.setInvulnerable(false);
20+
p.sendMessage(ChatColor.RED + "Protect is disabled.");
21+
22+
23+
}else {
24+
p.setInvulnerable(true);
25+
p.sendMessage(ChatColor.GREEN + "Protect enabled.");
26+
}
27+
}
28+
29+
return true;
30+
}
31+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package me.somename.myfirstplugin.commands;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.ChatColor;
5+
import org.bukkit.command.Command;
6+
import org.bukkit.command.CommandExecutor;
7+
import org.bukkit.command.CommandSender;
8+
import org.bukkit.entity.Player;
9+
import org.jetbrains.annotations.NotNull;
10+
11+
public class TPCommand implements CommandExecutor {
12+
@Override
13+
public boolean onCommand(@NotNull CommandSender commandSender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
14+
if (commandSender instanceof Player) {
15+
Player p = (Player) commandSender;
16+
17+
if (args.length == 0) {
18+
p.sendMessage(ChatColor.RED + "You forgot the player you want to teleport to!");
19+
}else{
20+
String playername = args[0];
21+
22+
Player target = Bukkit.getServer().getPlayerExact(playername);
23+
24+
p.teleport(target);
25+
target.sendMessage(ChatColor.RED + "Player named " + playername + " teleported to you!");
26+
}
27+
}
28+
return true;
29+
}
30+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: MyFirstPlugin
2+
version: '${project.version}'
3+
main: me.somename.myfirstplugin.MyFirstPlugin
4+
api-version: '1.20'
5+
commands:
6+
protect:
7+
description: Become invincible
8+
usage: /<command>
9+
permission: staff.protect
10+
permission-message: You don't have permission to do this!
11+
invisible:
12+
description: Become invisible and visible
13+
usage: /<command>
14+
permission: staff.invisible
15+
permission-message: You don't have permission to do this!
16+
tp:
17+
description: Teleport you to other player
18+
usage: /<command>
19+
permission: staff.teleport
20+
permission-message: You don't have permission to do this!
21+
fakeop:
22+
description: Fake op players
23+
usage: /<command> <player>
24+
permission: staff.fakeop
25+
permission-message: You don't have permission to do this!
26+
27+
permissions:
28+
staff.protect:
29+
description: Allows to run the /protect command
30+
staff.invisible:
31+
description: Allows to run the /invisible command
32+
staff.teleport:
33+
description: Allows to teleport to other player
34+
staff.fakeop:
35+
description: Allows to fake op players
Binary file not shown.
Binary file not shown.

0 commit comments

Comments
 (0)