Created
May 20, 2014 17:39
-
-
Save theresajayne/2c37fce51dcaa92eb413 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
import org.bukkit.permissions.Permissible; | |
import org.bukkit.ChatColor; | |
import org.bukkit.entity.Player; | |
import java.lang.Throwable; | |
import java.lang.Object; | |
import org.bukkit.plugin.PluginManager; | |
import com.slashchest.CommandCopyDat; | |
import com.slashchest.CommandMoveChest; | |
import com.slashchest.CommandOSpawn; | |
import com.slashchest.CommandDragonspawn; | |
import com.slashchest.CommandOpenChest; | |
import org.bukkit.command.CommandExecutor; | |
import com.slashchest.CommandChest; | |
import org.bukkit.plugin.Plugin; | |
import org.bukkit.event.Listener; | |
import com.slashchest.SlashChestListener; | |
import java.lang.StringBuilder; | |
import java.lang.System; | |
import java.lang.CharSequence; | |
import com.slashchest.InventoryAccess; | |
import com.slashchest.PlayerDataManager; | |
import com.slashchest.SpecialChest; | |
import java.lang.String; | |
import java.util.HashMap; | |
import java.util.logging.Logger; | |
import org.bukkit.plugin.java.JavaPlugin; | |
public class SlashChest extends JavaPlugin | |
{ | |
public static final Logger logger; | |
public static HashMap<String, SpecialChest> Chests; | |
public static SlashChest mainPlugin; | |
public static PlayerDataManager playerLoader; | |
public static InventoryAccess inventoryAccess; | |
public static String specialString; | |
public static int specialId; | |
public static int specialDamage; | |
public static String special2String; | |
public static int special2Id; | |
public static int special2Damage; | |
public static double[] spawnpos; | |
public static int tprandomMin; | |
public static int tprandomMax; | |
static { | |
logger = Logger.getLogger("Minecraft.SlashChest"); | |
SlashChest.Chests = new HashMap<String, SpecialChest>(); | |
SlashChest.specialString = "Electric Chest"; | |
SlashChest.specialId = 3001; | |
SlashChest.specialDamage = 13; | |
SlashChest.special2String = ""; | |
SlashChest.special2Id = 0; | |
SlashChest.special2Damage = 0; | |
SlashChest.spawnpos = new double[] { -30.5, 76.0, -125.5 }; | |
SlashChest.tprandomMax = 10000; | |
SlashChest.tprandomMin = 0; | |
} | |
public void onEnable() { | |
final PluginManager pm = this.getServer().getPluginManager(); | |
if (!this.getServer().getVersion().contains("1.5.2")) { | |
System.out.println("[SlashChest] SlashChest plugin is for Minecraft version 1.5.2 only, this is " + this.getServer().getVersion() + ", disabling."); | |
return; | |
} | |
this.saveDefaultConfig(); | |
this.reloadConfig(); | |
SlashChest.specialString = this.getConfig().getString("SpecialChest.name", SlashChest.specialString); | |
SlashChest.specialId = this.getConfig().getInt("SpecialChest.ID", SlashChest.specialId); | |
SlashChest.specialDamage = this.getConfig().getInt("SpecialChest.damage", SlashChest.specialDamage); | |
SlashChest.special2String = this.getConfig().getString("SpecialChest2.name", SlashChest.special2String); | |
SlashChest.special2Id = this.getConfig().getInt("SpecialChest2.ID", SlashChest.specialId); | |
SlashChest.special2Damage = this.getConfig().getInt("SpecialChest2.damage", SlashChest.special2Damage); | |
SlashChest.spawnpos[0] = 0.5 + this.getConfig().getInt("SpawnPosition.x", -31); | |
SlashChest.spawnpos[1] = 0.0 + this.getConfig().getInt("SpawnPosition.y", 76); | |
SlashChest.spawnpos[2] = 0.5 + this.getConfig().getInt("SpawnPosition.z", -126); | |
SlashChest.tprandomMin = 0 + this.getConfig().getInt("tpMin",0); | |
SlashChest.tprandomMax = 0 + this.getConfig().getInt("tpMax",10000); | |
this.saveConfig(); | |
SlashChest.playerLoader = new PlayerDataManager(); | |
SlashChest.inventoryAccess = new InventoryAccess(); | |
SlashChest.mainPlugin = this; | |
pm.registerEvents(new SlashChestListener(), (Plugin)this); | |
this.getCommand("chest").setExecutor(new CommandChest(this)); | |
this.getCommand("openchest").setExecutor(new CommandOpenChest(this)); | |
this.getCommand("dragonspawn").setExecutor(new CommandDragonspawn(this)); | |
this.getCommand("ospawn").setExecutor(new CommandOSpawn(this)); | |
this.getCommand("movechest").setExecutor(new CommandMoveChest(this)); | |
this.getCommand("copydat").setExecutor(new CommandCopyDat(this)); | |
logger.warning("adding slashchest commands"); | |
this.getCommand("tprandom").setExecutor(new CommandTpRandom(this)); | |
} | |
public static Object GetFromConfig(final String data, final Object defaultValue) { | |
final Object val = SlashChest.mainPlugin.getConfig().get(data); | |
if (val == null) { | |
SlashChest.mainPlugin.getConfig().set(data, defaultValue); | |
return defaultValue; | |
} | |
return val; | |
} | |
public static void SaveToConfig(final String data, final Object value) { | |
SlashChest.mainPlugin.getConfig().set(data, value); | |
SlashChest.mainPlugin.saveConfig(); | |
} | |
public static void log(final String text) { | |
SlashChest.logger.info("[SlashChest] " + text); | |
} | |
public static void log(final Throwable e) { | |
SlashChest.logger.severe("[SlashChest] " + e.toString()); | |
e.printStackTrace(); | |
} | |
public static void ShowHelp(final Player player) { | |
player.sendMessage(ChatColor.GREEN + "/openchest <Player> - Open another player's /chest (staff only)"); | |
} | |
public static boolean hasPermission(final Permissible player, final String permission) { | |
final String[] parts = permission.split("\\."); | |
String perm = ""; | |
for (int i = 0; i < parts.length; ++i) { | |
if (player.hasPermission(String.valueOf(perm) + "*")) { | |
return true; | |
} | |
perm = String.valueOf(perm) + parts[i] + "."; | |
} | |
return player.hasPermission(permission); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment