initial import
This commit is contained in:
17
MobScores/License-Header.txt
Normal file
17
MobScores/License-Header.txt
Normal file
@@ -0,0 +1,17 @@
|
||||
/*
|
||||
This file is part of MobScores.
|
||||
|
||||
MobScores is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MobScores 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with MobScores. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
2
MobScores/Manifest.MF
Normal file
2
MobScores/Manifest.MF
Normal file
@@ -0,0 +1,2 @@
|
||||
Manifest-Version: 1.0
|
||||
|
||||
19
MobScores/MobScores.jardesc
Normal file
19
MobScores/MobScores.jardesc
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
|
||||
<jardesc>
|
||||
<jar path="C:/Users/Tom/Desktop/Minecraft/Server (Bukkit) - Copy/plugins/MobScores.jar"/>
|
||||
<options buildIfNeeded="true" compress="true" descriptionLocation="/MobScores/MobScores.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
|
||||
<storedRefactorings deprecationInfo="true" structuralOnly="false"/>
|
||||
<selectedProjects/>
|
||||
<manifest generateManifest="false" manifestLocation="/MobScores/Manifest.MF" manifestVersion="1.0" reuseManifest="true" saveManifest="true" usesManifest="true">
|
||||
<sealing sealJar="false">
|
||||
<packagesToSeal/>
|
||||
<packagesToUnSeal/>
|
||||
</sealing>
|
||||
</manifest>
|
||||
<selectedElements exportClassFiles="true" exportJavaFiles="false" exportOutputFolder="false">
|
||||
<file path="/MobScores/.classpath"/>
|
||||
<javaElement handleIdentifier="=MobScores/\/ScoreKeeper\/bin"/>
|
||||
<javaElement handleIdentifier="=MobScores/src"/>
|
||||
<file path="/MobScores/.project"/>
|
||||
</selectedElements>
|
||||
</jardesc>
|
||||
6
MobScores/Readme.txt
Normal file
6
MobScores/Readme.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
This mod is copyright (c) 2011 Tom Hicks and released under the AGPL v3. See the file agpl-3.0.txt for the specifics of the license.
|
||||
|
||||
No Commands
|
||||
|
||||
Edit plugins/MobScores/config.yml to set scores per mob.
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
4
MobScores/bin/plugin.yml
Normal file
4
MobScores/bin/plugin.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: MobScores
|
||||
main: com.majinnaibu.bukkit.plugins.mobscores.MobScoresPlugin
|
||||
depend: [ScoreKeeper]
|
||||
version: 0.1
|
||||
@@ -0,0 +1,163 @@
|
||||
/*
|
||||
This file is part of MobScores.
|
||||
|
||||
MobScores is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MobScores 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with MobScores. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.majinnaibu.bukkit.plugins.mobscores;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Zombie;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
import com.majinnaibu.bukkit.plugins.mobscores.listeners.MobDeathListener;
|
||||
import com.majinnaibu.bukkit.plugins.mobscores.listeners.PlayerConnectListener;
|
||||
import com.majinnaibu.bukkit.plugins.scorekeeper.ScoreKeeperPlugin;
|
||||
|
||||
public class MobScoresPlugin extends JavaPlugin {
|
||||
private final MobDeathListener _mobDeathListener = new MobDeathListener(this);
|
||||
private final PlayerConnectListener _playerConnectListener = new PlayerConnectListener(this);
|
||||
private HashMap<Entity, Player> _claimedMobs = new HashMap<Entity, Player>();
|
||||
private HashMap<String, Integer> _scoreTable = new HashMap<String, Integer>();
|
||||
private ScoreKeeperPlugin _scoreKeeper = null;
|
||||
private Configuration _configuration = null;
|
||||
|
||||
private final String _logStart = "[" + ChatColor.AQUA + "MobScores" + ChatColor.WHITE + "] ";
|
||||
|
||||
public final Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
_configuration.setProperty("ScoreTable", _scoreTable);
|
||||
_configuration.save();
|
||||
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void onEnable() {
|
||||
_configuration = getConfiguration();
|
||||
try{
|
||||
_scoreTable = (HashMap<String, Integer>)_configuration.getProperty("ScoreTable");
|
||||
}catch (Exception ex){
|
||||
_scoreTable = getDefaultScoreTable();
|
||||
}
|
||||
|
||||
if(_scoreTable == null){
|
||||
_scoreTable = getDefaultScoreTable();
|
||||
}
|
||||
|
||||
_configuration.setProperty("ScoreTable", _scoreTable);
|
||||
|
||||
|
||||
_configuration.save();
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
_scoreKeeper = (ScoreKeeperPlugin)pm.getPlugin("ScoreKeeper");
|
||||
|
||||
if(_scoreKeeper == null){
|
||||
pm.disablePlugin(this);
|
||||
}
|
||||
|
||||
pm.registerEvent(Event.Type.ENTITY_DEATH, _mobDeathListener, Event.Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.ENTITY_DAMAGE, _mobDeathListener, Event.Priority.Monitor, this);
|
||||
pm.registerEvent(Event.Type.PLAYER_JOIN, _playerConnectListener, Event.Priority.Monitor, this);
|
||||
|
||||
PluginDescriptionFile pdFile = this.getDescription();
|
||||
log.info(pdFile.getName() + " version " + pdFile.getVersion() + " is enabled!");
|
||||
}
|
||||
|
||||
private HashMap<String, Integer> getDefaultScoreTable() {
|
||||
HashMap<String, Integer> scores = new HashMap<String, Integer>();
|
||||
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftZombie", 50);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftChicken", 0);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftCow", 0);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftCreeper", 50);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftGhast", 100);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftGiant", 250);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftPig", 0);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftPigZombie", 25);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftPlayer", 0);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftSheep", 0);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftSkeleton", 50);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftSlime", 100);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftSpider", 50);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftSquid", 0);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftWolf", 50);
|
||||
scores.put("org.bukkit.craftbukkit.entity.CraftZombie", 50);
|
||||
|
||||
return scores;
|
||||
}
|
||||
|
||||
public void claimMob(Entity entity, Player damager) {
|
||||
if(entity instanceof Zombie){
|
||||
_claimedMobs.put((Zombie)entity, damager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void awardScore(Entity entity) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
if(_claimedMobs.containsKey(entity)){
|
||||
Class<?> scoreClass = entity.getClass();
|
||||
String className = scoreClass.getName();
|
||||
if(_scoreTable.containsKey(className)){
|
||||
Player player = _claimedMobs.get(entity);
|
||||
int score = _scoreTable.get(className);
|
||||
|
||||
_scoreKeeper.addScore(player, score);
|
||||
}else{
|
||||
log.warning("[MobScores] Unable to award score for {" + className + "}");
|
||||
Set<String> keys = _scoreTable.keySet();
|
||||
String str = null;
|
||||
for(Iterator<String> i = keys.iterator(); i.hasNext(); str = i.next()){
|
||||
log.info("{" + str + "}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayerScoreTable(Player player) {
|
||||
Iterator<Map.Entry<String, Integer>> i=_scoreTable.entrySet().iterator();
|
||||
Map.Entry<String, Integer> pair = null;
|
||||
for(pair = i.next(); i.hasNext(); pair = i.next()){
|
||||
if(pair.getValue() != 0){
|
||||
String key = pair.getKey();
|
||||
if(key.startsWith("org.bukkit.craftbukkit.entity.Craft")){
|
||||
player.sendMessage(_logStart + key.substring(35) + " = " + pair.getValue().toString());
|
||||
}else{
|
||||
player.sendMessage(_logStart + key + " = " + pair.getValue().toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void logInfo(String string) {
|
||||
log.info(_logStart + string);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
This file is part of MobScores.
|
||||
|
||||
MobScores is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MobScores 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with MobScores. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.majinnaibu.bukkit.plugins.mobscores.listeners;
|
||||
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
import com.majinnaibu.bukkit.plugins.mobscores.MobScoresPlugin;
|
||||
|
||||
public class MobDeathListener extends EntityListener {
|
||||
private MobScoresPlugin _plugin = null;
|
||||
|
||||
public MobDeathListener(MobScoresPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if(event instanceof EntityDamageByEntityEvent){
|
||||
EntityDamageByEntityEvent ev = (EntityDamageByEntityEvent) event;
|
||||
Entity damager = ev.getDamager();
|
||||
if(damager instanceof Player){
|
||||
_plugin.claimMob(ev.getEntity(), (Player)damager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityDeath(EntityDeathEvent event) {
|
||||
_plugin.awardScore(event.getEntity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(EntityExplodeEvent event) {
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
This file is part of MobScores.
|
||||
|
||||
MobScores is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
MobScores 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 Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with MobScores. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package com.majinnaibu.bukkit.plugins.mobscores.listeners;
|
||||
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
|
||||
import com.majinnaibu.bukkit.plugins.mobscores.MobScoresPlugin;
|
||||
|
||||
public class PlayerConnectListener extends PlayerListener {
|
||||
private MobScoresPlugin _plugin = null;
|
||||
|
||||
public PlayerConnectListener(MobScoresPlugin plugin) {
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||
_plugin.sendPlayerScoreTable(event.getPlayer());
|
||||
}
|
||||
}
|
||||
4
MobScores/src/plugin.yml
Normal file
4
MobScores/src/plugin.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
name: MobScores
|
||||
main: com.majinnaibu.bukkit.plugins.mobscores.MobScoresPlugin
|
||||
depend: [ScoreKeeper]
|
||||
version: 0.1
|
||||
Reference in New Issue
Block a user