Skip to content

Commit

Permalink
🎉 Added license above every class. Renamed packages to follow Java pa…
Browse files Browse the repository at this point in the history
…ckages naming conventions. Added javadoc comments. Changed how cooldowns work completely. Added TimeUnit and TimeUtils classes. Updated version string from 1.4.4 to 1.5.0. Added a cooldown file for managing cooldowns. Cooldown#isInCooldown is now deprecated and "Cooldown#getTimeLeft > 0" should be used in its place.
  • Loading branch information
alfonsoLeandro committed Jan 18, 2021
1 parent 4f8902b commit 8d62e15
Show file tree
Hide file tree
Showing 26 changed files with 831 additions and 186 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@ MP Utils is a simple library for helping on the developing of minecraft spigot p
## Installation
Developers:
Add the following maven dependecy to your pom.xml file:

```xml
<dependencies>
<dependency>
<groupId>com.github.alfonsoLeandro</groupId>
<groupId>com.github.alfonsoleandrocom.github.alfonsoleandro</groupId>
<artifactId>MPUtils</artifactId>
<version>VERSION</version>
<scope>provided</scope>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.alfonsoLeandro</groupId>
<artifactId>MPUtils</artifactId>
<version>1.4.4</version>
<version>1.5.0</version>
<packaging>jar</packaging>

<name>MPUtils</name>
Expand Down Expand Up @@ -40,7 +40,7 @@
<developer>
<name>Leandro Alfonso</name>
<email>leandroalfonsoporley@gmail.com</email>
<organization>com.github.alfonsoLeandro</organization>
<organization>com.github.alfonsoleandro</organization>
<organizationUrl>https://github.com/alfonsoLeandro/MPUtils</organizationUrl>
</developer>
</developers>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

85 changes: 0 additions & 85 deletions src/main/java/com/github/alfonsoLeandro/mpUtils/time/Cooldown.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,10 +1,32 @@
package com.github.alfonsoLeandro.mpUtils;
/*
Copyright (c) 2020 Leandro Alfonso
import com.github.alfonsoLeandro.mpUtils.events.JoinEvent;
import com.github.alfonsoLeandro.mpUtils.files.YamlFile;
import com.github.alfonsoLeandro.mpUtils.guis.Events;
import com.github.alfonsoLeandro.mpUtils.metrics.Metrics;
import com.github.alfonsoLeandro.mpUtils.string.StringUtils;
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package com.github.alfonsoleandro.mputils;

import com.github.alfonsoleandro.mputils.events.JoinEvent;
import com.github.alfonsoleandro.mputils.files.YamlFile;
import com.github.alfonsoleandro.mputils.guis.Events;
import com.github.alfonsoleandro.mputils.metrics.Metrics;
import com.github.alfonsoleandro.mputils.string.StringUtils;
import com.github.alfonsoleandro.mputils.time.Cooldown;
import org.bukkit.Bukkit;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.PluginDescriptionFile;
Expand All @@ -16,7 +38,10 @@
import java.net.HttpURLConnection;
import java.net.URL;

public final class Main extends JavaPlugin {
/**
* MPUtils' main class.
*/
public final class MPUtils extends JavaPlugin {

/**
* This plugin's plugin.yml file.
Expand All @@ -34,6 +59,10 @@ public final class Main extends JavaPlugin {
* YamlFile object used for storing the {@link FileConfiguration} object for the config file and the file itself.
*/
private YamlFile configYaml;
/**
* YamlFile object used for storing the {@link FileConfiguration} object for the cooldown file and the file itself.
*/
private YamlFile cooldownYaml;

/**
* Sends a message to the console with colors and prefix.
Expand All @@ -43,19 +72,25 @@ private void send(String msg){
Bukkit.getConsoleSender().sendMessage(StringUtils.colorizeString('&', "&f[&aMPUtils&f] "+msg));
}


/**
* Plugin enable logic.
*/
@Override
public void onEnable() {
send("&aEnabled&f. Version: &e" + version);
send("&fThank you for using my plugin! &a" + pdfFile.getName() + "&f By " + pdfFile.getAuthors().get(0));
send("&fJoin my discord server at &chttps://discordapp.com/invite/ZznhQud");
send("Please consider subscribing to my yt channel: &c" + pdfFile.getWebsite());
registerConfig();
registerCooldown();
registerEvents();
updateChecker();
startMetrics();
}

/**
* Plugin disable logic.
*/
@Override
public void onDisable() {
send("&cDisabled&f. Version: &e" + version);
Expand All @@ -71,6 +106,13 @@ private void registerConfig(){
configYaml = new YamlFile(this, "config.yml");
}

/**
* Registers the cooldown file for this plugin.
*/
private void registerCooldown(){
cooldownYaml = new YamlFile(this, "cooldown.yml");
}

/**
* Tries to start the metrics system.
*/
Expand Down Expand Up @@ -130,4 +172,12 @@ public String getVersion() {
public String getLatestVersion(){
return latestVersion;
}

/**
* Gets the cooldown YAMLFile object.
* @return The YAMLFile object containing the cooldown's File and FileConfiguration objects.
*/
public YamlFile getCooldownYaml(){
return cooldownYaml;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
Copyright (c) 2020 Leandro Alfonso
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
package com.github.alfonsoleandro.mputils.events;

import com.github.alfonsoleandro.mputils.MPUtils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;

/**
* {@link PlayerJoinEvent} listener used for notifying server operators whenever there
* is a new MPUtils version available.
*/
public class JoinEvent implements Listener {

final private MPUtils plugin;

public JoinEvent(MPUtils plugin){
this.plugin = plugin;
}

@EventHandler
public void onJoin(PlayerJoinEvent event){
final Player player = event.getPlayer();
final String exclamation = "&e&l(&4&l!&e&l)";
final String prefix = "&f[&aMPUtils&f]";

if(player.isOp() && !plugin.getVersion().equals(plugin.getLatestVersion())) {
player.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix+" "+exclamation+" &4New version available &7(&e"+plugin.getLatestVersion()+"&7)"));
player.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix+" "+exclamation+" &fhttp://bit.ly/2If90hb") );
}
}

}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.github.alfonsoLeandro.mpUtils.files;
package com.github.alfonsoleandro.mputils.files;

import com.google.common.base.Strings;
import org.bukkit.configuration.InvalidConfigurationException;
Expand Down
Loading

0 comments on commit 8d62e15

Please sign in to comment.