Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
DrumYum - 27.08.2014
PHP код:
@Command
public boolean giveveh(Player p, String target, int model, int color1, int color2)
{
if(p.getVarInt(VAR_ADMIN_LEVEL) < GIVE_VEH_LEVEL)
{
p.sendMessage(new Color(-1), MESSAGE_LOW_LEVEL);
return true;
}
// ...
return true;
}
@Command
public boolean giveweap(Player p, String target, int weapon, int ammo)
{
if(p.getVarInt(VAR_ADMIN_LEVEL) < GIVE_WEAPON_LEVEL)
{
p.sendMessage(new Color(-1), MESSAGE_LOW_LEVEL);
return true;
}
// ...
return true;
}
How can I automatize check for admin level? I don't understand, how CommandGroup can help me with it.
And also I need to checking target's isOnline in all commands, how can I automatize all of it?
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
steki. - 28.08.2014
gtaun.net is http 118
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 28.08.2014
@steki.: gtaun.net is up again. Sorry for the downtime.
@DrumYum: You can create a BeforeCheck, to check the adminlevel etc. like this:
PHP код:
@BeforeCheck
public boolean checkPremission(Player p, String cmd, String params)
{
return p.isAdmin();
}
This will be called before every command, and if it returns false, the command won't be executed.
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
DrumYum - 28.08.2014
123marvin123, yes, I understand it. But I want to unite level and command together, like level is part of command. I wrote this 5 minutes ago (not tested), but I want automatize it more:
PHP код:
private Object COMMANDS_LEVELS[][] =
{
{"giveveh", 5},
{"giveweap", 5},
{"sethealth", 4}
};
@BeforeCheck
public boolean beforeCheck(Player p, String cmd, String params)
{
for(int i = 0, o = COMMANDS_LEVELS.length; i < o; i++)
{
if(!cmd.equals(COMMANDS_LEVELS[i][0])) continue;
if((int) COMMANDS_LEVELS[i][1] < p.getVarInt(VAR_ADMIN_LEVEL)) continue;
return true;
}
return false;
}
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 29.08.2014
Yes, you can do it like this, but you could make a Map, and then assign all the values to it.
Then you can do like:
PHP код:
if(hashMap.get(cmd) > player.getAdminLevel()) {
return false;
}
return true;
//Or just
return player.getAdminLevel() >= hashMap.get(cmd);
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
DrumYum - 30.08.2014
Thanks again, I'll try it.
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
DrumYum - 30.08.2014
Oh, how I can extend Player class (interface) correctly? I want to add variables like adminLevel from PVars to this class, or not worth it?
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 30.08.2014
You can't, and this has it's good reasons

