Skip to content

Commit ff84884

Browse files
committed
yeh
0 parents  commit ff84884

File tree

13 files changed

+687
-0
lines changed

13 files changed

+687
-0
lines changed

.gitignore

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# User-specific stuff
2+
.idea/
3+
4+
*.iml
5+
*.ipr
6+
*.iws
7+
8+
# IntelliJ
9+
out/
10+
11+
# Compiled class file
12+
*.class
13+
14+
# Log file
15+
*.log
16+
17+
# BlueJ files
18+
*.ctxt
19+
20+
# Package Files #
21+
*.jar
22+
*.war
23+
*.nar
24+
*.ear
25+
*.zip
26+
*.tar.gz
27+
*.rar
28+
29+
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
30+
hs_err_pid*
31+
32+
*~
33+
34+
# temporary files which can be created if a process still has a handle open of a deleted file
35+
.fuse_hidden*
36+
37+
# KDE directory preferences
38+
.directory
39+
40+
# Linux trash folder which might appear on any partition or disk
41+
.Trash-*
42+
43+
# .nfs files are created when an open file is removed but is still being accessed
44+
.nfs*
45+
46+
# General
47+
.DS_Store
48+
.AppleDouble
49+
.LSOverride
50+
51+
# Icon must end with two \r
52+
Icon
53+
54+
# Thumbnails
55+
._*
56+
57+
# Files that might appear in the root of a volume
58+
.DocumentRevisions-V100
59+
.fseventsd
60+
.Spotlight-V100
61+
.TemporaryItems
62+
.Trashes
63+
.VolumeIcon.icns
64+
.com.apple.timemachine.donotpresent
65+
66+
# Directories potentially created on remote AFP share
67+
.AppleDB
68+
.AppleDesktop
69+
Network Trash Folder
70+
Temporary Items
71+
.apdisk
72+
73+
# Windows thumbnail cache files
74+
Thumbs.db
75+
Thumbs.db:encryptable
76+
ehthumbs.db
77+
ehthumbs_vista.db
78+
79+
# Dump file
80+
*.stackdump
81+
82+
# Folder config file
83+
[Dd]esktop.ini
84+
85+
# Recycle Bin used on file shares
86+
$RECYCLE.BIN/
87+
88+
# Windows Installer files
89+
*.cab
90+
*.msi
91+
*.msix
92+
*.msm
93+
*.msp
94+
95+
# Windows shortcuts
96+
*.lnk
97+
98+
target/
99+
100+
pom.xml.tag
101+
pom.xml.releaseBackup
102+
pom.xml.versionsBackup
103+
pom.xml.next
104+
105+
release.properties
106+
dependency-reduced-pom.xml
107+
buildNumber.properties
108+
.mvn/timing.properties
109+
.mvn/wrapper/maven-wrapper.jar
110+
.flattened-pom.xml
111+
112+
# Common working directory
113+
run/

