Skip to content

Commit 6415ce6

Browse files
authored
Bigger commit
2 parents 1570349 + e4bf386 commit 6415ce6

File tree

9 files changed

+369
-1
lines changed

9 files changed

+369
-1
lines changed

README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# DevSchool Group B
2+
3+
Learning course for young enthusiasts<br>
4+
focused on the basics of object-oriented programming and algorithmization. <br>
5+
The course is divided into two groups (Spigot API and Spring Boot)<br>
6+
into which participants are divided after obtaining the necessary Java basics.
7+
8+
### WARNING
9+
This project is not intended for perfect implementation of a specific module <br>
10+
only for demonstration of solution that is not 100% error proof! <br>
11+
Any use is at your own risk, and no one is responsible for any errors! <br>
12+
EDUCATIONAL PURPOSES ONLY.
13+
14+
### Some info
15+
**This project si only for education for Group B in DevSchool!**<br>
16+
In this project, we use as few libraries as possible to help students learn to work with Java and the Spigot API as much as possible.
17+
18+
19+
20+
### Links
21+
* <a href="https://github.com/ForestTechMC" target="_blank">ForestTech</a>
22+
* <a href="https://discord.gg/BnYncjGma5" target="_blank">DevSchool</a>

pom.xml

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,95 @@
1414
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
1515
</properties>
1616

