Skip to content

Commit 062c39b

Browse files
committed
first commit
0 parents  commit 062c39b

File tree

10 files changed

+560
-0
lines changed

10 files changed

+560
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
.vscode
2+
3+
test
4+
5+
target

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Плагин для Minecraft(1.20+) с рандомными событиями (ядро "Purpur")

pom.xml

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<project xmlns="http://maven.apache.org/POM/4.0.0"
4+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
6+
<modelVersion>4.0.0</modelVersion>
7+
8+
<groupId>com.example</groupId>
9+
<artifactId>randomizer</artifactId>
10+
<version>1.0</version>
11+
12+
<properties>
13+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
14+
<maven.compiler.source>1.7</maven.compiler.source>
15+
<maven.compiler.target>1.7</maven.compiler.target>
16+
</properties>
17+
18+
<repositories>
19+
<!-- This adds the Spigot Maven repository to the build -->
20+
<repository>
21+
<id>spigot-repo</id>
22+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
23+
</repository>
24+
</repositories>
25+
26+
<dependencies>
27+
<dependency>
28+
<groupId>junit</groupId>
29+
<artifactId>junit</artifactId>
30+
<version>4.11</version>
31+
<scope>test</scope>
32+
</dependency>
33+
<!--This adds the Spigot API artifact to the build -->
34+
<dependency>
35+
<groupId>org.spigotmc</groupId>
36+
<artifactId>spigot-api</artifactId>
37+
<version>1.15.1-R0.1-SNAPSHOT</version>
38+
<scope>provided</scope>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.apache.maven.plugins</groupId>
42+
<artifactId>maven-compiler-plugin</artifactId>
43+
<version>3.8.0</version>
44+
</dependency>
45+
<dependency>
46+
<groupId>org.apache.maven.plugins</groupId>
47+
<artifactId>maven-jar-plugin</artifactId>
48+
<version>3.0.2</version>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.apache.maven.plugins</groupId>
52+
<artifactId>maven-resources-plugin</artifactId>
53+
<version>3.0.2</version>
54+
</dependency>
55+
<dependency>
56+
<groupId>org.apache.maven.surefire</groupId>
57+
<artifactId>maven-surefire-common</artifactId>
58+
<version>3.1.2</version>
59+
</dependency>
60+
61+
</dependencies>
62+
63+
<build>
64+
<pluginManagement>
65+
<plugins>
66+
<plugin>
67+
<artifactId>maven-clean-plugin</artifactId>
68+
<version>3.1.0</version>
69+
</plugin>
70+
<plugin>
71+
<artifactId>maven-resources-plugin</artifactId>
72+
<version>3.0.2</version>
73+
</plugin>
74+
<plugin>
75+
<artifactId>maven-compiler-plugin</artifactId>
76+
<version>3.8.0</version>
77+
</plugin>
78+
<plugin>
79+
<artifactId>maven-surefire-plugin</artifactId>
80+
<version>2.22.1</version>
81+
</plugin>
82+
<plugin>
83+
<artifactId>maven-jar-plugin</artifactId>
84+
<version>3.0.2</version>
85+
</plugin>
86+
<plugin>
87+
<artifactId>maven-install-plugin</artifactId>
88+
<version>2.5.2</version>
89+
</plugin>
90+
<plugin>
91+
<artifactId>maven-deploy-plugin</artifactId>
92+
<version>2.8.2</version>
93+
</plugin>
94+
</plugins>
95+
</pluginManagement>
96+
</build>
97+
</project>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package com.example.CommandExecutor;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.command.Command;
5+
import org.bukkit.command.CommandExecutor;
6+
import org.bukkit.command.CommandSender;
7+
8+
import com.example.Plugin;
9+
import com.example.Timer;
10+
import com.example.Utils;
11+
12+
import net.md_5.bungee.api.ChatColor;
13+
14+
public class CmdExecutor implements CommandExecutor {
15+
16+
private Timer timer = new Timer();
17+
private boolean timerRunning = false;
18+
private Plugin plugin;
19+
private final int delay = 5;
20+
private int period = 60;
21+
22+
@Override
23+
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
24+
if(label.equalsIgnoreCase("start_randomize") && !timerRunning){
25+
Bukkit.getServer().broadcastMessage(ChatColor.DARK_AQUA + sender.getName() + " запустил randomize! GO! GO! GO!");
26+
if (args.length == 1 && Utils.isNumeric(args[0]))
27+
period = Integer.parseInt(args[0]);
28+
timerRunning = true;
29+
timer.runTaskTimer(plugin, delay * 20L, period * 20L);
30+
return true;
31+
}
32+
else if(label.equalsIgnoreCase("start_randomize")){
33+
sender.sendMessage(ChatColor.RED + "Randomizer уже запущен!");
34+
return true;
35+
}
36+
37+
if(label.equalsIgnoreCase("stop_randomize") && timerRunning){
38+
Bukkit.getServer().broadcastMessage(ChatColor.RED + "Randomizer отключен!");
39+
timerRunning = false;
40+
timer.cancel();
41+
timer = new Timer();
42+
return true;
43+
}
44+
else if(label.equalsIgnoreCase("stop_randomize"))
45+
{
46+
sender.sendMessage(ChatColor.RED + "Randomizer уже отключен!");
47+
return true;
48+
}
49+
50+
return false;
51+
}
52+
53+
}

0 commit comments

Comments
 (0)