Skip to content

Commit

Permalink
Добавил плагин в гит хаб
Browse files Browse the repository at this point in the history
  • Loading branch information
Hxncusik committed Jul 1, 2023
0 parents commit c69c8ed
Show file tree
Hide file tree
Showing 20 changed files with 1,274 additions and 0 deletions.
113 changes: 113 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -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/
75 changes: 75 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<?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>kz.hxncus.mc</groupId>
<artifactId>Duels</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<name>Duels</name>

<description>Дуэли для сервера MineSon</description>
<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>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</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>com.destroystokyo.paper</groupId>
<artifactId>paper-api</artifactId>
<version>1.16.5-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
101 changes: 101 additions & 0 deletions src/main/java/kz/hxncus/mc/duels/Duels.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package kz.hxncus.mc.duels;

import kz.hxncus.mc.duels.commands.DuelCommand;
import kz.hxncus.mc.duels.commands.SpawnCommand;
import kz.hxncus.mc.duels.methods.ItemStacker;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.java.JavaPlugin;
import org.jetbrains.annotations.NotNull;

import java.io.File;
import java.io.IOException;
import java.util.*;

public final class Duels extends JavaPlugin {
private static Duels instance;
private static final Map<String, DuelsQueue> queues = new HashMap<>();
private final List<DuelsArenas> arenas = new ArrayList<>();
private static final Map<Player, PlayerChecks> playerChecks = new HashMap<>();
private static File kitsFile;
private static YamlConfiguration kits;
@Override
public void onEnable() {
instance = this;
new SpawnCommand();
new DuelCommand();
arenas.add(new DuelsArenas("cowboy", new Location(Bukkit.getWorld("arenas"), 132.5, 28, -85.5), new Location(Bukkit.getWorld("arenas"), 134.5, 28, -38.5), true));
arenas.add(new DuelsArenas("dragon", new Location(Bukkit.getWorld("arenas"), 257.5, 27, -122.5), new Location(Bukkit.getWorld("arenas"), 257.5, 27, -0.5), true));
kitsFile = new File(getDataFolder(), "kits.yml");
kits = YamlConfiguration.loadConfiguration(kitsFile);
getServer().getPluginManager().registerEvents(new EventListener(), instance);
for(Player player : Bukkit.getOnlinePlayers()){
Map<Player, PlayerChecks> playerChecks = Duels.getPlayerChecks();
if(playerChecks.isEmpty() || playerChecks.get(player) == null){
playerChecks.put(player, new PlayerChecks(null));
}
Inventory inventory = player.getInventory();
inventory.clear();
player.teleport(new Location(Bukkit.getWorld("world"), 1422.5, 159, 1729.5));
player.setHealth(20);
player.setFoodLevel(20);

inventory.setItem(0, ItemStacker.setDisplayName(new ItemStack(Material.IRON_SWORD), "§fДуэли"));
player.updateInventory();

AttributeInstance attack_speed = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
if(attack_speed != null) {
attack_speed.setBaseValue(attack_speed.getDefaultValue());
}
}
}

@Override
public void onDisable() {
try {
kits.save(kitsFile);
} catch (IOException e) {
e.printStackTrace();
}
}
public DuelsArenas getFreeArena() {
DuelsArenas[] duelsArenas = new DuelsArenas[arenas.size()];
int i = 0;
for (DuelsArenas arena : arenas) {
if (arena.isAvailable()) {
duelsArenas[i] = arena;
i++;
}
}
if(i > 0) {
return duelsArenas[new Random().nextInt(i)];
} else {
return null;
}
}
public static Map<String, DuelsQueue> getQueues() { return queues; }
public static Map<Player, PlayerChecks> getPlayerChecks(){
return playerChecks;
}
public static void setKit(String key, Object value) { kits.set(key, value); }
public static Object getKit(String key) {
return kits.get(key);
}
public static Set<String> getKitsKeys(boolean deep) { return kits.getKeys(deep); }
public static Map<String, Object> getValues(boolean deep) { return kits.getValues(deep); }
public void reloadConfig() {
kitsFile = new File(getDataFolder(), "kits.yml");
kits = YamlConfiguration.loadConfiguration(kitsFile);
}
public static Duels getInstance() {
return instance;
}
}
35 changes: 35 additions & 0 deletions src/main/java/kz/hxncus/mc/duels/DuelsArenas.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package kz.hxncus.mc.duels;

import org.bukkit.Location;

public class DuelsArenas {
private String name;
private Location spawnPoint1;
private Location spawnPoint2;
private boolean isAvailable;

public DuelsArenas(String name, Location spawnPoint1, Location spawnPoint2, boolean isAvailable) {
this.name = name;
this.spawnPoint1 = spawnPoint1;
this.spawnPoint2 = spawnPoint2;
this.isAvailable = isAvailable;
}

public String getName() { return name; }

public Location getSpawnPoint1() {
return spawnPoint1;
}

public Location getSpawnPoint2() {
return spawnPoint2;
}

public boolean isAvailable() {
return isAvailable;
}

public void setAvailable(boolean isAvailable) {
this.isAvailable = isAvailable;
}
}

0 comments on commit c69c8ed

Please sign in to comment.