-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fazendo upload do código para o GitHub!
- Loading branch information
GabrielAugustoTI
committed
Nov 5, 2016
1 parent
90cf7d7
commit 2b4c4c2
Showing
11 changed files
with
661 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Auto detect text files and perform LF normalization | ||
* text=auto | ||
|
||
# Custom for Visual Studio | ||
*.cs diff=csharp | ||
|
||
# Standard to msysgit | ||
*.doc diff=astextplain | ||
*.DOC diff=astextplain | ||
*.docx diff=astextplain | ||
*.DOCX diff=astextplain | ||
*.dot diff=astextplain | ||
*.DOT diff=astextplain | ||
*.pdf diff=astextplain | ||
*.PDF diff=astextplain | ||
*.rtf diff=astextplain | ||
*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
gradle/ | ||
.gradle/ | ||
gradlew* | ||
.idea/ | ||
.metadata/ | ||
.settings/ | ||
bin/ | ||
build/ | ||
.classpath | ||
.project | ||
RemoteSystemsTempFiles/.project | ||
*.iml | ||
*.eml | ||
out/ | ||
target/ | ||
dependency-reduced-pom.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
package com.satoshicraft.bottle; | ||
|
||
import java.util.HashMap; | ||
|
||
import org.bukkit.event.Listener; | ||
import org.bukkit.plugin.PluginManager; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
import com.satoshicraft.bottle.commands.XpBottle; | ||
import com.satoshicraft.bottle.listener.XpBottleThrow; | ||
|
||
public class Main | ||
extends JavaPlugin | ||
implements Listener | ||
{ | ||
public HashMap<String, Integer> xpitemlore; | ||
public XpLevel xpl = new XpLevel(); | ||
public XpItem xpBottle = new XpItem(this); | ||
private YmlMaker cfg; | ||
|
||
public void onEnable() | ||
{ | ||
this.cfg = new YmlMaker(this, "config.yml"); | ||
this.cfg.saveDefaultConfig(); | ||
onRegisterCommands(); | ||
onRegisterEvents(); | ||
this.xpitemlore = new HashMap<String, Integer>(); | ||
getServer().getPluginManager().registerEvents(this, this); | ||
double dropPercentage = this.cfg.getConfig().getDouble("DropPercentage"); | ||
if ((dropPercentage <= 0.0D) || (dropPercentage > 100.0D)) | ||
{ | ||
this.cfg.getConfig().set("DropPercentage", Integer.valueOf(100)); | ||
this.cfg.saveConfig(); | ||
this.cfg.reloadConfig(); | ||
} | ||
} | ||
|
||
public void onRegisterCommands() | ||
{ | ||
getCommand("satoshixp").setExecutor(new XpBottle(this)); | ||
} | ||
|
||
public void onRegisterEvents() | ||
{ | ||
PluginManager pm = getServer().getPluginManager(); | ||
pm.registerEvents(new XpBottleThrow(this), this); | ||
} | ||
|
||
public void onDisable() {} | ||
|
||
public YmlMaker getCfg() | ||
{ | ||
return this.cfg; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package com.satoshicraft.bottle; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public class NumberCheck | ||
{ | ||
public static boolean isInt(String s, Player p) | ||
{ | ||
try | ||
{ | ||
Integer.parseInt(s); | ||
} | ||
catch (NumberFormatException nfe) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
package com.satoshicraft.bottle; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import org.bukkit.Material; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.ItemStack; | ||
import org.bukkit.inventory.meta.ItemMeta; | ||
|
||
public class XpItem | ||
{ | ||
@SuppressWarnings("unused") | ||
private Main pl; | ||
private ItemStack Xpb; | ||
|
||
public XpItem(Main plugin) | ||
{ | ||
this.pl = plugin; | ||
} | ||
|
||
public void setXpb(int takenXp, Player p) | ||
{ | ||
this.Xpb = new ItemStack(Material.EXP_BOTTLE, 1); | ||
ItemMeta xpbmeta = this.Xpb.getItemMeta(); | ||
String BottleName = "&6&lFrasco de XP &7(%value% XP)"; | ||
BottleName = BottleName.replaceAll("&", "§"); | ||
BottleName = BottleName.replace("%value%", String.valueOf(takenXp)); | ||
xpbmeta.setDisplayName(BottleName); | ||
List<String> lore = new ArrayList<String>(); | ||
String value = "&dValor&r %value% XP"; | ||
value = value.replaceAll("&", "§"); | ||
value = value.replace("%value%", String.valueOf(takenXp)); | ||
lore.add(value); | ||
String enchanter = "&dEngarrafado por&r %player%"; | ||
enchanter = enchanter.replaceAll("&", "§"); | ||
if (enchanter.contains("%player%")) { | ||
enchanter = enchanter.replace("%player%", p.getName()); | ||
} | ||
lore.add(enchanter); | ||
xpbmeta.setLore(lore); | ||
this.Xpb.setItemMeta(xpbmeta); | ||
} | ||
|
||
public void setXpbServer(int takenXp) | ||
{ | ||
this.Xpb = new ItemStack(Material.EXP_BOTTLE, 1); | ||
ItemMeta xpbmeta = this.Xpb.getItemMeta(); | ||
String BottleName = "&6&lFrasco de XP &7(%value% XP)"; | ||
BottleName = BottleName.replaceAll("&", "�"); | ||
BottleName = BottleName.replace("%value%", String.valueOf(takenXp)); | ||
xpbmeta.setDisplayName(BottleName); | ||
List<String> lore = new ArrayList<String>(); | ||
String value = "&dValor&r %value% XP"; | ||
value = value.replaceAll("&", "�"); | ||
value = value.replace("%value%", String.valueOf(takenXp)); | ||
lore.add(value); | ||
String enchanter = "&dEngarrafado por &rServer"; | ||
enchanter = enchanter.replaceAll("&", "�"); | ||
lore.add(enchanter); | ||
xpbmeta.setLore(lore); | ||
this.Xpb.setItemMeta(xpbmeta); | ||
} | ||
|
||
public ItemStack getXpb() | ||
{ | ||
return this.Xpb; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.satoshicraft.bottle; | ||
|
||
import org.bukkit.entity.Player; | ||
|
||
public class XpLevel | ||
{ | ||
private static double xplevel; | ||
private static int xpe; | ||
private static int result; | ||
|
||
public static void setXpLevel(int level, float cExp) | ||
{ | ||
if (level > 30) | ||
{ | ||
xplevel = 4.5D * level * level - 162.5D * level + 2220.0D; | ||
xpe = 9 * level - 158; | ||
xplevel += Math.round(cExp * xpe); | ||
result = (int)xplevel; | ||
return; | ||
} | ||
if (level > 15) | ||
{ | ||
xplevel = 2.5D * level * level - 40.5D * level + 360.0D; | ||
xpe = 5 * level - 38; | ||
xplevel += Math.round(cExp * xpe); | ||
result = (int)xplevel; | ||
return; | ||
} | ||
if (level <= 15) | ||
{ | ||
xplevel = level * level + 6 * level; | ||
xpe = 2 * level + 7; | ||
xplevel += Math.round(cExp * xpe); | ||
result = (int)xplevel; | ||
return; | ||
} | ||
} | ||
|
||
public static int getXp(Player p) | ||
{ | ||
setXpLevel(p.getLevel(), p.getExp()); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package com.satoshicraft.bottle; | ||
|
||
import java.io.File; | ||
import java.io.FileInputStream; | ||
import java.io.FileNotFoundException; | ||
import java.io.IOException; | ||
import java.io.InputStream; | ||
import java.io.InputStreamReader; | ||
import java.io.UnsupportedEncodingException; | ||
import java.util.logging.Level; | ||
import org.bukkit.configuration.file.FileConfiguration; | ||
import org.bukkit.configuration.file.YamlConfiguration; | ||
import org.bukkit.plugin.java.JavaPlugin; | ||
|
||
public class YmlMaker | ||
{ | ||
Main Plugin; | ||
public String fileName; | ||
private JavaPlugin plugin; | ||
public File ConfigFile; | ||
private FileConfiguration Configuration; | ||
|
||
public YmlMaker(Main Plugin) | ||
{ | ||
this.Plugin = Plugin; | ||
} | ||
|
||
public YmlMaker(JavaPlugin plugin, String fileName) | ||
{ | ||
if (plugin == null) { | ||
throw new IllegalArgumentException("plugin cannot be null"); | ||
} | ||
this.plugin = plugin; | ||
this.fileName = fileName; | ||
File dataFolder = plugin.getDataFolder(); | ||
if (dataFolder == null) { | ||
throw new IllegalStateException(); | ||
} | ||
this.ConfigFile = new File(dataFolder.toString() + File.separatorChar + this.fileName); | ||
} | ||
|
||
public void reloadConfig() | ||
{ | ||
try | ||
{ | ||
this.Configuration = YamlConfiguration.loadConfiguration(new InputStreamReader(new FileInputStream(this.ConfigFile), "UTF-8")); | ||
} | ||
catch (UnsupportedEncodingException e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
catch (FileNotFoundException e) | ||
{ | ||
e.printStackTrace(); | ||
} | ||
InputStream defConfigStream = this.plugin.getResource(this.fileName); | ||
if (defConfigStream != null) | ||
{ | ||
@SuppressWarnings("deprecation") | ||
YamlConfiguration defConfig = YamlConfiguration.loadConfiguration(defConfigStream); | ||
this.Configuration.setDefaults(defConfig); | ||
} | ||
} | ||
|
||
public FileConfiguration getConfig() | ||
{ | ||
if (this.Configuration == null) { | ||
reloadConfig(); | ||
} | ||
return this.Configuration; | ||
} | ||
|
||
public void saveConfig() | ||
{ | ||
if ((this.Configuration == null) || (this.ConfigFile == null)) { | ||
return; | ||
} | ||
try | ||
{ | ||
getConfig().save(this.ConfigFile); | ||
} | ||
catch (IOException ex) | ||
{ | ||
this.plugin.getLogger().log(Level.SEVERE, "Could not save config to " + this.ConfigFile, ex); | ||
} | ||
} | ||
|
||
public void saveDefaultConfig() | ||
{ | ||
if (!this.ConfigFile.exists()) { | ||
this.plugin.saveResource(this.fileName, false); | ||
} | ||
} | ||
} |
Oops, something went wrong.