pom.xml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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>simplexity</groupId>
8+
<artifactId>SimpleHomes</artifactId>
9+
<version>0.0.0</version>
10+
<packaging>jar</packaging>
11+
12+
<name>SimpleHomes</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>16</source>
27+
<target>16</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.4-R0.1-SNAPSHOT</version>
68+
<scope>provided</scope>
69+
</dependency>
70+
<dependency>
71+
<groupId>org.xerial</groupId>
72+
<artifactId>sqlite-jdbc</artifactId>
73+
<version>3.45.1.0</version>
74+
</dependency>
75+
</dependencies>
76+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package simplexity.simplehomes;
2+
3+
import org.bukkit.Location;
4+
5+
public class Home {
6+
7+
private final String name;
8+
private final Location location;
9+
public Home(String name, Location location){
10+
this.name = name;
11+
this.location = location;
12+
}
13+
14+
public String getName() {
15+
return name;
16+
}
17+
18+
public Location getLocation() {
19+
return location;
20+
}
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package simplexity.simplehomes;
2+
3+
import org.bukkit.Location;
4+
5+
public class SafetyCheck {
6+
7+
public boolean isSafe(Location location){
8+
return false;
9+
}
10+
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package simplexity.simplehomes;
2+
3+
import net.kyori.adventure.text.minimessage.MiniMessage;
4+
import org.bukkit.plugin.java.JavaPlugin;
5+
import simplexity.simplehomes.commands.DelHomeCommand;
6+
import simplexity.simplehomes.commands.SetHomeCommand;
7+
import simplexity.simplehomes.configs.LocaleHandler;
8+
import simplexity.simplehomes.saving.SQLiteHandler;
9+
10+
public final class SimpleHomes extends JavaPlugin {
11+
12+
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
13+
private static SimpleHomes instance;
14+
15+
16+
@Override
17+
public void onEnable() {
18+
instance = this;
19+
saveDefaultConfig();
20+
LocaleHandler.getInstance().loadLocale();
21+
SQLiteHandler.getInstance().init();
22+
this.getCommand("sethome").setExecutor(new SetHomeCommand());
23+
this.getCommand("delhome").setExecutor(new DelHomeCommand());
24+
// Plugin startup logic
25+
26+
}
27+
28+
public static SimpleHomes getInstance() {
29+
return instance;
30+
}
31+
32+
public static MiniMessage getMiniMessage(){
33+
return miniMessage;
34+
}
35+
@Override
36+
public void onDisable() {
37+
// Plugin shutdown logic
38+
}
39+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package simplexity.simplehomes.commands;
2+
3+
import org.bukkit.command.Command;
4+
import org.bukkit.command.CommandSender;
5+
import org.bukkit.command.TabExecutor;
6+
import org.bukkit.entity.Player;
7+
import org.jetbrains.annotations.NotNull;
8+
import org.jetbrains.annotations.Nullable;
9+
import simplexity.simplehomes.Home;
10+
import simplexity.simplehomes.configs.LocaleHandler;
11+
import simplexity.simplehomes.saving.SQLiteHandler;
12+
13+
import java.util.List;
14+
15+
public class DelHomeCommand implements TabExecutor {
16+
17+
@Override
18+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
19+
if (!(sender instanceof Player player)) {
20+
sender.sendRichMessage(LocaleHandler.getInstance().getMustBePlayer());
21+
return false;
22+
}
23+
List<Home> playerHomes = SQLiteHandler.getInstance().getHomes(player);
24+
if (args.length < 1) {
25+
sender.sendRichMessage(LocaleHandler.getInstance().getProvideHomeName());
26+
return false;
27+
}
28+
String homeName = args[0];
29+
if (homeExists(playerHomes, homeName)) {
30+
SQLiteHandler.getInstance().deleteHome(player, homeName);
31+
player.sendMessage(LocaleHandler.getInstance().getHomeDeleted());
32+
} else {
33+
player.sendMessage(LocaleHandler.getInstance().getHomeNotFound());
34+
}
35+
return false;
36+
}
37+
38+
@Override
39+
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
40+
return null;
41+
}
42+
43+
private boolean homeExists(List<Home> homes, String homeName) {
44+
for (Home home : homes) {
45+
if (home.getName().equalsIgnoreCase(homeName)) {
46+
return true;
47+
}
48+
}
49+
return false;
50+
}
51+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
package simplexity.simplehomes.commands;
2+
3+
import net.kyori.adventure.text.minimessage.MiniMessage;
4+
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
5+
import org.bukkit.Location;
6+
import org.bukkit.command.Command;
7+
import org.bukkit.command.CommandSender;
8+
import org.bukkit.command.TabExecutor;
9+
import org.bukkit.entity.Player;
10+
import org.jetbrains.annotations.NotNull;
11+
import org.jetbrains.annotations.Nullable;
12+
import simplexity.simplehomes.Home;
13+
import simplexity.simplehomes.SimpleHomes;
14+
import simplexity.simplehomes.configs.LocaleHandler;
15+
import simplexity.simplehomes.saving.SQLiteHandler;
16+
17+
import java.util.List;
18+
19+
public class SetHomeCommand implements TabExecutor {
20+
21+
MiniMessage miniMessage = SimpleHomes.getMiniMessage();
22+
// /sethome name
23+
/*
24+
/sethome - no args, if has no home set, will set first home, if has home, will ask for additional arguments
25+
/sethome <name> - check if another home has that name, if it does, return and let player know
26+
/sethome <name> -o - overwrites the previous home named that if one existed
27+
each home set checks on how many homes the person has permissions to have, returns if the person has too many
28+
*/
29+
@Override
30+
public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
31+
if (!(sender instanceof Player player)) {
32+
sender.sendRichMessage(LocaleHandler.getInstance().getMustBePlayer());
33+
return false;
34+
}
35+
List<Home> playerHomes = SQLiteHandler.getInstance().getHomes(player);
36+
if (args.length < 1 && !playerHomes.isEmpty()) {
37+
sender.sendRichMessage(LocaleHandler.getInstance().getProvideHomeName());
38+
return false;
39+
}
40+
Location playerLocation = player.getLocation().toCenterLocation();
41+
String homeName = args[0];
42+
boolean overwrite = false;
43+
if (args.length > 1) {
44+
if (args[1].equalsIgnoreCase("-o")) {
45+
overwrite = true;
46+
}
47+
}
48+
if (homeExists(playerHomes, homeName) && !overwrite) {
49+
player.sendRichMessage(LocaleHandler.getInstance().getHomeExists());
50+
return false;
51+
}
52+
SQLiteHandler.getInstance().setHome(player, homeName, playerLocation, overwrite);
53+
player.sendMessage(miniMessage.deserialize(LocaleHandler.getInstance().getHomeSet(),
54+
Placeholder.unparsed("name", homeName)));
55+
return true;
56+
}
57+
58+
@Override
59+
public @Nullable List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String s, @NotNull String[] args) {
60+
return List.of("");
61+
}
62+
63+
private boolean homeExists(List<Home> homes, String homeName) {
64+
for (Home home : homes) {
65+
if (home.getName().equalsIgnoreCase(homeName)) {
66+
return true;
67+
}
68+
}
69+
return false;
70+
}
71+
}

0 commit comments

Comments
 (0)