mirror of
https://github.com/yawaflua/SexPlugin.git
synced 2026-02-04 10:34:10 +02:00
Created a plugin
This commit is contained in:
113
.gitignore
vendored
Normal file
113
.gitignore
vendored
Normal file
@@ -0,0 +1,113 @@
|
|||||||
|
# User-specific stuff
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
|
||||||
|
# IntelliJ
|
||||||
|
out/
|
||||||
|
|
||||||
|
# Compiled class file
|
||||||
|
*.class
|
||||||
|
|
||||||
|
# Log file
|
||||||
|
*.log
|
||||||
|
|
||||||
|
# BlueJ files
|
||||||
|
*.ctxt
|
||||||
|
|
||||||
|
# Package Files #
|
||||||
|
*.jar
|
||||||
|
*.war
|
||||||
|
*.nar
|
||||||
|
*.ear
|
||||||
|
*.zip
|
||||||
|
*.tar.gz
|
||||||
|
*.rar
|
||||||
|
|
||||||
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
|
hs_err_pid*
|
||||||
|
|
||||||
|
*~
|
||||||
|
|
||||||
|
# temporary files which can be created if a process still has a handle open of a deleted file
|
||||||
|
.fuse_hidden*
|
||||||
|
|
||||||
|
# KDE directory preferences
|
||||||
|
.directory
|
||||||
|
|
||||||
|
# Linux trash folder which might appear on any partition or disk
|
||||||
|
.Trash-*
|
||||||
|
|
||||||
|
# .nfs files are created when an open file is removed but is still being accessed
|
||||||
|
.nfs*
|
||||||
|
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two \r
|
||||||
|
Icon
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
target/
|
||||||
|
|
||||||
|
pom.xml.tag
|
||||||
|
pom.xml.releaseBackup
|
||||||
|
pom.xml.versionsBackup
|
||||||
|
pom.xml.next
|
||||||
|
|
||||||
|
release.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
buildNumber.properties
|
||||||
|
.mvn/timing.properties
|
||||||
|
.mvn/wrapper/maven-wrapper.jar
|
||||||
|
.flattened-pom.xml
|
||||||
|
|
||||||
|
# Common working directory
|
||||||
|
run/
|
||||||
78
pom.xml
Normal file
78
pom.xml
Normal file
@@ -0,0 +1,78 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>org.yawaflua</groupId>
|
||||||
|
<artifactId>SexPlugin</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<name>SexPlugin</name>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<java.version>1.8</java.version>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>${java.version}</source>
|
||||||
|
<target>${java.version}</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<includes>
|
||||||
|
<include>plugin.yml</include>
|
||||||
|
</includes>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>papermc-repo</id>
|
||||||
|
<url>https://repo.papermc.io/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>sonatype</id>
|
||||||
|
<url>https://oss.sonatype.org/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.papermc.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.20.4-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</project>
|
||||||
77
src/main/java/org/yawaflua/sexplugin/Sex.java
Normal file
77
src/main/java/org/yawaflua/sexplugin/Sex.java
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
package org.yawaflua.sexplugin;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.yawaflua.sexplugin.Utils.Parser;
|
||||||
|
|
||||||
|
|
||||||
|
public class Sex extends JavaPlugin {
|
||||||
|
public void onEnable() {
|
||||||
|
this.saveDefaultConfig();
|
||||||
|
this.getCommand("sex").setExecutor(this);
|
||||||
|
this.getLogger().info("§7| ");
|
||||||
|
this.getLogger().info("§7| §bSEX???");
|
||||||
|
this.getLogger().info("§7| §fDeveloper: §byawaflua");
|
||||||
|
this.getLogger().info("§7| §fVersion: §b1.0");
|
||||||
|
this.getLogger().info("§7| ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onDisable() {
|
||||||
|
this.getLogger().info("§7| ");
|
||||||
|
this.getLogger().info("§7| §bSEX???");
|
||||||
|
this.getLogger().info("§7| §fDeveloper: §byawaflua");
|
||||||
|
this.getLogger().info("§7| §fVersion: §b1.0");
|
||||||
|
this.getLogger().info("§7| §fThnx: §bMellsher & 5OPKA");
|
||||||
|
this.getLogger().info("§7| ");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
String consoleUse = this.getConfig().getString("messages.consoleUse");
|
||||||
|
sender.sendMessage(Parser.hex(consoleUse));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
Player player = (Player)sender;
|
||||||
|
String targetName;
|
||||||
|
if (args.length != 1) {
|
||||||
|
targetName = this.getConfig().getString("messages.use");
|
||||||
|
player.sendMessage(Parser.hex(targetName));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
targetName = args[0];
|
||||||
|
Player target = Bukkit.getPlayer(targetName);
|
||||||
|
if (target == null) {
|
||||||
|
String notFound = this.getConfig().getString("messages.notFound");
|
||||||
|
player.sendMessage(Parser.hex(notFound));
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
double distance = player.getLocation().distance(target.getLocation());
|
||||||
|
String titlePlayer;
|
||||||
|
if (distance > this.getConfig().getDouble("settings.distance")) {
|
||||||
|
titlePlayer = this.getConfig().getString("messages.far").replace("%target%", target.getName());
|
||||||
|
player.sendMessage("Игрок " + target.getName() + " слишком далеко!");
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 0));
|
||||||
|
target.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, 60, 0));
|
||||||
|
player.playSound(player.getLocation(), Sound.ENTITY_GHAST_SCREAM, 1.0F, 1.0F);
|
||||||
|
target.playSound(target.getLocation(), Sound.ENTITY_GHAST_SCREAM, 1.0F, 1.0F);
|
||||||
|
titlePlayer = this.getConfig().getString("settings.title.player.title").replace("%target%", target.getName());
|
||||||
|
String subtitlePlayer = this.getConfig().getString("settings.title.player.subtitle").replace("%target%", target.getName());
|
||||||
|
player.sendTitle(Parser.hex(titlePlayer), Parser.hex(subtitlePlayer), 0, 40, 0);
|
||||||
|
String titleTarget = this.getConfig().getString("settings.title.target.title").replace("%player%", player.getName());
|
||||||
|
String subtitleTarget = this.getConfig().getString("settings.title.target.subtitle").replace("%player%", player.getName());
|
||||||
|
target.sendTitle(Parser.hex(titleTarget), Parser.hex(subtitleTarget), 0, 40, 0);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
29
src/main/java/org/yawaflua/sexplugin/Utils/Parser.java
Normal file
29
src/main/java/org/yawaflua/sexplugin/Utils/Parser.java
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
package org.yawaflua.sexplugin.Utils;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
public class Parser {
|
||||||
|
public static String hex(String message) {
|
||||||
|
Pattern pattern = Pattern.compile("(#[a-fA-F0-9]{6})");
|
||||||
|
|
||||||
|
for(Matcher matcher = pattern.matcher(message); matcher.find(); matcher = pattern.matcher(message)) {
|
||||||
|
String hexCode = message.substring(matcher.start(), matcher.end());
|
||||||
|
String replaceSharp = hexCode.replace('#', 'x');
|
||||||
|
char[] ch = replaceSharp.toCharArray();
|
||||||
|
StringBuilder builder = new StringBuilder("");
|
||||||
|
char[] var7 = ch;
|
||||||
|
int var8 = ch.length;
|
||||||
|
|
||||||
|
for(int var9 = 0; var9 < var8; ++var9) {
|
||||||
|
char c = var7[var9];
|
||||||
|
builder.append("&" + c);
|
||||||
|
}
|
||||||
|
|
||||||
|
message = message.replace(hexCode, builder.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', message).replace('&', '§');
|
||||||
|
}
|
||||||
|
}
|
||||||
30
src/main/resources/config.yml
Normal file
30
src/main/resources/config.yml
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
messages:
|
||||||
|
# Сообщение которое будет выводиться если команду ввели из консоли
|
||||||
|
consoleUse: "&#fb0000Только игроки могут использовать эту команду!"
|
||||||
|
# Сообщение которое будет выводиться если ввели меньше или больше 1 аргумента
|
||||||
|
use: "&fИспользование: ab6fb/sex <ник>"
|
||||||
|
# Сообщение которое будет выводиться если игрок которого указали в команде не найден
|
||||||
|
notFound: "&#fb0000Игрок не найден!"
|
||||||
|
# Сообщение которое будет выводиться если игрок слишком далеко от игрока указанного в команде
|
||||||
|
far: "&fИгрок ab6fb%target% &fслишком далеко!"
|
||||||
|
|
||||||
|
settings:
|
||||||
|
# Дистанция на которой должен находиться игрок который ввел команду от того кого ввел
|
||||||
|
distance: 10
|
||||||
|
|
||||||
|
title:
|
||||||
|
# Плейсхолдеры:
|
||||||
|
# %target% - ник игрока который ввели в команде
|
||||||
|
player:
|
||||||
|
# Титл который будет выводиться игроку который ввел команду
|
||||||
|
title: "&fТы трахнул"
|
||||||
|
# Сабтитл который будет выводиться игроку который ввел команду
|
||||||
|
subtitle: "&fигрока ab6fb%target%"
|
||||||
|
|
||||||
|
# Плейсхолдеры:
|
||||||
|
# %player% - ник игрока который ввел команду
|
||||||
|
target:
|
||||||
|
# Титл который будет выводиться игроку ник которого ввели в команде
|
||||||
|
title: "&fТебя трахнул"
|
||||||
|
# Сабтитл который будет выводиться игроку ник которого ввели в команде
|
||||||
|
subtitle: "&fигрок ab6fb%player%"
|
||||||
6
src/main/resources/plugin.yml
Normal file
6
src/main/resources/plugin.yml
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
name: SexPlugin
|
||||||
|
version: '${project.version}'
|
||||||
|
main: org.yawaflua.sexplugin.Sex
|
||||||
|
api-version: '1.20'
|
||||||
|
commands:
|
||||||
|
sex:
|
||||||
Reference in New Issue
Block a user