Skip to content

Commit

Permalink
Version 2.3c
Browse files Browse the repository at this point in the history
    New Enchantments
    	Headless (Thanks to IAmNotPopular and hetjoshi) - Gives you the Head of a player you killed
	Coding
		Updated to Spigot 1.8.6 - Fixed some compiler errors on some IDE setups (casts of null values)
    Bugfixes
    	Global enchantments that also worked on bows now work again
		Fixed the color of the enchantments having to be spelled in capital letters
  • Loading branch information
Taiterio authored and Taiterio committed May 31, 2015
1 parent bf0da5e commit f5f3f9d
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 12 deletions.
2 changes: 1 addition & 1 deletion plugin.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CustomEnchantments
main: com.taiter.ce.Main
version: 2.3b
version: 2.3c

softdepend: [WorldGuard, WorldEdit, Vault]

Expand Down
2 changes: 1 addition & 1 deletion src/com/taiter/ce/CEventHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ public static void handleEventMain(Player toCheck, ItemStack i, Event e, HashSet
}
//BOWS

if(e instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) e).getDamager() instanceof Player && ce.triggers.contains(Trigger.SHOOT_BOW))
if(e instanceof EntityDamageByEntityEvent && ((EntityDamageByEntityEvent) e).getDamager() instanceof Player && ce.triggers.contains(Trigger.SHOOT_BOW) && ((Player) ((EntityDamageByEntityEvent) e).getDamager()).getItemInHand().getType().equals(Material.BOW))
continue;

ce.effect(e, i, level);
Expand Down
3 changes: 2 additions & 1 deletion src/com/taiter/ce/CItems/Deathscythe.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/


import java.util.HashSet;
import java.util.List;

import org.bukkit.ChatColor;
Expand Down Expand Up @@ -113,7 +114,7 @@ public boolean effect(Event event, final Player player) {
}

for(int i = 1; i < Range; i++) {
loc = player.getTargetBlock(null, i).getLocation();
loc = player.getTargetBlock((HashSet<Byte>)null, i).getLocation();
if(!loc.getBlock().getType().equals(Material.AIR))
return true;
loc.getWorld().playEffect(loc, Effect.SMOKE, Range*2);
Expand Down
3 changes: 2 additions & 1 deletion src/com/taiter/ce/CItems/Flamethrower.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@


import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;

import org.bukkit.ChatColor;
Expand Down Expand Up @@ -138,7 +139,7 @@ public void initConfigEntries() {
public List<Location> getLinePlayer(Player player, int length) {
List<Location> list = new ArrayList<Location>();
for(int amount = length; amount > 0; amount --) {
list.add(player.getTargetBlock(null, amount).getLocation());
list.add(player.getTargetBlock((HashSet<Byte>)null, amount).getLocation());
}
return list;
}
Expand Down
3 changes: 2 additions & 1 deletion src/com/taiter/ce/CItems/NecromancersStaff.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;

import org.bukkit.ChatColor;
Expand Down Expand Up @@ -143,7 +144,7 @@ public boolean effect(Event event, Player player) {
player.launchProjectile(SmallFireball.class).setVelocity(l.getDirection().multiply(1.5));
player.getWorld().playSound(l, Sound.BLAZE_HIT, 0.2f, 0f);
} else if(spell == 2) {
Location target = player.getTargetBlock(null, 20).getLocation();
Location target = player.getTargetBlock((HashSet<Byte>)null, 20).getLocation();
player.getWorld().strikeLightning(target);
if(Tools.checkWorldGuard(l, player, "TNT", true))
player.getWorld().createExplosion(target, 1);
Expand Down
75 changes: 75 additions & 0 deletions src/com/taiter/ce/Enchantments/Global/Headless.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.taiter.ce.Enchantments.Global;

/*
* This file is part of Custom Enchantments
* Copyright (C) Taiterio 2015
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by the
* Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
* for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/



import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.Event;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.SkullMeta;
import org.bukkit.scheduler.BukkitRunnable;

import com.taiter.ce.Enchantments.CEnchantment;



public class Headless extends CEnchantment {

public Headless(Application app) {
super(app);
triggers.add(Trigger.DAMAGE_GIVEN);
}

@Override
public void effect(Event e, ItemStack item, int level) {
EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e;
final Player player = (Player) event.getDamager();
final LivingEntity ent = (LivingEntity) event.getEntity();

new BukkitRunnable() {
@Override
public void run() {

if(ent.getHealth() <= 0)
if(!(ent instanceof Player))
return;
else {
ItemStack skull = new ItemStack(Material.SKULL_ITEM, 1, (byte) 3);
SkullMeta sm = (SkullMeta) skull.getItemMeta();
sm.setOwner(ent.getName());
skull.setItemMeta(sm);
ent.getWorld().dropItem(ent.getLocation(), skull);
player.getWorld().playSound(player.getLocation(), Sound.ZOMBIE_WOODBREAK, 0.1f, 0.1f);
}
}
}.runTaskLater(getPlugin(), 1l);


}

@Override
public void initConfigEntries() {
this.resetMaxLevel();
}
}
22 changes: 17 additions & 5 deletions src/com/taiter/ce/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -177,14 +177,26 @@ public void onEnable(){
//Start the listener
initializeListener();

createExplosions = Boolean.parseBoolean(Main.config.getString("Global.CreateExplosions"));

//Get the maximum amount of Enchantments on an Item
maxEnchants = Integer.parseInt(config.getString("Global.Enchantments.MaximumCustomEnchantments"));
try {

createExplosions = Boolean.parseBoolean(Main.config.getString("Global.CreateExplosions"));

//Set the Loreprefix
lorePrefix = Tools.resolveEnchantmentColor();
//Get the maximum amount of Enchantments on an Item
maxEnchants = Integer.parseInt(config.getString("Global.Enchantments.MaximumCustomEnchantments"));

} catch(Exception ex) {
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[CE] Config error, please check the values of");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[CE] Global.CreateExplosions (Has to be true or false) and");
Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "[CE] Global.Enchantments.MaximumCustomEnchantments (Has to be a number)");
}

//Set the Loreprefix
lorePrefix = Tools.resolveEnchantmentColor();




//Check and set up the Economy
if(setupEconomy()) {
Bukkit.getConsoleSender().sendMessage(ChatColor.GREEN + "[CE] Vault has been detected!");
Expand Down
4 changes: 2 additions & 2 deletions src/com/taiter/ce/Tools.java
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ public static String resolveEnchantmentColor() {
}
} else {
try {
color = ChatColor.valueOf(Main.config.getString("Global.Enchantments.CEnchantmentColor")) + "";
color = ChatColor.valueOf(Main.config.getString("Global.Enchantments.CEnchantmentColor").toUpperCase()).toString();
} catch (Exception e){
Bukkit.getConsoleSender().sendMessage(ChatColor.DARK_RED + "[CE] ERROR: The ChatColor '" + color + "' was not found, please check the list of Bukkit ChatColors and update the ChatColor Section. The ChatColor will be ignored to ensure that CE is still working.");
}
Expand Down Expand Up @@ -970,7 +970,7 @@ private static String getPlayerDirection(Location loc) {
public static List<Location> getLinePlayer(Player player, int length) {
List<Location> list = new ArrayList<Location>();
for(int amount = length; amount > 0; amount--) {
list.add(player.getTargetBlock(null, amount).getLocation());
list.add(player.getTargetBlock((HashSet<Byte>) null, amount).getLocation());
}
return list;
}
Expand Down

0 comments on commit f5f3f9d

Please sign in to comment.