Compare commits

...

4 Commits

78 changed files with 349 additions and 217 deletions

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="AntConfiguration">
<buildFile url="file://$PROJECT_DIR$/ant_build_increment.xml">
<executeOn event="afterCompilation" target="end" />
<executeOn event="beforeCompilation" target="init" />
</buildFile>
</component>
</project>

16
.idea/compiler.xml Normal file

@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="UhcCore" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="UhcCore" target="1.8" />
</bytecodeTargetLevel>
</component>
</project>

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding">
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
<file url="PROJECT" charset="UTF-8" />
</component>
</project>

25
.idea/jarRepositories.xml Normal file

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RemoteRepositoriesConfiguration">
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Central Repository" />
<option name="url" value="https://repo.maven.apache.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="spigot-repo" />
<option name="name" value="spigot-repo" />
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
</remote-repository>
<remote-repository>
<option name="id" value="central" />
<option name="name" value="Maven Central repository" />
<option name="url" value="https://repo1.maven.org/maven2" />
</remote-repository>
<remote-repository>
<option name="id" value="jboss.community" />
<option name="name" value="JBoss Community repository" />
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
</remote-repository>
</component>
</project>

@ -1,5 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>

@ -3,6 +3,7 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/UHC-Core.iml" filepath="$PROJECT_DIR$/UHC-Core.iml" />
<module fileurl="file://$PROJECT_DIR$/UhcCore.iml" filepath="$PROJECT_DIR$/UhcCore.iml" />
</modules>
</component>
</project>

@ -1,34 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/.idea/dictionaries" />
<excludeFolder url="file://$MODULE_DIR$/.idea/libraries" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/17.0.0/annotations-17.0.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library" scope="PROVIDED">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../../spigot-1.14.4.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../../spigot-1.14.4.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="library" name="spigot-1.16.1" level="project" />
</component>
</module>

20
UhcCore.iml Normal file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<excludeFolder url="file://$MODULE_DIR$/target" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.16.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.16-R0.3" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.26" level="project" />
</component>
</module>

@ -1,38 +0,0 @@
<project name="BuildIncrement" default="init" basedir=".">
<description>
simple example increment build variable
</description>
<!-- set global properties for this build -->
<property name="src" location="src"/>
<property name="version" value="0.0"/>
<loadproperties>
<file file="build.number"/>
</loadproperties>
<target name="init">
<echo file="ant_buildversion_init.txt">Changing build version from BUILD_VERSION to ${version}.${build.number} in file plugin.yml...</echo>
<replaceregexp file="${src}/plugin.yml"
match="BUILD_NUMBER"
replace="${version}.${build.number}"
byline="true"
/>
<echo file="ant_buildversion_init.txt">Changed!</echo>
</target>
<target name="end">
<echo file="ant_buildversion_end.txt">Changing back build version ${version}.${build.number} in file plugin.yml to BUILD_VERSION...</echo>
<replaceregexp file="${src}/plugin.yml"
match="${version}.${build.number}"
replace="BUILD_NUMBER"
byline="true"
/>
<buildnumber/>
<echo file="ant_buildversion_init.txt">Changed!</echo>
</target>
</project>

@ -1 +0,0 @@
Changing back build version 0.0.135 in file plugin.yml to BUILD_VERSION...

@ -1 +0,0 @@
Changed!

@ -1,5 +0,0 @@
#Build Number for ANT. Do not edit!
#Tue Feb 25 14:58:59 CET 2020
\#Build=Number for ANT. Do not edit\!
build.number=136
\#Tue=Jul 30 16\:09\:09 CEST 2019

57
pom.xml Normal file

@ -0,0 +1,57 @@
<?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>net.mindoverflow.network.uhccore</groupId>
<artifactId>UhcCore</artifactId>
<version>0.0.136</version>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestFile>src/main/resources/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<versionName>${project.version}</versionName>
</properties>
<repositories>
<!-- This adds the Spigot Maven repository to the build -->
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
</repositories>
<dependencies>
<!--This adds the Spigot API artifact to the build -->
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.16.1-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<!--This adds the Bukkit API artifact to the build -->
<!-- Do not include this in the pom.xml file if the Spigot API is already added -->
<!--
<dependency>
<groupId>org.bukkit</groupId>
<artifactId>bukkit</artifactId>
<version>1.15.2-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-->
</dependencies>
</project>