17+
<build>
18+
<resources>
19+
<resource>
20+
<directory>src/main/resources</directory>
21+
<filtering>true</filtering>
22+
<includes>
23+
<include>plugin.yml</include>
24+
</includes>
25+
</resource>
26+
<resource>
27+
<directory>src/main/resources</directory>
28+
<filtering>false</filtering>
29+
<excludes>
30+
<exclude>plugin.yml</exclude>
31+
</excludes>
32+
</resource>
33+
</resources>
34+
<plugins>
35+
<plugin>
36+
<groupId>org.apache.maven.plugins</groupId>
37+
<artifactId>maven-dependency-plugin</artifactId>
38+
</plugin>
39+
<plugin>
40+
<artifactId>maven-compiler-plugin</artifactId>
41+
<configuration>
42+
<source>1.8</source>
43+
<target>1.8</target>
44+
</configuration>
45+
</plugin>
46+
<plugin>
47+
<groupId>org.apache.maven.plugins</groupId>
48+
<artifactId>maven-shade-plugin</artifactId>
49+
<version>3.2.2</version>
50+
<executions>
51+
<execution>
52+
<phase>package</phase>
53+
<goals>
54+
<goal>shade</goal>
55+
</goals>
56+
<configuration>
57+
<filters>
58+
<filter>
59+
<artifact>*:*</artifact>
60+
<excludes>
61+
<exclude>META-INF/license/**</exclude>
62+
<exclude>META-INF/*</exclude>
63+
<exclude>META-INF/maven/**</exclude>
64+
<exclude>LICENSE</exclude>
65+
<exclude>NOTICE</exclude>
66+
<exclude>/*.txt</exclude>
67+
<exclude>build.properties</exclude>
68+
</excludes>
69+
</filter>
70+
</filters>
71+
</configuration>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
</plugins>
76+
</build>
77+
78+
<repositories>
79+
<repository>
80+
<id>spigot-repo</id>
81+
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
82+
</repository>
83+
<repository>
84+
<id>maven-central</id>
85+
<url>https://oss.sonatype.org/content/groups/public</url>
86+
</repository>
87+
<repository>
88+
<id>jitpack.io</id>
89+
<url>https://jitpack.io</url>
90+
</repository>
91+
</repositories>
92+
93+
94+
<dependencies>
95+
<dependency>
96+
<groupId>com.tchristofferson</groupId>
97+
<artifactId>ConfigUpdater</artifactId>
98+
<version>2.0-SNAPSHOT</version>
99+
</dependency>
100+
<dependency>
101+
<groupId>org.spigotmc</groupId>
102+
<artifactId>spigot-api</artifactId>
103+
<version>1.19-R0.1-SNAPSHOT</version>
104+
<scope>provided</scope>
105+
</dependency>
106+
</dependencies>
107+
17108
</project>
Lines changed: 56 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,61 @@
11
package org.devschool;
22

3-
public class Main {
3+
import jdk.javadoc.internal.doclets.toolkit.Messages;
4+
import org.bukkit.Bukkit;
5+
import org.bukkit.plugin.java.JavaPlugin;
6+
import org.devschool.modules.messages.manager.MessagesManager;
7+
import org.devschool.modules.messages.taker.MessagesTaker;
48

9+
import java.util.logging.Level;
510

11+
/**
12+
* Because of the education of people only,
13+
* this way is much cut and easier
14+
*/
15+
public class Main extends JavaPlugin {
16+
17+
// Instance for main class
18+
private static Main instance;
19+
20+
private MessagesManager messagesManager;
21+
private MessagesTaker messagesTaker;
22+
@Override
23+
public void onEnable() {
24+
instance = this;
25+
26+
messagesManager = new MessagesManager();
27+
messagesTaker = new MessagesTaker();
28+
29+
Bukkit.getLogger().log(Level.INFO, " -<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-");
30+
Bukkit.getLogger().log(Level.INFO, " ");
31+
Bukkit.getLogger().log(Level.INFO, " DevSchoolB (" + getDescription().getVersion() + ")");
32+
Bukkit.getLogger().log(Level.INFO, " Authors: " + getDescription().getAuthors());
33+
Bukkit.getLogger().log(Level.INFO, " Description: " + getDescription().getDescription());
34+
Bukkit.getLogger().log(Level.INFO, " ");
35+
Bukkit.getLogger().log(Level.INFO, " -<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-");
36+
}
37+
38+
@Override
39+
public void onDisable() {
40+
Bukkit.getLogger().log(Level.WARNING, " -<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-");
41+
Bukkit.getLogger().log(Level.WARNING, " ");
42+
Bukkit.getLogger().log(Level.WARNING, " DevSchoolB (" + getDescription().getVersion() + ")");
43+
Bukkit.getLogger().log(Level.WARNING, " Authors: " + getDescription().getAuthors());
44+
Bukkit.getLogger().log(Level.WARNING, " Description: " + getDescription().getDescription());
45+
Bukkit.getLogger().log(Level.WARNING, " ");
46+
Bukkit.getLogger().log(Level.WARNING, " -<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-<|>-");
47+
}
48+
49+
public static Main getInstance() {
50+
return instance;
51+
}
52+
53+
54+
public MessagesManager getMessagesManager() {
55+
return messagesManager;
56+
}
57+
58+
public MessagesTaker getMessagesTaker() {
59+
return messagesTaker;
60+
}
661
}
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
package org.devschool.modules.messages.manager;
2+
3+
import org.bukkit.ChatColor;
4+
import org.bukkit.entity.Player;
5+
import org.devschool.Main;
6+
7+
import java.util.Arrays;
8+
import java.util.HashMap;
9+
import java.util.List;
10+
11+
public class MessagesManager {
12+
13+
private Main plugin;
14+
15+
private HashMap<String, String> messageHashMap;
16+
private List<String> legacyColors = Arrays.asList("&0", "&1", "&2", "&3", "&4", "&5", "&6", "&7", "&8", "&9", "&a", "&b", "&c", "&d", "&e", "§0", "§1", "§2", "§3", "§4", "§5", "§6", "§7", "§8", "§9", "§a", "§b", "§c", "§d", "§e");
17+
private List<String> specialChars = Arrays.asList("&l", "&n", "&o", "&k", "&m", "§l", "§n", "§o", "§k", "§m");
18+
19+
/**
20+
* Simple example of manager for messages without database!
21+
*
22+
* The easiest way to store messages,
23+
* because of the education of people only,
24+
* this way is much cut and easier
25+
*
26+
*/
27+
public MessagesManager() {
28+
this.plugin = Main.getInstance();
29+
loadData();
30+
}
31+
32+
public void loadData() {
33+
messageHashMap = new HashMap<>();
34+
35+
addMessage("super", "&cSuper zpráva");
36+
addMessage("bad", "Super zpráva");
37+
addMessage("no_perm", "&cMáš nedostatečná oprávnění na to provést tento příkaz!");
38+
addMessage("success_remove", "&aÚspěšně si odstranil zprávů!");
39+
}
40+
41+
public void removeMessage(String name) {
42+
getMessages().remove(name.toLowerCase());
43+
}
44+
45+
public String removeColorsAndChars(String input) {
46+
for (String chars : specialChars) {
47+
if (!input.contains(chars)) {
48+
continue;
49+
}
50+
input = input.replaceAll(chars, "");
51+
}
52+
53+
for (String colors : legacyColors) {
54+
if (!input.contains(colors)) {
55+
continue;
56+
}
57+
input = input.replaceAll(colors, "");
58+
}
59+
60+
return input;
61+
}
62+
63+
public void sendMessage(Player player, String msg, boolean colorize) {
64+
if (!colorize) {
65+
msg = removeColorsAndChars(msg);
66+
player.sendMessage(msg);
67+
return;
68+
}
69+
player.sendMessage(ChatColor.translateAlternateColorCodes('&', msg));
70+
return;
71+
}
72+
73+
public void addMessage(String name, String content) {
74+
getMessages().put(name.toLowerCase(), content);
75+
}
76+
77+
public String getMsg(String name) {
78+
return messageHashMap.get(name.toLowerCase());
79+
}
80+
81+
public HashMap<String, String> getMessages() {
82+
return messageHashMap;
83+
}
84+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package org.devschool.modules.messages.taker;
2+
3+
import org.bukkit.Bukkit;
4+
import org.bukkit.entity.Player;
5+
import org.devschool.Main;
6+
7+
import java.util.logging.Level;
8+
9+
public class MessagesTaker {
10+
11+
private Main plugin;
12+
13+
/**
14+
* The easiest way to store messages,
15+
* because of the education of people only,
16+
* this way is much cut and easier
17+
*/
18+
public MessagesTaker() {
19+
this.plugin = Main.getInstance();
20+
}
21+
22+
public void sendMessage(Player player, String nameOfMessage, boolean colorize) {
23+
if (nameOfMessage.isEmpty()) {
24+
Bukkit.getLogger().log(Level.INFO, "Message "+ nameOfMessage +" is null!");
25+
return;
26+
}
27+
28+
String message = plugin.getMessagesManager().getMsg(nameOfMessage);
29+
30+
if (message == null || message.isEmpty()) {
31+
return;
32+
}
33+
34+
if (player == null) {
35+
return;
36+
}
37+
38+
plugin.getMessagesManager().sendMessage(player, message, colorize);
39+
}
40+
41+
public void removeMessage(Player player, String nameOfMessage) {
42+
if (!player.hasPermission("messages.remove") && !player.hasPermission("messages.admin")) {
43+
plugin.getMessagesManager().sendMessage(player, "no_perm", true);
44+
return;
45+
}
46+
47+
if (nameOfMessage.isEmpty()) {
48+
return;
49+
}
50+
51+
String message = plugin.getMessagesManager().getMsg(nameOfMessage);
52+
if (message == null || message.isEmpty()) {
53+
return;
54+
}
55+
56+
plugin.getMessagesManager().removeMessage(nameOfMessage);
57+
plugin.getMessagesManager().sendMessage(player, "success_remove", true);
58+
}
59+
60+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package org.devschool.modules.user;
2+
3+
public class User {
4+
5+
private String name;
6+
7+
private String description;
8+
9+
private int IQ;
10+
11+
public User(String name, String description, int IQ) {
12+
this.name = name;
13+
this.description = description;
14+
this.IQ = IQ;
15+
}
16+
17+
public String getName() {
18+
return name;
19+
}
20+
21+
public void setName(String name) {
22+
this.name = name;
23+
}
24+
25+
public String getDescription() {
26+
return description;
27+
}
28+
29+
public void setDescription(String description) {
30+
this.description = description;
31+
}
32+
33+
public int getIQ() {
34+
return IQ;
35+
}
36+
37+
public void setIQ(int IQ) {
38+
this.IQ = IQ;
39+
}
40+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.devschool.modules.user.manager;
2+
3+
public class UserManager {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.devschool.modules.user.taker;
2+
3+
public class UserTaker {
4+
}

src/main/resources/plugin.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
name: DevSchoolB
2+
author: Fly_Ultra
3+
version: 1.0.0
4+
main: org.devschool.Main
5+
database: false
6+
description: "Plugin for teaching young Developers in DevSchool by ForestTech"
7+
8+
commands:

0 commit comments

Comments
 (0)