, but you can use the PlayerLifecycleHolder from shoebill-common.
PHP код:
PlayerLifecycleHolder playerLifecycleHolder = new PlayerLifecycleHolder(getEventManager());
playerLifecycleHolder.registerClass(GamePlayer.class, (eventManager, p) -> new GamePlayer(eventManager, p));
then you can create a class called GamePlayer. This class has to extend the PlayerLifecycleObject. For example:
PHP код:
public class GamePlayer extends PlayerLifecycleObject {
private int adminLevel;
public GamePlayer(EventManager manager, Player p) {
super(manager, p);
}
public int getAdminLevel() {
return adminLevel;
}
public void setAdminLevel(int level) {
this.adminLevel = level;
}
@Override
protected void onInit() {
//Create objects, 3dtextlabels etc.
}
@Override
protected void onDestroy() {
//Destroy objects etc.
}
}
and you can get the class like this:
PHP код:
GamePlayer playerClass = playerLifecycleHolder.getObject(event.getPlayer(), GamePlayer.class);
or, you can get all players like this:
PHP код:
Collection<GamePlayer> players = playerLifecycleHolder.getObjects(GamePlayer.class);
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
DrumYum - 30.08.2014
What is PlayerLifecycleHolder and PlayerLifecycleObject? And for what I need to .registerClass?
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 31.08.2014
@DrumYum: The PlayerLifecycleHolder will create and destroy custom player objects when a player connects or disconnect. It was made, because you can't extend the player class. With .getObject you can get a custom object that is assigned to that player. It is like having a Map<Player, GamePlayer> (GamePlayer is a custom class, with adminLevel, isOnline, level, server-side money etc.). You need to call the .registerClass to let the PlayerLifecycleHolder know, that he should create a GamePlayer object for every player that connects (and destroy it when he disconnects).
The GamePlayer class has to extend the PlayerLifecycleObject, because it contains some methods and variables.
You can only register classes, that extend the PlayerLifecycleObject.
Example use:
PHP код:
//OnPlayerConnect
getEventManager().registerHandler(PlayerConnectEvent.class, (event) -> {
GamePlayer gamePlayer = playerLifecycleHolder.getObject(event.getPlayer(), GamePlayer.class); //Getting the players custom object with all information in it like adminLevel, money etc.
if(event.getPlayer().getName().equals("123marvin123")) //Check if player's name equals 123marvin123
gamePlayer.setAdminLevel(5); //assign admin level 5 to player
});
//OnPlayerDisconnect
getEventManager().registerHandler(PlayerDisconnectEvent.class, event -> {
GamePlayer gamePlayer = playerLifecycleHolder.getObject(event.getPlayer(), GamePlayer.class); //Getting the players custom object with all information in it like adminLevel, money etc.
event.getPlayer().sendMessage(Color.WHITE, "You had adminlevel " + gamePlayer.getAdminLevel()); //Send message with his current adminlevel as information
});
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
steki. - 31.08.2014
How do I get a streamer running without having to make one by myself?
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 31.08.2014
@steki.: You can't. Right now you have to make your own, or wait for Shoebill 1.1.
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
DrumYum - 04.09.2014
So, I can't cast Player and playerLifecycleObject?
Like this:
PHP код:
Player p = (Player) playerLifecycleHolder.getObject(e.getPlayer(), PlayerFW.class);
I must use .getObject every time when I need to setAdminlevel etc?
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 04.09.2014
@DrumYum: No, you don't have to cast it. You can call the .getPlayer() function in your custom Player class, which is already inherited from PlayerLifecycleObject. Like this:
PHP код:
PlayerFW playerFw = playerLifecycleHolder.getObject(e.getPlayer(), PlayerFW.class);
playerFw.setAdminLevel(6); //For example
Player player = playerFw.getPlayer();
//Or just:
Player player = playerLifecycleHolder.getObject(e.getPlayer(), PlayerFW.class).getPlayer();
And of course, your PlayerFW class need to have the needed methods. Like this:
PHP код:
public class .... {
private int adminLevel;
public void setAdminLevel(int adminLevel) {
this.adminLevel = adminLevel;
}
public int getAdminLevel() {
return this.adminLevel;
}
}
@EmilLykke: No, it does not contain any kind of viruses. It's opensource and you can build it youself if you don't trust mk124.
Sourcecode can be found @
https://github.com/Shoebill
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 18.09.2014
Tomorrow we will release a quick fix for 0.3z R2-4.
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 20.09.2014
Ok, Shoebill for 0.3z R2-4 got released:
http://puu.sh/bGqjO/66ed0bd7bb.zip
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
SetupDLL - 01.10.2014
Can I add my own events to this?
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 02.10.2014
@SetupDLL:
Yes, you can. For example, this is a event to detect when a player changed his armed weapon:
PHP код:
//PlayerEvent contains a Player variable already. You can also create you all own type of event, when you just implement Event. Or if you want t make some Vehicle Event you can use VehicleEvent.
public class PlayerChangedWeapon extends PlayerEvent {
private WeaponModel oldWeapon;
private WeaponModel newWeapon;
protected PlayerChangedWeapon(Player player, WeaponModel oldWeapon, WeaponModel newWeapon) {
super(player);
this.oldWeapon = oldWeapon;
this.newWeapon = newWeapon;
}
public WeaponModel getNewWeapon() {
return newWeapon;
}
public WeaponModel getOldWeapon() {
return oldWeapon;
}
}
To register it, you can use it like this:
PHP код:
eventManager.registerHandler(PlayerChangedWeapon.class, (e) -> {
Player player = e.getPlayer();
player.sendMessage(Color.RED, "* Your old weapon was " + e.getOldWeapon().getName() + " and your new one is " + e.getNewWeapon().getName());
});
But it won't trigger itself, so you need to recognize somehow if the player changed his weapon. In this case,
we can use the PlayerUpdate event and compare his old and current weapon:
PHP код:
//We need to save his old weapon, so create a global hashmap:
private WeakHashMap<Player, WeaponModel> oldWeapons;
//Initzialize it in constructor
oldWeapons = new WeakHashMap<>();
//Register PlayerUpdateEvent
eventManager.registerHandler(PlayerUpdateEvent.class, (e) -> {
if(oldWeapons.containsKey(e.getPlayer())) {
WeaponModel old = oldWeapons.get(e.getPlayer());
WeaponModel newModel = e.getPlayer().getArmedWeapon();
if(!old.equals(newModel)) {
oldWeapons.put(e.getPlayer(), newModel);
//Trigger the PlayerChangedWeapon
eventManager.dispatchEvent(new PlayerChangedWeapon(e.getPlayer(), old, newModel),
e.getPlayer());
}
} else oldWeapons.put(e.getPlayer(), e.getPlayer().getArmedWeapon());
});
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
joh999 - 11.10.2014
Hello I cannot seem to get the server running.
I have java 8 jdk and jre (Both 32 bit) installed and my JAVA_PATH and JRE_PATH variables are pointing at them.
I've downloaded the dev pack from this thread and downloaded the sa-mp server from the sa-mp website. I've merged the folders and changed nothing in them.
everytime i run it i get these errors:
[17:36:11]
[17:36:11] Server Plugins
[17:36:11] --------------
[17:36:11] Loading plugin: Shoebill
[17:36:11] > Shoebill 1.0 NativePlugin for SA-MP 0.3z R2-4 by MK124, JoJLlmAn & 123marvin123
[17:36:11] > Java VM has been created.
[17:36:11] Loaded.
[17:36:11] Loaded 1 plugins.
[17:36:11]
[17:36:11] Filterscripts
[17:36:11] ---------------
[17:36:11] Loaded 0 filterscripts.
[17:36:11] ShoebillPlugin: AMX registered.
[17:36:11] Script[gamemodes/Shoebill.amx]: Run time error 19: "File or function is not found"
[17:36:11] Number of vehicle models: 0
Does anyone have a surgestion as where to look for a solution? Thanks in advance.
Re: [SNAPSHOT][Java 8] Shoebill 1.0 - SA-MP Java Development Kit -
123marvin123 - 11.10.2014
@joh999: Are you sure, that you use Server version 0.3z R2-4?
It can be found here:
https://sampforum.blast.hk/showthread.php?tid=531302