Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Upadting FlatGen, Adding Meaglin's Zones permissions resolving support,

Added some additional Custom Events
  • Loading branch information...
commit 8ec64b6c233cce147257a56b15147f5942196807 1 parent fd7b027
@GuntherDW authored
View
7 src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/AdminCommands.java
@@ -23,6 +23,7 @@
import com.guntherdw.bukkit.tweakcraft.Chat.Modes.AdminChat;
import com.guntherdw.bukkit.tweakcraft.Commands.aCommand;
import com.guntherdw.bukkit.tweakcraft.DataSources.Ban.BanHandler;
+import com.guntherdw.bukkit.tweakcraft.Events.TweakcraftUtilsEvent;
import com.guntherdw.bukkit.tweakcraft.Exceptions.*;
import com.guntherdw.bukkit.tweakcraft.Packages.ItemDB;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
@@ -470,6 +471,10 @@ public boolean tweakcraft(CommandSender sender, String command, String[] args)
plugin.getPlayerListener().reloadInfo();
} */
+ TweakcraftUtilsEvent reloadEvent = new TweakcraftUtilsEvent(TweakcraftUtilsEvent.Action.RELOAD);
+ if (sender instanceof Player) reloadEvent.setPlayer((Player) sender);
+ plugin.getServer().getPluginManager().callEvent(reloadEvent);
+
} else if(args[0].equalsIgnoreCase("world")) {
if(sender instanceof Player)
if(!plugin.check((Player) sender, "admin.world"))
@@ -477,7 +482,7 @@ public boolean tweakcraft(CommandSender sender, String command, String[] args)
if(args.length>2) {
String modus = args[1];
String world = args[2];
- String arg = args.length>3? args[3] : null;
+ String arg = args.length>3 ? args[3] : null;
iWorld iw = plugin.getworldManager().getWorld(world);
if(modus.equalsIgnoreCase("unload")) {
if(iw!=null) {
View
2  src/com/guntherdw/bukkit/tweakcraft/Commands/Commands/TeleportationCommands.java
@@ -265,7 +265,7 @@ public boolean teleportToPlayer(CommandSender sender, String command, String[] r
tpsuccess = player.teleport(getTpLocation(p));
if (tpsuccess) {
plugin.getTelehistory().addHistory(player.getName(), oldloc);
- p.sendMessage(player.getDisplayName() + ChatColor.LIGHT_PURPLE + " Teleported to you!");
+ if(!lp.isInvisible()) p.sendMessage(player.getDisplayName() + ChatColor.LIGHT_PURPLE + " Teleported to you!");
if (override)
player.sendMessage(ChatColor.RED + "Forced tp!");
View
3  src/com/guntherdw/bukkit/tweakcraft/Events/TweakcraftUtilsEvent.java
@@ -63,6 +63,7 @@ public static HandlerList getHandlerList() {
public enum Action {
CHATMODE_CHANGED,
NICK_CHANGED,
- RELOAD_INFO
+ RELOAD_INFO,
+ RELOAD
}
}
View
18 src/com/guntherdw/bukkit/tweakcraft/Listeners/TweakcraftPlayerListener.java
@@ -217,10 +217,10 @@ public Player findPlayerByNick(String nick, boolean exact) {
String p = null;
String n = null;
- for (String part : nicks.keySet()) {
- n = nicks.get(part);
- if (exact ? n.toLowerCase().equals(nick.toLowerCase()) : n.toLowerCase().contains(nick.toLowerCase())) {
- p = part;
+ for (Map.Entry<String, String> part : nicks.entrySet()) {
+ if (exact ? part.getValue().toLowerCase().equals(nick.toLowerCase())
+ : ChatColor.stripColor(part.getValue()).toLowerCase().contains(nick.toLowerCase())) {
+ p = part.getValue();
}
}
@@ -249,10 +249,12 @@ public String findPlayerNameByNick(String nick, boolean strict) {
String p = null;
String n = null;
- for (String part : nicks.keySet()) {
- n = nicks.get(part);
- if (strict ? n.toLowerCase().equals(nick.toLowerCase()) : n.toLowerCase().contains(nick.toLowerCase())) {
- p = part;
+ for (Map.Entry<String, String> part : nicks.entrySet()) {
+ // n = nicks.get(part);
+ if (strict ? part.getValue().toLowerCase().equals(nick.toLowerCase())
+ : ChatColor.stripColor(part.getValue()).toLowerCase().contains(nick.toLowerCase())) {
+ // p = part;
+ p = part.getValue();
if (strict) return p;
}
}
View
77 src/com/guntherdw/bukkit/tweakcraft/Tools/Permissions/ZonesPerms.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright (c) 2012 GuntherDW
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+package com.guntherdw.bukkit.tweakcraft.Tools.Permissions;
+
+import com.guntherdw.bukkit.tweakcraft.Tools.PermissionsResolver;
+import com.zones.Zones;
+import org.bukkit.entity.Player;
+
+/**
+ * @author GuntherDW
+ */
+public class ZonesPerms extends Permissions {
+
+ private Zones zones;
+ private PermissionsResolver resolver;
+
+ public ZonesPerms(PermissionsResolver permissionsResolver, Zones zonesInstance) {
+ this.zones = zonesInstance;
+ this.resolver = permissionsResolver;
+ }
+
+ @Override
+ public String getUserPrefix(String player) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String getUserPrefix(String world, String player) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String getPrimaryUserGroup(String world, String player) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public String getUserSuffix(String world, String player) {
+ return null; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean inGroup(String group, Player player) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean inGroup(String world, String group, Player player) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean inSingleGroup(String world, String group, Player player) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ @Override
+ public boolean hasPermission(String world, Player player, String permissionbit) {
+ return false; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
View
15 src/com/guntherdw/bukkit/tweakcraft/Tools/PermissionsResolver.java
@@ -20,6 +20,7 @@
import com.guntherdw.bukkit.tweakcraft.Tools.Permissions.*;
import com.guntherdw.bukkit.tweakcraft.TweakcraftUtils;
+import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
/**
@@ -44,6 +45,7 @@ public void init() {
foundPlugin = tryPermissionsEx();
if (!foundPlugin) foundPlugin = tryNijiPerms();
+ if (!foundPlugin) tryZones();
if (!foundPlugin) tryWEPIF();
if (!foundPlugin) {
plugin.getLogger().info("[TweakcraftUtils] DinnerPerms found, using that for permissions resolving!");
@@ -52,11 +54,24 @@ public void init() {
}
}
+
public Permissions getResolver() {
if (resolver == null) init();
return resolver;
}
+ public boolean hasPermission(String world, Player player, String permissionbit) {
+ if (resolver == null) init();
+ return resolver.hasPermission(world, player, permissionbit);
+ }
+
+ private void tryZones() {
+ if(plugin.getConfigHandler().enableZones && plugin.getZones() != null) {
+ resolver = new ZonesPerms(this, plugin.getZones());
+ plugin.getLogger().info("[TweakcraftUtils] Meaglin's Zones found, using that for permissions resolving!");
+ }
+ }
+
private boolean tryPermissionsEx() {
Plugin p = plugin.getServer().getPluginManager().getPlugin("PermissionsEx");
if (p != null) {
View
9 src/com/guntherdw/bukkit/tweakcraft/TweakcraftUtils.java
@@ -37,11 +37,11 @@
import com.guntherdw.bukkit.tweakcraft.Packages.CraftIRCEndPoint;
import com.guntherdw.bukkit.tweakcraft.Packages.ItemDB;
import com.guntherdw.bukkit.tweakcraft.Packages.LocalPlayer;
+import com.guntherdw.bukkit.tweakcraft.Tools.Permissions.Permissions;
import com.guntherdw.bukkit.tweakcraft.Tools.PermissionsResolver;
import com.guntherdw.bukkit.tweakcraft.Tools.TamerTool;
import com.guntherdw.bukkit.tweakcraft.Util.TeleportHistory;
import com.guntherdw.bukkit.tweakcraft.Worlds.WorldManager;
-import com.nijikokun.bukkit.Permissions.Permissions;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.zones.Zones;
@@ -69,7 +69,6 @@
public class TweakcraftUtils extends JavaPlugin {
- protected Permissions perm = null;
protected WorldGuardPlugin wg = null;
protected CraftIRC circ = null;
protected Zones zones = null;
@@ -125,6 +124,10 @@ public PermissionsResolver getPermissions() {
return this.permsResolver;
}
+ public Permissions getPermissionsResolver() {
+ return this.getPermissions().getResolver();
+ }
+
public Set<Player> getCUIPlayers() {
return cuiPlayers;
}
@@ -630,7 +633,7 @@ public String getNick(String player) {
public boolean check(Player player, String permNode) {
return player.isOp() ||
- this.getPermissions().getResolver().hasPermission(player.getWorld().getName(), player, "tweakcraftutils." + permNode);
+ this.getPermissions().hasPermission(player.getWorld().getName(), player, "tweakcraftutils." + permNode);
}
public boolean checkfull(Player player, String permNode) {
View
49 src/com/guntherdw/bukkit/tweakcraft/Worlds/Generators/FlatGen.java
@@ -78,7 +78,7 @@ public byte getToplayer() {
return toplayer;
}
- @Override
+ /* @Override
public byte[] generate(World world, Random random, int cx, int cz) {
// byte[] result = new byte[32768];
byte[] result = new byte[65536];
@@ -98,6 +98,53 @@ else if (y == height)
}
}
return result;
+ } */
+
+ @Deprecated
+ public byte[] generate(World world, Random random, int x, int z) {
+ return null;
+ }
+
+ @Override
+ public short[][] generateExtBlockSections(World world, Random random, int x, int z, BiomeGrid biomes) {
+ return null;
+ }
+
+ public byte[][] generateBlockSections(World world, Random random, int cx, int cz, BiomeGrid biomes) {
+ int maxHeight = world.getMaxHeight();
+ byte[][] result = new byte[maxHeight / 16][];
+
+ for(int x = 0; x < 16; x++) {
+ for(int z = 0; z < 16; z++) {
+ for(int y = 0; y < maxHeight; y++) {
+ if(y== 0 && bedrockBottom)
+ setBlock(result, x, y, z, (byte) 7);
+ else if (y < height)
+ setBlock(result, x, y, z, normal);
+ else if (y == height)
+ setBlock(result, x, y, z, toplayer);
+ else
+ setBlock(result, x, y, z, (byte) 0);
+ }
+ }
+ }
+
+ // return null; // Default - returns null, which drives call to generate()
+ return result;
+ }
+
+ public void setBlock(byte[][] result, int x, int y, int z, byte blkid) {
+ if (result[y >> 4] == null) {
+ result[y >> 4] = new byte[4096];
+ }
+ result[y >> 4][((y & 0xF) << 8) | (z << 4) | x] = blkid;
+ }
+
+ public byte getBlock(byte[][] result, int x, int y, int z) {
+ if (result[y >> 4] == null) {
+ return (byte)0;
+ }
+ return result[y >> 4][((y & 0xF) << 8) | (z << 4) | x];
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.