@ -1,6 +1,6 @@
package net.mindoverflow.network.uhccore.commands.uhccommands;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
@ -12,12 +12,12 @@ public class ListCommand
{
HashMap<Integer, ArrayList<String>>playersPerTeam = new HashMap<>();
for(int i = 0; i < CommonValues.totalTeams; i++)
for(int i = 0; i < Cache.totalTeams; i++)
{
ArrayList<String>playersInThisTeam = new ArrayList<>();
for(String playerName : CommonValues.playerTeam.keySet())
for(String playerName : Cache.playerTeam.keySet())
{
if(CommonValues.playerTeam.get(playerName).equals(i))
if(Cache.playerTeam.get(playerName).equals(i))
{
playersInThisTeam.add(playerName);
}
@ -28,7 +28,7 @@ public class ListCommand
commandSender.sendMessage("§6-------[ UHC: Lista Team ]-------");
for(Integer i : playersPerTeam.keySet())
{
String teamName = CommonValues.teamNames.get(i);
String teamName = Cache.teamNames.get(i);
int playersInThisTeam = playersPerTeam.get(i).size();
ArrayList<String>playersNames = playersPerTeam.get(i);
String playersList = playersNames.toString().replace("[", "").replace("]", "").replace(",", "§7,§r");

@ -1,6 +1,6 @@
package net.mindoverflow.network.uhccore.commands.uhccommands;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.configuration.ConfigEntries;
import net.mindoverflow.network.uhccore.utils.Debugger;
import net.mindoverflow.network.uhccore.utils.configuration.FileUtils;
@ -23,17 +23,17 @@ public class SetFireworkCommand
YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml;
int listPos = CommonValues.fireworksLocations.size() + 1;
int listPos = Cache.fireworksLocations.size() + 1;
if(CommonValues.fireworksLocations.get(0).getWorld() == null)
if(Cache.fireworksLocations.get(0).getWorld() == null)
{
debugger.sendDebugMessage(Level.SEVERE, "WORLD IS NULL!");
listPos = 1;
CommonValues.fireworksLocations.set(0, fireworkLoc);
Cache.fireworksLocations.set(0, fireworkLoc);
}
else
{
CommonValues.fireworksLocations.add(fireworkLoc);
Cache.fireworksLocations.add(fireworkLoc);
}
String currentPath = ConfigEntries.FIREWORK_POS.path + "." + listPos;

@ -1,6 +1,6 @@
package net.mindoverflow.network.uhccore.commands.uhccommands;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.configuration.ConfigEntries;
import net.mindoverflow.network.uhccore.utils.configuration.FileUtils;
import org.bukkit.Location;
@ -16,7 +16,7 @@ public class SetSpawnCommand
Player player = (Player) sender;
Location playerLoc = player.getLocation();
CommonValues.spawn = playerLoc;
Cache.spawn = playerLoc;
YamlConfiguration config = FileUtils.FileType.CONFIG_YAML.yaml;
config.set(ConfigEntries.SPAWN_WORLD.path, playerLoc.getWorld().getName());
config.set(ConfigEntries.SPAWN_X.path, playerLoc.getX());

@ -1,7 +1,7 @@
package net.mindoverflow.network.uhccore.commands.uhccommands;
import net.mindoverflow.network.uhccore.UhcCore;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.Debugger;
import net.mindoverflow.network.uhccore.utils.math.NumberUtils;
import org.bukkit.*;
@ -23,17 +23,17 @@ public class StartUhcCommand {
HashMap<Integer, Location> spawnPerTeam = new HashMap<>();
World spawnWorld = plugin.getServer().getWorld(CommonValues.uhcWorlds.get(0));
World spawnWorld = plugin.getServer().getWorld(Cache.uhcWorlds.get(0));
int borderX = CommonValues.borderX;
int borderZ = CommonValues.borderZ;
int borderSize = CommonValues.borderSize;
int borderX = Cache.borderX;
int borderZ = Cache.borderZ;
int borderSize = Cache.borderSize;
int range = borderSize / 2;
Location borderCenter = new Location(spawnWorld, borderX, 64, borderZ);
for(String playerName : CommonValues.playerTeam.keySet())
for(String playerName : Cache.playerTeam.keySet())
{
Player player = plugin.getServer().getPlayer(playerName);
player.sendTitle("La §dUHC§r inizierà a breve!", "ricerca degli spawnpoint...", 20, 70, 10);
@ -42,7 +42,7 @@ public class StartUhcCommand {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, ()->
{
for(int i = 0; i < CommonValues.totalTeams; i++)
for(int i = 0; i < Cache.totalTeams; i++)
{
double x = NumberUtils.getRandomNumberInRange(borderX - range + 1, borderX + range - 1) + 0.5;
@ -67,18 +67,18 @@ public class StartUhcCommand {
}
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, ()->
{
CommonValues.allowMovement = false;
Cache.allowMovement = false;
}, 20L);
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, ()->
{
CommonValues.allowMovement = true;
Cache.allowMovement = true;
}, loadDelay * 20L);
for(String playerName : CommonValues.playerTeam.keySet())
for(String playerName : Cache.playerTeam.keySet())
{
int teamNumber = CommonValues.playerTeam.get(playerName);
int teamNumber = Cache.playerTeam.get(playerName);
Player player = plugin.getServer().getPlayer(playerName);
Location hisTeamLoc = spawnPerTeam.get(teamNumber);

@ -1,7 +1,7 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.UhcCore;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
@ -28,11 +28,11 @@ public class PlayerChatListener implements Listener {
String message;
// Check if the player is in a team.
if(CommonValues.playerTeam.containsKey(playerName))
if(Cache.playerTeam.containsKey(playerName))
{
// Load the team number and the team name from that.
int teamNumber = CommonValues.playerTeam.get(playerName);
String teamName = CommonValues.teamNames.get(teamNumber);
int teamNumber = Cache.playerTeam.get(playerName);
String teamName = Cache.teamNames.get(teamNumber);
// Build the chat message.
message = "§7[" + teamName + "§7] §f" + displayName + "§7: " + event.getMessage();

@ -1,7 +1,7 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.UhcCore;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.Debugger;
import net.mindoverflow.network.uhccore.utils.UhcUtils;
import org.bukkit.*;
@ -44,10 +44,10 @@ public class PlayerDeathRespawnListener implements Listener
Player player = event.getEntity();
// Remove the Teams selector item from the drops.
event.getDrops().remove(CommonValues.teamsItem);
event.getDrops().remove(Cache.teamsItem);
// Check if the player died in the lobby...
if(CommonValues.lobbyWorlds.contains(player.getWorld().getName()))
if(Cache.lobbyWorlds.contains(player.getWorld().getName()))
{
// And clear all drops.
event.getDrops().clear();
@ -58,7 +58,7 @@ public class PlayerDeathRespawnListener implements Listener
// check if the death world is a UHC world (we don't want this to happen in the lobby!)
// and
// check if the player is in any team (players who are not in a team are not playing!)
if((CommonValues.uhcWorlds.contains(player.getWorld().getName())) && CommonValues.playerTeam.containsKey(player.getName()))
if((Cache.uhcWorlds.contains(player.getWorld().getName())) && Cache.playerTeam.containsKey(player.getName()))
{
// Spawn a Firework where the player died.
@ -71,11 +71,11 @@ public class PlayerDeathRespawnListener implements Listener
deadPlayers.put(playerName, player.getLocation());
// Load the dead player's team number.
int thisPlayerTeamNumber = CommonValues.playerTeam.get(playerName);
int thisPlayerTeamNumber = Cache.playerTeam.get(playerName);
// Load the death player's team name.
String thisPlayerTeamName = CommonValues.teamNames.get(thisPlayerTeamNumber);
String thisPlayerTeamName = Cache.teamNames.get(thisPlayerTeamNumber);
// Remove the player from his team.
CommonValues.playerTeam.remove(playerName);
Cache.playerTeam.remove(playerName);
// Run this task Async, because it may be CPU heavy.
@ -86,44 +86,44 @@ public class PlayerDeathRespawnListener implements Listener
UhcUtils.updatePlayersPerTeam();
// Check how many players are left in the dead player's team.
int thisPlayerTeamPlayers = CommonValues.playersPerTeam.get(thisPlayerTeamNumber);
int thisPlayerTeamPlayers = Cache.playersPerTeam.get(thisPlayerTeamNumber);
// Run this task Sync, because we need to access the API, and also delay it by 1 second.
plugin.getServer().getScheduler().runTaskLater(plugin, () ->
{
int playingPlayers = CommonValues.playerTeam.size();
int playingPlayers = Cache.playerTeam.size();
for(Player p : plugin.getServer().getOnlinePlayers())
{
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, 1, 1);
}
plugin.getServer().broadcastMessage(playerName + "§7 del team §e" + thisPlayerTeamName + "§7 è fuori gioco!");
plugin.getServer().broadcastMessage("§7Nel team " + thisPlayerTeamName + "§7 rimangono §e" + thisPlayerTeamPlayers + "§7 giocatori.");
plugin.getServer().broadcastMessage("§7In totale rimangono §e" + playingPlayers + "§7 giocatori, in §e" + CommonValues.playingTeams + "§7 team.");
plugin.getServer().broadcastMessage("§7In totale rimangono §e" + playingPlayers + "§7 giocatori, in §e" + Cache.playingTeams + "§7 team.");
if(CommonValues.playingTeams <= 1)
if(Cache.playingTeams <= 1)
{
CommonValues.allowMovement = false;
Cache.allowMovement = false;
scheduleTask();
plugin.getServer().broadcastMessage("§6La UHC è finita!");
int winningTeam = 0;
for(int i = 0; i < CommonValues.totalTeams; i++)
for(int i = 0; i < Cache.totalTeams; i++)
{
if(CommonValues.playersPerTeam.get(i) > 0)
if(Cache.playersPerTeam.get(i) > 0)
{
winningTeam = i;
}
}
String teamName = CommonValues.teamNames.get(winningTeam) + "§r";
String teamName = Cache.teamNames.get(winningTeam) + "§r";
plugin.getServer().broadcastMessage("§6Ha vinto il team: " + teamName);
for(Player currentPlayer : plugin.getServer().getOnlinePlayers())
{
currentPlayer.teleport(CommonValues.spawn);
currentPlayer.teleport(Cache.spawn);
// Clear his inventory and give him the Teams selector item.
UhcUtils.giveTeamsSelectorItem(currentPlayer);
plugin.getLogger().log(Level.INFO,"UHC Finished!");
@ -159,7 +159,7 @@ public class PlayerDeathRespawnListener implements Listener
// Check if there is more than 1 team alive.
// If there is only 1 team alive, then the UHC is over.
if(CommonValues.playingTeams > 1)
if(Cache.playingTeams > 1)
{
// warn the player that he's not a spectator.
player.sendMessage("§cSei morto nella UHC e ora sei uno spettatore!");
@ -221,7 +221,7 @@ public class PlayerDeathRespawnListener implements Listener
taskID = 0;
}
for(Location loc : CommonValues.fireworksLocations)
for(Location loc : Cache.fireworksLocations)
{
debugger.sendDebugMessage(Level.INFO, "FIREWORK LOC: " + loc);
UhcUtils.spawnFirework(loc, 10L);
@ -236,7 +236,7 @@ public class PlayerDeathRespawnListener implements Listener
plugin.getServer().getScheduler().runTaskLater(plugin, ()->
{
isTaskScheduled = false;
CommonValues.allowMovement = true;
Cache.allowMovement = true;
for (Player currentPlayer : plugin.getServer().getOnlinePlayers())
{

@ -1,6 +1,6 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
@ -14,7 +14,7 @@ public class PlayerHitListener implements Listener
public void onPlayerHitPlayer(EntityDamageByEntityEvent event)
{
// if friendly fire is enabled, then skip everything that follows and let the hit happen.
if(CommonValues.friendlyFire) return;
if(Cache.friendlyFire) return;
// check if the damaged and damager entities are both players. If they're not, stop.
if(!(event.getDamager() instanceof Player && event.getEntity() instanceof Player))
@ -27,13 +27,13 @@ public class PlayerHitListener implements Listener
String damagerName = event.getDamager().getName();
// Check if they're in a team. if they're not, stop.
if(!(CommonValues.playerTeam.containsKey(damagedName) && CommonValues.playerTeam.containsKey(damagerName)))
if(!(Cache.playerTeam.containsKey(damagedName) && Cache.playerTeam.containsKey(damagerName)))
{
return;
}
// check if they're both in the same team.
if(CommonValues.playerTeam.get(damagedName).equals(CommonValues.playerTeam.get(damagerName)))
if(Cache.playerTeam.get(damagedName).equals(Cache.playerTeam.get(damagerName)))
{
// cancel the event.
event.setCancelled(true);

@ -1,7 +1,7 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.UhcUtils;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -28,10 +28,10 @@ public class PlayerInteractListener implements Listener
Player player = event.getPlayer();
// check if the player's item in hand was the Teams selector item.
if(player.getInventory().getItemInMainHand().equals(CommonValues.teamsItem))
if(player.getInventory().getItemInMainHand().equals(Cache.teamsItem))
{
// Open the teams selector GUI.
player.openInventory(CommonValues.teamsSelectorGUI.getInventory());
player.openInventory(Cache.teamsSelectorGUI.getInventory());
}
}
}
@ -49,7 +49,7 @@ public class PlayerInteractListener implements Listener
ItemStack item = event.getCurrentItem();
// Check if the clicked inventory is the Teams selector GUI.
if(event.getClickedInventory().equals(CommonValues.teamsSelectorGUI.getInventory()))
if(event.getClickedInventory().equals(Cache.teamsSelectorGUI.getInventory()))
{
// Cancel the event (we don't want items to be moved!)
event.setCancelled(true);
@ -64,15 +64,15 @@ public class PlayerInteractListener implements Listener
player.closeInventory();
// Check if the clicked item is an existing Team.
if(CommonValues.teamNames.contains(im.getDisplayName()))
if(Cache.teamNames.contains(im.getDisplayName()))
{
// Load the team number from the team name in the teams list.
int teamNumber = CommonValues.teamNames.indexOf(im.getDisplayName());
int teamNumber = Cache.teamNames.indexOf(im.getDisplayName());
// Add the player to that team.
CommonValues.playerTeam.remove(player.getName());
CommonValues.playerTeam.put(player.getName(), teamNumber);
Cache.playerTeam.remove(player.getName());
Cache.playerTeam.put(player.getName(), teamNumber);
// Update the total number of players in each team, and the total number of alive teams.
UhcUtils.updatePlayersPerTeam();
@ -81,14 +81,14 @@ public class PlayerInteractListener implements Listener
player.sendMessage("§7Aggiunto al team " + im.getDisplayName());
}
// Else, check if the clicked item is the one used to quit teams.
else if(item.equals(CommonValues.quitTeamItem))
else if(item.equals(Cache.quitTeamItem))
{
// Check if the player is in any team.
if(CommonValues.playerTeam.containsKey(player.getName()))
if(Cache.playerTeam.containsKey(player.getName()))
{
// Remove the player from the team.
player.sendMessage("§eRimosso dal Team!");
CommonValues.playerTeam.remove(player.getName());
Cache.playerTeam.remove(player.getName());
// Update the total number of players in each team, and the total number of alive teams.
UhcUtils.updatePlayersPerTeam();
@ -98,10 +98,10 @@ public class PlayerInteractListener implements Listener
}
}
} // Check if the non-clicked inventory (there always are two inventories) is the Teams selector GUI, and cancel the event (we don't want items to be put inside of it!)
else if(event.getInventory().equals(CommonValues.teamsSelectorGUI.getInventory())) event.setCancelled(true);
else if(event.getInventory().equals(Cache.teamsSelectorGUI.getInventory())) event.setCancelled(true);
// Prevent everyone from moving the Teams selector item in their inventory.
if(item.equals(CommonValues.teamsItem)) event.setCancelled(true);
if(item.equals(Cache.teamsItem)) event.setCancelled(true);
}
@ -111,7 +111,7 @@ public class PlayerInteractListener implements Listener
public void onItemDrop(PlayerDropItemEvent event)
{
// Check if the dropped item is the Teams selector item.
if(event.getItemDrop().getItemStack().equals(CommonValues.teamsItem))
if(event.getItemDrop().getItemStack().equals(Cache.teamsItem))
{
// Prevent it from being dropped.
event.setCancelled(true);

@ -1,17 +1,12 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.Debugger;
import net.mindoverflow.network.uhccore.utils.UhcUtils;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.logging.Level;
public class PlayerJoinListener implements Listener
{
@ -28,7 +23,7 @@ public class PlayerJoinListener implements Listener
Player player = e.getPlayer();
if(!(CommonValues.playerTeam.containsKey(player.getName())))
if(!(Cache.playerTeam.containsKey(player.getName())))
{
UhcUtils.tpSpawnAndGiveItem(player);
}

@ -1,16 +1,10 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.UhcCore;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Debugger;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import net.mindoverflow.network.uhccore.utils.Cache;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.scheduler.BukkitTask;
import java.util.logging.Level;
public class PlayerMoveListener implements Listener
{
@ -26,7 +20,7 @@ public class PlayerMoveListener implements Listener
@EventHandler
public void onPlayerMove(PlayerMoveEvent event)
{
if(CommonValues.allowMovement) return;
if(Cache.allowMovement) return;
event.setCancelled(true);
}
}

@ -1,6 +1,6 @@
package net.mindoverflow.network.uhccore.listeners;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
@ -8,8 +8,6 @@ import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.LinkedHashMap;
public class TeamsSelectorGUI implements InventoryHolder
{
@ -28,15 +26,15 @@ public class TeamsSelectorGUI implements InventoryHolder
public void initializeInv()
{
for(int i = 0; i < CommonValues.totalTeams; i++)
for(int i = 0; i < Cache.totalTeams; i++)
{
String teamName = CommonValues.teamNames.get(i);
Material itemMat = CommonValues.teamItemsMaterials.get(i);
String teamName = Cache.teamNames.get(i);
Material itemMat = Cache.teamItemsMaterials.get(i);
inv.setItem(i, createItem(teamName, itemMat));
}
inv.setItem(17, CommonValues.quitTeamItem);
inv.setItem(17, Cache.quitTeamItem);
}

@ -1,22 +1,15 @@
package net.mindoverflow.network.uhccore.utils;
import net.mindoverflow.network.uhccore.UhcCore;
import net.mindoverflow.network.uhccore.listeners.TeamsSelectorGUI;
import org.bukkit.Color;
import org.bukkit.FireworkEffect;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Firework;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
public class CommonValues {
public class Cache {
// Values to save the uhc and lobby world names.
public static List<String> uhcWorlds = new ArrayList<>(), lobbyWorlds = new ArrayList<>();

@ -19,16 +19,16 @@ public class UhcUtils {
int playingTeams = 0;
// Iterate through every existing team.
for(int i = 0; i < CommonValues.totalTeams; i++)
for(int i = 0; i < Cache.totalTeams; i++)
{
// Int to store the players number for each team.
int playersNumber = 0;
// Iterate through every player and...
for(String s : CommonValues.playerTeam.keySet())
for(String s : Cache.playerTeam.keySet())
{
//if his team is the current checked one...
if(CommonValues.playerTeam.get(s) == i)
if(Cache.playerTeam.get(s) == i)
{
//increase the playersNumber by 1.
playersNumber++;
@ -36,21 +36,21 @@ public class UhcUtils {
}
// Finally, put the team number and his player count in the playersPerTeam HashMap.
CommonValues.playersPerTeam.put(i, playersNumber);
Cache.playersPerTeam.put(i, playersNumber);
// If there is at least 1 player in this team, then count this as an "alive team".
if(playersNumber != 0) playingTeams++;
}
// Return the number of alive teams.
CommonValues.playingTeams = playingTeams;
Cache.playingTeams = playingTeams;
}
public static void giveTeamsSelectorItem(Player player)
{
player.getInventory().clear();
player.getInventory().setItem(4, CommonValues.teamsItem);
player.getInventory().setItem(4, Cache.teamsItem);
}
public static void spawnFirework(Location location, long detonateDelay) {
@ -70,7 +70,7 @@ public class UhcUtils {
public static void tpSpawnAndGiveItem(Player player)
{
player.teleport(CommonValues.spawn);
player.teleport(Cache.spawn);
// Clear the player's inventory and give hims the Teams selector item.
UhcUtils.giveTeamsSelectorItem(player);

@ -2,7 +2,7 @@ package net.mindoverflow.network.uhccore.utils.configuration;
import net.mindoverflow.network.uhccore.UhcCore;
import net.mindoverflow.network.uhccore.listeners.TeamsSelectorGUI;
import net.mindoverflow.network.uhccore.utils.CommonValues;
import net.mindoverflow.network.uhccore.utils.Cache;
import net.mindoverflow.network.uhccore.utils.Debugger;
import org.bukkit.Location;
import org.bukkit.Material;
@ -59,46 +59,46 @@ public class FileUtils
FileType.CONFIG_YAML.yaml = YamlConfiguration.loadConfiguration(FileType.CONFIG_YAML.file);
FileType.LANG_YAML.yaml = YamlConfiguration.loadConfiguration(FileType.LANG_YAML.file);
CommonValues.playerTeam.clear();
CommonValues.playersPerTeam.clear();
CommonValues.teamNames.clear();
CommonValues.teamItemsMaterials.clear();
CommonValues.spawn = null;
CommonValues.fireworksLocations.clear();
Cache.playerTeam.clear();
Cache.playersPerTeam.clear();
Cache.teamNames.clear();
Cache.teamItemsMaterials.clear();
Cache.spawn = null;
Cache.fireworksLocations.clear();
CommonValues.playingTeams = 0;
Cache.playingTeams = 0;
YamlConfiguration config = FileType.CONFIG_YAML.yaml;
CommonValues.teamNames = config.getStringList(ConfigEntries.TEAMS_NAMES.path);
Cache.teamNames = config.getStringList(ConfigEntries.TEAMS_NAMES.path);
for(String matName : config.getStringList(ConfigEntries.TEAMS_ITEMS.path))
{
CommonValues.teamItemsMaterials.add(Material.valueOf(matName));
Cache.teamItemsMaterials.add(Material.valueOf(matName));
}
CommonValues.uhcWorlds = config.getStringList(ConfigEntries.UHC_WORLDS.path);
CommonValues.lobbyWorlds = config.getStringList(ConfigEntries.LOBBY_WORLDS.path);
Cache.uhcWorlds = config.getStringList(ConfigEntries.UHC_WORLDS.path);
Cache.lobbyWorlds = config.getStringList(ConfigEntries.LOBBY_WORLDS.path);
CommonValues.friendlyFire = config.getBoolean(ConfigEntries.FRIENDLY_FIRE.path);
Cache.friendlyFire = config.getBoolean(ConfigEntries.FRIENDLY_FIRE.path);
CommonValues.teamsItem = new ItemStack(Material.NETHER_STAR);
ItemMeta im = CommonValues.teamsItem.getItemMeta();
Cache.teamsItem = new ItemStack(Material.NETHER_STAR);
ItemMeta im = Cache.teamsItem.getItemMeta();
im.setDisplayName("§eTeam");
CommonValues.teamsItem.setItemMeta(im);
Cache.teamsItem.setItemMeta(im);
CommonValues.quitTeamItem = new ItemStack(Material.BARRIER);
im = CommonValues.quitTeamItem.getItemMeta();
Cache.quitTeamItem = new ItemStack(Material.BARRIER);
im = Cache.quitTeamItem.getItemMeta();
im.setDisplayName("§cEsci dal Team");
CommonValues.quitTeamItem.setItemMeta(im);
Cache.quitTeamItem.setItemMeta(im);
CommonValues.totalTeams = config.getInt(ConfigEntries.TEAMS_NUMBER.path);
Cache.totalTeams = config.getInt(ConfigEntries.TEAMS_NUMBER.path);
CommonValues.teamsSelectorGUI = new TeamsSelectorGUI();
CommonValues.teamsSelectorGUI.initializeInv();
Cache.teamsSelectorGUI = new TeamsSelectorGUI();
Cache.teamsSelectorGUI.initializeInv();
CommonValues.borderX = config.getInt(ConfigEntries.BORDER_CENTER_X.path);
CommonValues.borderZ = config.getInt(ConfigEntries.BORDER_CENTER_Z.path);
CommonValues.borderSize = config.getInt(ConfigEntries.BORDER_SIZE.path);
Cache.borderX = config.getInt(ConfigEntries.BORDER_CENTER_X.path);
Cache.borderZ = config.getInt(ConfigEntries.BORDER_CENTER_Z.path);
Cache.borderSize = config.getInt(ConfigEntries.BORDER_SIZE.path);
String spawnWorldName = config.getString(ConfigEntries.SPAWN_WORLD.path);
if(spawnWorldName != null)
@ -112,7 +112,7 @@ public class FileUtils
double z = config.getDouble(ConfigEntries.SPAWN_Z.path);
double yaw = config.getDouble(ConfigEntries.SPAWN_YAW.path);
double pitch = config.getDouble(ConfigEntries.SPAWN_PITCH.path);
CommonValues.spawn = new Location(spawnWorld, x, y, z, (float) yaw, (float) pitch);
Cache.spawn = new Location(spawnWorld, x, y, z, (float) yaw, (float) pitch);
}
}
@ -124,7 +124,7 @@ public class FileUtils
double y = config.getDouble(currentPath + ".y");
double z = config.getDouble(currentPath + ".z");
CommonValues.fireworksLocations.add(new Location(plugin.getServer().getWorld(world), x, y, z));
Cache.fireworksLocations.add(new Location(plugin.getServer().getWorld(world), x, y, z));
}
}

@ -1,5 +1,5 @@
name: UHC-Core
version: BUILD_NUMBER
version: 0.0.136
author: mind_overflow
api-version: '1.15'
main: net.mindoverflow.network.uhccore.UhcCore

BIN
target/UhcCore-0.0.136.jar Normal file

Binary file not shown.

40
target/classes/config.yml Normal file

@ -0,0 +1,40 @@
settings:
uhcworlds: ['world', 'world_nether']
lobbyworlds: ['flat']
teams: 4
friendly-fire: false
border:
center-x: 0
center-z: 0
size: 4000
spawn:
world: __UNSET__
x: 0.0
y: 0.0
z: 0.0
yaw: 0.0
pitch: 0.0
firework-pos:
1:
world: __UNSET__
x: 0.0
y: 0.0
z: 0.0
teams:
- '§9Blue'
- '§cRed'
- '§aGreen'
- '§eYellow'
- '§5Purple'
- '§6Orange'
- '§8Black'
- '§dPink'
team-items:
- 'BLUE_WOOL'
- 'RED_WOOL'
- 'LIME_WOOL'
- 'YELLOW_WOOL'
- 'PURPLE_WOOL'
- 'ORANGE_WOOL'
- 'BLACK_WOOL'
- 'PINK_WOOL'

5
target/classes/lang.yml Normal file

@ -0,0 +1,5 @@
error:
console_access: '&eWarning! You are accessing the plugin command from console.'
console_access_blocked: '&cSorry, but this command is not available via console.'
info: '&bThis is a colored and localized message!'
player_position: '&bYour position is: &e%pos%'

@ -0,0 +1,9 @@
name: UHC-Core
version: 0.0.136
author: mind_overflow
api-version: '1.15'
main: net.mindoverflow.network.uhccore.UhcCore
commands:
uhc:
description: UHC-Core base command.
usage: /uhc

@ -0,0 +1,5 @@
#Generated by Maven
#Tue May 31 20:19:46 CEST 2022
groupId=net.mindoverflow.network.uhccore
artifactId=UhcCore
version=0.0.136

@ -0,0 +1,27 @@
net\mindoverflow\network\uhccore\utils\Debugger.class
net\mindoverflow\network\uhccore\utils\configuration\ConfigEntries.class
net\mindoverflow\network\uhccore\utils\UhcUtils.class
net\mindoverflow\network\uhccore\commands\uhccommands\ListCommand.class
net\mindoverflow\network\uhccore\listeners\PlayerMoveListener.class
net\mindoverflow\network\uhccore\listeners\PlayerInteractListener.class
net\mindoverflow\network\uhccore\utils\Cache.class
net\mindoverflow\network\uhccore\listeners\PlayerChatListener.class
net\mindoverflow\network\uhccore\commands\UhcCoreCommand.class
net\mindoverflow\network\uhccore\utils\configuration\LocalizedMessages.class
net\mindoverflow\network\uhccore\listeners\PlayerDeathRespawnListener.class
net\mindoverflow\network\uhccore\listeners\PlayerHitListener.class
net\mindoverflow\network\uhccore\commands\uhccommands\SetSpawnCommand.class
net\mindoverflow\network\uhccore\commands\uhccommands\StartUhcCommand.class
net\mindoverflow\network\uhccore\commands\uhccommands\SetFireworkCommand.class
net\mindoverflow\network\uhccore\utils\configuration\FileUtils.class
net\mindoverflow\network\uhccore\utils\Permissions.class
net\mindoverflow\network\uhccore\commands\uhccommands\HelpCommand.class
net\mindoverflow\network\uhccore\utils\PermissionUtils.class
net\mindoverflow\network\uhccore\commands\uhccommands\ReloadCommand.class
net\mindoverflow\network\uhccore\listeners\PlayerJoinListener.class
net\mindoverflow\network\uhccore\utils\math\NumberUtils.class
net\mindoverflow\network\uhccore\listeners\TeamsSelectorGUI.class
net\mindoverflow\network\uhccore\utils\MessageUtils.class
net\mindoverflow\network\uhccore\UhcCore.class
net\mindoverflow\network\uhccore\utils\configuration\FileUtils$FileType.class
net\mindoverflow\network\uhccore\completers\InfoCompleter.class

@ -0,0 +1,26 @@
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\Permissions.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\uhccommands\SetFireworkCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\PlayerInteractListener.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\MessageUtils.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\uhccommands\StartUhcCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\math\NumberUtils.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\PlayerDeathRespawnListener.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\PlayerHitListener.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\PermissionUtils.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\PlayerMoveListener.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\configuration\ConfigEntries.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\Debugger.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\TeamsSelectorGUI.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\PlayerChatListener.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\uhccommands\ListCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\UhcCore.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\uhccommands\SetSpawnCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\configuration\LocalizedMessages.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\uhccommands\ReloadCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\configuration\FileUtils.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\uhccommands\HelpCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\completers\InfoCompleter.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\UhcUtils.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\commands\UhcCoreCommand.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\listeners\PlayerJoinListener.java
C:\Users\lol9\Desktop\Coding\Java\Spigot\UHC-Core\src\main\java\net\mindoverflow\network\uhccore\utils\Cache.java